Xcode归档flutter插件失败

6
我的Flutter应用程序运行良好,但当我尝试通过归档将应用程序上传到App Store时: Xcode -> Product -> Archive 它失败了,并出现了两个错误。 第一个错误在flutter_inappwebview中,具有以下错误消息:
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'flutter_inappwebview' from project 'Pods')
    cd /Users/user1/StudioProjects/app/ios/Pods
    export DEVELOPER_DIR\=/Applications/Xcode.app/Contents/Developer
    export SDKROOT\=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.4.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name flutter_inappwebview -O -whole-module-optimization -enforce-exclusivity\=checked @/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/Objects-normal/arm64/flutter_inappwebview.SwiftFileList -D COCOAPODS -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.4.sdk -target arm64-apple-ios12.0 -g -module-cache-path /Users/user1/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -embed-bitcode -swift-version 5 -I /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/flutter_inappwebview -F /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/flutter_inappwebview -F /Users/user1/flutter/bin/cache/artifacts/engine/ios-release/Flutter.xcframework/ios-arm64_armv7 -F /Users/osamahhaitham/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/OrderedSet -c -num-threads 4 -output-file-map /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/Objects-normal/arm64/flutter_inappwebview-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/Objects-normal/arm64/flutter_inappwebview.swiftmodule -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/flutter_inappwebview-generated-files.hmap -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/flutter_inappwebview-own-target-headers.hmap -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/flutter_inappwebview-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/flutter_inappwebview-project-headers.hmap -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/flutter_inappwebview/include -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/DerivedSources-normal/arm64 -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/DerivedSources/arm64 -Xcc -I/Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/DerivedSources -Xcc -DPOD_CONFIGURATION_RELEASE\=1 -Xcc -DCOCOAPODS\=1 -emit-objc-header -emit-objc-header-path /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/Objects-normal/arm64/flutter_inappwebview-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/flutter_inappwebview.build/unextended-module-overlay.yaml -working-directory /Users/user1/StudioProjects/app/ios/Pods

remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
Command CompileSwiftSources failed with a nonzero exit code

DKImagePickerController 的第二个问题

SwiftCodeGeneration normal arm64 (in target 'DKImagePickerController' from project 'Pods')
    cd /Users/user1/StudioProjects/app/ios/Pods
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.bc -embed-bitcode -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -O -disable-llvm-optzns -module-name DKImagePickerController -o /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.o

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/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.bc -embed-bitcode -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -O -disable-llvm-optzns -module-name DKImagePickerController -o /Users/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.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/user1/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.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           0x000000010fa19de7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010fa18e38 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010fa1a440 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007ff81c319dfd _sigtramp + 29
4  libsystem_malloc.dylib   0x00007ff81c137abb _malloc_zone_malloc + 125
5  libsystem_c.dylib        0x00007ff81c24fd24 abort + 123
6  swift-frontend           0x000000010f966cda llvm::report_bad_alloc_error(char const*, bool) + 106
7  swift-frontend           0x000000010f966cf2 out_of_memory_new_handler() + 18
8  libc++abi.dylib          0x00007ff81c2c196b operator new(unsigned long) + 43
9  swift-frontend           0x000000010f727efd llvm::Function::BuildLazyArguments() const + 77
10 swift-frontend           0x000000010d510e87 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           0x000000010d523f88 (anonymous namespace)::ObjCARCContract::run(llvm::Function&, llvm::AAResults*, llvm::DominatorTree*) + 1384
12 swift-frontend           0x000000010f75f380 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1488
13 swift-frontend           0x000000010f766073 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
14 swift-frontend           0x000000010f75fb39 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1161
15 swift-frontend           0x000000010ac7d6df swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 3791
16 swift-frontend           0x000000010ac7e8cc 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           0x000000010ac87aa5 swift::performLLVM(swift::IRGenOptions const&, swift::ASTContext&, llvm::Module*, llvm::StringRef) + 213
18 swift-frontend           0x000000010a742795 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 16565
19 swift-frontend           0x000000010a7015d4 swift::mainEntry(int, char const**) + 1108
20 dyld                     0x000000011812c51e start + 462
error: Abort trap: 6 (in target 'DKImagePickerController' from project 'Pods')

我执行了pod install & update,尝试了很多方法但没能解决问题。请问如何修复呢?谢谢。

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

pubspec.yaml

name: app_test
description: app_test Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.5.0+61 

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:  
    sdk: flutter
  shared_preferences: ^2.0.13  
  http: ^0.13.4  
  intl: ^0.17.0 
  encrypt: ^5.0.1 
  json_annotation: ^4.4.0 
  searchable_dropdown: ^1.1.3  
  flutter_typeahead: ^3.2.4  
  flutter_datetime_picker: ^1.5.1  
  image_picker: ^0.8.4+10 
  connectivity_plus: ^2.2.1  
  flutter_svg: ^0.23.0+1  
  file_picker: ^4.5.0 
  open_file: ^3.2.1  
  permission_handler: ^9.2.0  
  path_provider: ^2.0.9 
  sqflite: ^2.0.2 
  device_info_plus: ^3.2.2
  url_launcher: ^6.0.20 
  maps_launcher: ^2.0.1 
  package_info_plus: ^1.4.0 #package info
  flutter_html: ^2.2.1  #html display
  html_editor_enhanced: ^2.4.0+1 #html textbox summernote
  cupertino_icons: ^1.0.4 # Use with the CupertinoIcons class for iOS style icons.
  flutter_colorpicker: ^1.0.3
  syncfusion_flutter_calendar: ^19.4.55 
  geolocator: ^8.2.0
  mobile_scanner: ^1.0.0 


dev_dependencies:
  flutter_test:
    sdk: flutter
  platform: ^3.1.0

@ArbiterChil 是的 - blue492
如果是这样,那么你很幸运。如果是分段的包,则需要更新一些包,还有一些包会出现“abort trap 6”错误,需要更新一些代码。因此,现在最好的选择是回到13.2.1版本的Xcode,并等待作者更新软件包中的Swift文件。在某些情况下,你无法控制这种情况,只能等待。 - Arbiter Chil
1
@blue492 从这里 https://xcodereleases.com/ 下载13.2.1版本,然后解压缩文件。首先进入Xcode->Preferences->location->Command Line Tools,选择13.2.1版本或者直接点击你下载的已解压缩的.xip文件。 - Arbiter Chil
@blue492,我编辑了我的新评论。 - Arbiter Chil
1
@blue492 没问题,很高兴能帮忙。上周晚上更新 Xcode 后我也遇到了这个问题,但是它真的很讨厌,哈哈哈,所以我在我的 Mac 上安装了三个版本的 Xcode。 - Arbiter Chil
显示剩余5条评论
3个回答

5

我在 iOS 文件夹的 Podfile 中添加了以下行。我成功地存档了应用程序并上传到 App Store。我的 Xcode 版本是 13.3。

pod 'DKImagePickerController/PhotoGallery',:git => 'https://github.com/miguelpruivo/DKImagePickerController.git'

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  pod 'DKImagePickerController/PhotoGallery', :git => 'https://github.com/miguelpruivo/DKImagePickerController.git'
end

哇,谢谢!这是我唯一可靠且易于操作的解决方案。完全忘记了这个解决方案是一个可能性。感谢! - Christian X
只需进行一个编辑,也遵循此解决方案:您还需要在终端中运行:flutter clean --> pod deintegrate --> flutter pub get --> pod install。然后一切都应该完美运行 :) - Christian X
是的,您需要运行flutter clean和flutter pub get。 问题不在于在设备上运行应用程序时,而是在归档时。 - Yogesh Tandel
即使使用 Xcode 13.3.1 和 Flutter 10.2.4,我仍然遇到了错误。上面的代码解决了这个问题。 - Karsten Silz

4
从13.3版本降级到13.2.1版本解决了我的问题。

遇到了类似的问题,但是由于(打印)pub而出现了错误,并且可以确认降级是正确的解决方案。 - Richard Suarez
在构建我的Flutter应用程序时,出现了“错误:分段错误:11(在项目'Pods'的目标'DKImagePickerController'中)”。将Xcode从13.3降级到13.2.1也为我解决了这个问题。 - Karsten Silz

2

当您使用UI_USER_INTERFACE_IDIOM()时,这是在Xcode 13.3或Swift 5.6中发生的错误。

将其替换为UIDevice.current.userInterfaceIdiom可以解决此错误。

[SR-16003]此线程中查看更多讨论。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接