React Native iOS 自动打包+发布历险记(未完待续)

一、配置环境
iOS在环境这块比安卓的要简单一些,不用配置环境变量,只需要准备一台mac(原先想用linux来搞,被劝退)。安装或升级到xcode最新版。
测试下使用xcode工具打离线包,项目先初始化好,然后按标准流程打包即可:
1、从develop.appstore下载并导入到本地证书;
2、还是从develop.appstore生成profile并下载下来;
3、在网上随便找一篇教程照着做就行了,这里不详述。

二、命令打包

cd项目的ios目录下:
第1步:

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./release_ios/main.jsbundle --assets-dest ./release_ios

 

第2步:

xcodebuild archive -workspace AwesomeProject.xcworkspace -scheme AwesomeProject -configuration Release -archivePath archive/release.ipa 
CODE_SIGN_IDENTITY=./cert/release.p12 PROVISIONING_PROFILE=./cert/testappprofile3.mobileprovision

 

第3步:

xcodebuild -exportArchive -archivePath archive/release.ipa.xcarchive -exportPath archive/release -exportOptionsPlist AwesomeProject/Adhoc.plist

 

所有的步骤都基于xcode工具已经能正常导出ipa包的前提下的坑!xcode工具导出的坑解决时间短,就不记录了。

缺少第1步,直接运行第2步会报错(这一步卡了2天):

error SHA-1 for file /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/lib/polyfills/require.js (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/lib/polyfills/require.js) is not computed. Run CLI with --verbose flag for more details.
ReferenceError: SHA-1 for file /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/lib/polyfills/require.js (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/lib/polyfills/require.js) is not computed
at DependencyGraph.getSha1 (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/node-haste/DependencyGraph.js:263:13)
at /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:211:26
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:46:24)
at _next (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:66:9)
at /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:71:7
at new Promise (<anonymous>)
at /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:63:12
at Transformer.transformFile (/Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/DeltaBundler/Transformer.js:236:7)
at /Users/yangdejian/desktop/work/app/AwesomeProject/node_modules/metro/src/Bundler.js:87:34
……
……
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/yangdejian/Library/Developer/Xcode/DerivedData/AwesomeProject-dagximgtjqvkfdhiqllocbioygbe/Build/Intermediates.noindex/ArchiveIntermediates/AwesomeProject/IntermediateBuildFilesPath/AwesomeProject.build/Release-iphoneos/AwesomeProject.build/Script-00DD1BFF1BD5951E006B06BC.sh

 


第3步,不能直接用项目下的Info.plist(ad-hoc和appstore包的配置不一样),会报错:(参考:https://www.jianshu.com/p/4281908243a3 )

Error Domain=IDECodesignResolverErrorDomain Code=1 "No signing certificate "iOS Development" found" UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedRecoverySuggestion=No "iOS Development" signing certificate matching team ID "G758H44A7X" with a private key was found., IDEProvisioningError_UserInfoKey_IDEProvisioningErrorSpecifier=iOS Development, NSLocalizedDescription=No signing certificate "iOS Development" found, IDEProvisioningError_UserInfoKey_IDEProvisioningErrorPlatform=com.apple.platform.iphoneos, IDEProvisioningError_UserInfoKey_IDEProvisioningErrorAction=5, IDEProvisioningError_UserInfoKey_IDEProvisioningErrorTeam=<IDEProvisioningBasicTeam: 0x7fc78b2f4ac0; teamID='G758H44A7X', teamName='(null)'>}
error: exportArchive: No signing certificate "iOS Development" found

 

因为不知道怎么构建这个plist文件,最后网上找到办法,直接xcode导出来,然后复制导出的ExportOptions.plist过来(这一步也卡了3-4个小时)

【TODO】三、编写打包脚本(并发布离线测试包)

【TODO】四、jenkins配置测试

【TODO】五、自动上架appstore

posted @ 2020-12-10 18:58  流失的痕迹  阅读(589)  评论(0编辑  收藏  举报