集成Tap To Pay on iPhone Cordova插件时Ionic项目构建失败求助
Ionic+Cordova集成Tap To Pay on iPhone构建失败解决方案
问题重现
在Cordova插件中集成Tap To Pay on iPhone功能,添加插件到Ionic项目后执行构建,抛出以下错误:
d/sharedpch -pch-disable-validation -module-name Product -frontend-parseable-output -disable-clang-spi -target-sdk-version 16.1 -parse-as-library -o /Users/mads/Library/Developer/Xcode/DerivedData/Product-anlvmriclbyybqfhfhbdkszgzqql/Build/Intermediates.noindex/Product.build/Debug-iphonesimulator/Product.build/Objects-normal/x86_64/CDVTapToPay.o -index-unit-output-path /Product.build/Debug-iphonesimulator/Product.build/Objects-normal/x86_64/CDVTapToPay.o -index-store-path /Users/mads/Library/Developer/Xcode/DerivedData/Product-anlvmriclbyybqfhbdkszgzqql/Index.noindex/DataStore -index-system-modules /Users/mads/company/2/menon/platforms/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.1.99. (in target 'Branch' from project 'Pods') ** BUILD FAILED ** The following build commands failed: SwiftEmitModule normal x86_64 Emitting\ module\ for\ Product (in target 'Product' from project 'Product') (1 failure) Command finished with error code 65: xcodebuild -workspace,Product.xcworkspace,-scheme,Product,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 14 Pro Max,build,CONFIGURATION_BUILD_DIR=/Users/mads/company/2/menon/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/mads/company/2/menon/platforms/ios/build/sharedpch xcodebuild: Command failed with exit code 65 Error: xcodebuild: Command failed with exit code 65 at ChildProcess.whenDone (/Users/mads/company/2/menon/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:136:25) at ChildProcess.emit (events.js:193:13) at maybeClose (internal/child_process.js:999:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5) [ERROR] An error occurred while running subprocess cordova. cordova build ios --verbose exited with exit code 65. Re-running this command with the --verbose flag may provide more information. ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms ionic:utils-process onBeforeExit handler: running 2 functions +2ms ionic:utils-process processExit: exiting (exit code: 65) +62ms
问题根源
- 依赖版本不兼容:Pod依赖
Branch的iOS部署目标设为9.0,而当前Xcode SDK支持的最低版本是11.0,版本不匹配触发兼容性问题。 - Swift模块编译失败:
SwiftEmitModule步骤出错,大概率是Swift版本、部署目标不统一,或者Cordova插件的Swift配置缺失导致。
解决步骤
1. 统一所有Pod的部署目标
打开项目的platforms/ios/Podfile,在文件末尾添加以下代码,强制所有Pod的部署目标与项目一致(这里设为11.0,也可根据Tap To Pay要求设为15.0):
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' end end end
然后执行命令更新Pod配置:
cd platforms/ios && pod install
2. 配置Cordova插件的Swift支持
检查Tap To Pay插件的plugin.xml,确保包含以下配置:
- 引入Swift框架依赖:
<framework src="Swift.framework" weak="true" /> - 指定Swift版本(比如5.0,根据你的Xcode版本调整):
<preference name="SWIFT_VERSION" value="5.0" />
3. 清理项目后重新构建
- 移除并重新添加iOS平台,清除旧的配置缓存:
ionic cordova platform remove ios ionic cordova platform add ios - 删除Xcode的DerivedData,避免缓存干扰:
rm -rf ~/Library/Developer/Xcode/DerivedData - 重新执行构建:
ionic cordova build ios --verbose
4. 适配Tap To Pay的最低版本要求
Tap To Pay on iPhone要求iOS 15.0及以上,在项目的config.xml中设置最低iOS版本:
<preference name="ios-minimum-version" value="15.0" />
内容的提问来源于stack exchange,提问作者mesh
相关产品推荐
相关产品推荐

