'Flutter for iOS run, build but not archive

My app archive perfectly two weeks age (was the latest update I made).

After some minor changes in the flutter code (I did not add any packages or something), I am trying to archive again and I am getting some estrange errors and I have no clue where are coming from (those are from libraries, so no real changes on it). I am able to run it on the emulator and also I am able to build without any problem. I just can not archive.

This is the error:

Running Xcode build...                                                  
Xcode archive done.                                         80.5s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-03-20 00:27:32.265 xcodebuild[22543:393081] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension
    Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-03-20 00:27:32.266 xcodebuild[22543:393081] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension
    Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** ARCHIVE FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/lp/myd6ssb57_jg81p9920h5_sr0000gn/T/flutter_tools.AJZJFr/flutter_ios_build_temp_dir4zPWKc/temporary_xcresult_bundle

    LLVM ERROR: out of memory
    Allocation failed
    Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
    Stack dump:
    0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file
    /Users/eae/Library/Developer/Xcode/DerivedData/Runner-cssekixerfgncvbcfrtqdpehzsfb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/prin
    ting.build/Objects-normal/arm64/PrintJob.bc -embed-bitcode -target arm64-apple-ios11.0 -Xllvm -aarch64-use-tbi -O -disable-llvm-optzns -module-name printing -o
    /Users/eae/Library/Developer/Xcode/DerivedData/Runner-cssekixerfgncvbcfrtqdpehzsfb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/prin
    ting.build/Objects-normal/arm64/PrintJob.o
    1.  Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
    2.  Compiling with the current language version
    3.  Running pass 'Function Pass Manager' on module
    '/Users/eae/Library/Developer/Xcode/DerivedData/Runner-cssekixerfgncvbcfrtqdpehzsfb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/pri
    nting.build/Objects-normal/arm64/PrintJob.bc'.
    4.  Running pass 'ObjC ARC contraction' on function '@UI_USER_INTERFACE_IDIOM'
    Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
    0  swift-frontend           0x0000000107437de7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
    1  swift-frontend           0x0000000107436e38 llvm::sys::RunSignalHandlers() + 248
    2  swift-frontend           0x0000000107438440 SignalHandler(int) + 288
    3  libsystem_platform.dylib 0x00007ff80f10cdfd _sigtramp + 29
    4  libsystem_malloc.dylib   0x00007ff80ef2aabb _malloc_zone_malloc + 125
    5  libsystem_c.dylib        0x00007ff80f042d24 abort + 123
    6  swift-frontend           0x0000000107384cda llvm::report_bad_alloc_error(char const*, bool) + 106
    7  swift-frontend           0x0000000107384cf2 out_of_memory_new_handler() + 18
    8  libc++abi.dylib          0x00007ff80f0b496b operator new(unsigned long) + 43
    9  swift-frontend           0x0000000107145efd llvm::Function::BuildLazyArguments() const + 77
    10 swift-frontend           0x0000000104f2ee87 llvm::objcarc::BundledRetainClaimRVs::insertRVCallWithColors(llvm::Instruction*, llvm::CallBase*, llvm::DenseMap<llvm::BasicBlock*,
    llvm::TinyPtrVector<llvm::BasicBlock*>, llvm::DenseMapInfo<llvm::BasicBlock*>, llvm::detail::DenseMapPair<llvm::BasicBlock*, llvm::TinyPtrVector<llvm::BasicBlock*> > > const&) + 151
    11 swift-frontend           0x0000000104f41f88 (anonymous namespace)::ObjCARCContract::run(llvm::Function&, llvm::AAResults*, llvm::DominatorTree*) + 1384
    12 swift-frontend           0x000000010717d380 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1488
    13 swift-frontend           0x0000000107184073 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
    14 swift-frontend           0x000000010717db39 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1161
    15 swift-frontend           0x000000010269b6df swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 3791
    16 swift-frontend           0x000000010269c8cc swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*,
    llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2812
    17 swift-frontend           0x00000001026a5aa5 swift::performLLVM(swift::IRGenOptions const&, swift::ASTContext&, llvm::Module*, llvm::StringRef) + 213
    18 swift-frontend           0x0000000102160795 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 16565
    19 swift-frontend           0x000000010211f5d4 swift::mainEntry(int, char const**) + 1108
    20 dyld                     0x000000011690651e start + 462
    error: Abort trap: 6 (in target 'printing' from project 'Pods')
    error: backend command failed due to signal 6 (use -v to see invocation)

I have tried the following:

  • in ios/ folder of your project, change Podfile to

    platform :ios, '12.0'

  • Run pod deintegrate in Terminal inside the ios/ folder of your project.

  • Run pod install --repo-update in your ios/ folder

And from flutter doctor:

[✓] Flutter (Channel stable, 2.10.3, on macOS 12.3 21E230 darwin-x64, locale en-ES)
    • Flutter version 2.10.3 at /Users/eae/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (2 weeks ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/eae/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.65.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 50A38949-153E-4E22-AAF3-E96FC64DF2B5 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 99.0.4844.74

[✓] HTTP Host Availability
    • All required HTTP hosts are available
```


Solution 1:[1]

This is an issue that occurs in version 13.3 of Xcode. In Xcode 13.3, if you have a code that uses UI_USER_INTERFACE_IDIOM(), you will get an "Out of Memory" error when you run Archive. Changing "UI_USER_INTERFACE_IDIOM()" to "UIDevice.current.userInterfaceIdiom" resolves the error.

Currently, we have the following solutions.

  • Modify the code,
  • Downgrade to Xcode 13.2.1
  • Wait for Apple to modify Xcode

References

Solution 2:[2]

In my case I fix this replacing UI_USER_INTERFACE_IDIOM() into UIDevice.current.userInterfaceIdiom.(You can find this in pods folder). I think this happened in Xcode 13.3

Check this as well

https://developer.apple.com/forums/thread/702200

Solution 3:[3]

13.3 of the Xcode version has this problem, first of all, delete your current XCode application. Use the below method:

Click on the Finder icon > On the Sidebar, you will find Applications, click on it, then delete the Xcode icon. That will remove Xcode from your system completely. Restart your Mac.

After install the 13.2.1 version, change the UI_USER_INTERFACE_IDIOM() to UIDevice.current.userInterfaceIdiom while run Archive.

Now go to the Xcode Releases page and download an Xcode 13.2.1 version.

Use the 13.2.1 version until Apple solves this issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 y2ducky
Solution 2
Solution 3 Fakhriddin Abdullaev