• 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

  • 相关阅读:
    NO.6: 若不想编译器提供自动生成的函数,就应该明确拒绝
    NO.5: 了解C++编译器默认为你生成的构造/赋值/析构
    NO.4: 确定对象被使用前已被初始化
    NO.3: 尽量使用const
    NO.2: 尽量以const,enum,inline 替换 #define
    NO.1: 视C++为一个语言联邦
    C/C++ exception类
    C/C++ 类成员函数指针 类成员数据指针
    c++中的 Stl 算法(很乱别看)
    自定义类签发校验token-实现多方式登录-自定义反爬类-admin后台表管理字段自定义-群查接口-搜索-排序-分页
  • 原文地址:https://www.cnblogs.com/Denny_Yang/p/14116708.html
Copyright © 2020-2023  润新知