Ionic 4编译iOS时Pods中GoogleDataTransport目标构建失败求助
Ionic 4 iOS编译失败:GoogleDataTransport编译错误
错误信息
** ARCHIVE FAILED ** The following build commands failed: CompileC /Users/myuser/Library/Developer/Xcode/DerivedData/myapp-gcpsxwgciwwqcxghqjubozbsahac/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/Pods.build/Debug-iphoneos/GoogleDataTransport.build/Objects-normal/arm64/GDTCORPlatform.o /Users/myuser/dev/myapp-ionic/platforms/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'GoogleDataTransport' from project 'Pods') (1 failure) xcodebuild: Command failed with exit code 65 [ERROR] An error occurred while running subprocess cordova. cordova build ios exited with exit code 65. Re-running this command with the --verbose flag may provide more information.
已尝试的解决方法
- 移除并重新添加cordova ios platform @5.1.1
- 多次执行
ionic repair - 执行
pod deintegrate && pod install
相关配置
package.json(关键片段)
"@ionic-native/firebase-x": "^5.36.0", "@ionic/angular": "^4.7.1", "cordova-plugin-androidx": "^1.0.2", "cordova-plugin-androidx-adapter": "^1.1.0", "cordova-plugin-firebase": "^2.0.5", "cordova-plugin-firebasex": "^7.0.1", ... "cordova-plugin-googlemaps": "^2.7.1", "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git", "phonegap-plugin-barcodescanner": "^8.1.0", ... "cordova": { "plugins": { "cordova-plugin-whitelist": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-ionic-keyboard": {}, "cordova-plugin-app-version": {}, "cordova-plugin-network-information": {}, "cordova-plugin-screen-orientation": {}, "cordova.plugins.diagnostic": { "ANDROID_SUPPORT_VERSION": "28.+" }, "cordova-plugin-badge": {}, "cordova-plugin-firebasex": { "FIREBASE_ANALYTICS_COLLECTION_ENABLED": "true", "FIREBASE_PERFORMANCE_COLLECTION_ENABLED": "true", "FIREBASE_CRASHLYTICS_COLLECTION_ENABLED": "true", "ANDROID_ICON_ACCENT": "#FF00FFFF", "ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION": "17.0.0", "ANDROID_FIREBASE_ANALYTICS_VERSION": "17.2.1", "ANDROID_FIREBASE_MESSAGING_VERSION": "20.0.0", "ANDROID_FIREBASE_CONFIG_VERSION": "19.0.3", "ANDROID_FIREBASE_PERF_VERSION": "19.0.1", "ANDROID_FIREBASE_AUTH_VERSION": "19.1.0", "ANDROID_CRASHLYTICS_VERSION": "2.10.1", "ANDROID_CRASHLYTICS_NDK_VERSION": "2.1.1" }, "cordova-plugin-androidx-adapter": {}, "cordova-plugin-apprate": { "PLAY_CORE_VERSION": "1.+" }, "uk.co.workingedge.phonegap.plugin.launchnavigator": { "GOOGLE_API_KEY_FOR_ANDROID": "xxxxxxxxxxxxxx", "OKHTTP_VERSION": "3.12.0", }, "cordova-plugin-androidx": {}, "cordova-plugin-inappbrowser": {}, "cordova-clipboard": {}, "cordova-plugin-geolocation": { "GPS_REQUIRED": "true" }, "phonegap-plugin-barcodescanner": { "ANDROID_SUPPORT_V4_VERSION": "27.+" }, "cordova-plugin-googlemaps": { }, "cordova-plugin-ionic-webview": {} }, "platforms": [ "ios" ] }
Ionic环境信息
Ionic: Ionic CLI : 6.20.8 (/Users/myuser/.nvm/versions/node/v14.19.1/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 4.11.13 @angular-devkit/build-angular : 0.803.29 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.3.3 Cordova: Cordova CLI : 11.1.0 Cordova Platforms : ios 5.1.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 20 other plugins) Utility: cordova-res : 0.15.4 native-run (update available: 1.7.2) : 1.7.1 System: Android SDK Tools : 26.1.1 (/Users/myuser/Library/Android/sdk) ios-deploy : 1.12.1 ios-sim : 8.0.2 NodeJS : v14.19.1 (/Users/myuser/.nvm/versions/node/v14.19.1/bin/node) npm : 6.14.17 OS : macOS Xcode : Xcode 14.3 Build version 14E222b
Podfile配置
source 'https://cdn.cocoapods.org/' platform :ios, '11.0' use_frameworks! target 'MyApp' do project 'MyApp.xcodeproj' pod 'Firebase/Core', '6.13.0' pod 'Firebase/Auth', '6.13.0' pod 'Firebase/Messaging', '6.13.0' pod 'Firebase/Performance', '6.13.0' pod 'Firebase/RemoteConfig', '6.13.0' pod 'Fabric', '1.10.2' pod 'Crashlytics', '3.14.0' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' end end end
解决方案
1. 移除冲突的Firebase插件
你的package.json中同时存在cordova-plugin-firebase和cordova-plugin-firebasex,这两个插件会导致依赖冲突,直接删除旧版插件:
ionic cordova plugin rm cordova-plugin-firebase npm uninstall cordova-plugin-firebase
2. 升级Firebase Pod版本
当前使用的Firebase 6.13.0版本过于老旧,不兼容Xcode 14.3的编译环境。建议升级到Firebase 8.x系列(该版本仍支持Objective-C,适配旧版Cordova插件),修改Podfile如下:
source 'https://cdn.cocoapods.org/' platform :ios, '11.0' use_frameworks! target 'MyApp' do project 'MyApp.xcodeproj' # 升级到兼容Xcode14.3的Firebase版本 pod 'Firebase/Core', '8.15.0' pod 'Firebase/Auth', '8.15.0' pod 'Firebase/Messaging', '8.15.0' pod 'Firebase/Performance', '8.15.0' pod 'Firebase/RemoteConfig', '8.15.0' # 替换停止维护的Fabric为Firebase Crashlytics pod 'Firebase/Crashlytics', '8.15.0' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # 保留原设置,添加兼容Xcode14的编译选项 config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' # 解决旧库的引用警告 config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = 'NO' # 适配arm64架构 config.build_settings['EXCLUDED_ARCHS'] = 'arm64' if config.name == 'Debug' end end end
3. 彻底清理并重建项目
# 移除iOS平台 ionic cordova platform rm ios # 删除Pods缓存和Xcode派生数据 rm -rf platforms/ios/Pods rm -rf ~/Library/Developer/Xcode/DerivedData # 重新添加iOS平台 ionic cordova platform add ios@5.1.1 # 执行pod安装 cd platforms/ios && pod deintegrate && pod install && cd ../.. # 重新编译项目 ionic cordova build ios --prod
4. 检查Xcode项目设置
打开platforms/ios/MyApp.xcodeproj,确认以下设置:
- 项目的
Deployment Target设置为iOS 11.0或更高 Build Settings中的Excluded Architectures在Debug模式下添加arm64Build Options中的Enable Bitcode设置为NO(旧版Cordova插件通常不支持Bitcode)
内容的提问来源于stack exchange,提问作者anderlaini
相关产品推荐
相关产品推荐

