iOS Jenkins打包遇到的坑

使用的打包命令:

xcodebuild archive -workspace $project_name.xcworkspace -scheme $project_name -configuration Release -archivePath archive/$project_name.xcarchive CODE_SIGN_IDENTITY=”iPhone Developer: xxxxxx (xxxxxxx)” PROVISIONING_PROFILE_SPECIFIER=”development_orange”

echo “第五步,执行编译生成.ipa命令”

xcodebuild -exportArchive -exportOptionsPlist archieveOpt.plist -archivePath archive/$project_name.xcarchive -exportPath ./ -configuration Release

打包命令在这里不多做解释,主要说一下遇到的两个坑.

参考文章:

第三方库使用 Framework,用 Jenkins 打包时报错

iOS 命令打包

坑一:Podfile 文件中使用了 use_frameworks!造成的坑

如果Podfile 文件中使用了 use_frameworks,那么Jenkins打包时出现以下错误

Check dependencies

Code Signing Error: AFNetworking does not support provisioning profiles. AFNetworking does not support provisioning profiles, but provisioning profile development_orange has been manually specified. Set the provisioning profile value to “Automatic” in the build settings editor.

这是因为使用了 use_frameworks后,CocoaPods 要对每一个 Framework 进行证书签名,而每个 Framework 的 bundleID 都是不一样的

解决方案:

在 Podfile 中添加如下代码:

post_install do |installer|

    installer.pods_project.targets.each do |target|

        target.build_configurations.each do |config|

            config.build_settings[‘EXPANDED_CODE_SIGN_IDENTITY’] = “”

            config.build_settings[‘CODE_SIGNING_REQUIRED’] = “NO”

            config.build_settings[‘CODE_SIGNING_ALLOWED’] = “NO”

        end

    end

end

添加后的podfile文件如下:

platform :ios, ‘8.0’

use_frameworks!

post_install do |installer|

    installer.pods_project.targets.each do |target|

        target.build_configurations.each do |config|

            config.build_settings[‘EXPANDED_CODE_SIGN_IDENTITY’] = “”

            config.build_settings[‘CODE_SIGNING_REQUIRED’] = “NO”

            config.build_settings[‘CODE_SIGNING_ALLOWED’] = “NO”

        end

    end

end

target ‘QingPu’ do

    pod ‘MBProgressHUD’

    pod ‘MJExtension’,’~> 3.0.13′

    pod ‘MJRefresh’

    pod ‘ReactiveObjC’

    pod ‘FMDB’, ‘~> 2.7.2’

end

坑二:Archive成功,export ipa文件时失败,报以下错误:error: exportArchive: The data couldn’t be read because it isn’t in the correct format 

Error Domain=NSCocoaErrorDomain Code=3840 “No value.” UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

第五步,执行编译生成.ipa命令

2018-05-18 15:22:27.811 xcodebuild[32828:2936854] [MT] IDEDistribution: Step failed: : Error Domain=NSCocoaErrorDomain Code=3840 “No value.” UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

error: exportArchive: The data couldn’t be read because it isn’t in the correct format.

Error Domain=NSCocoaErrorDomain Code=3840 “No value.” UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

** EXPORT FAILED **

这是因为配置文件archieveOpt.plist中compileBitcode选项没有配置,默认compileBitcode为YES,要设置成NO就可以了,archieveOpt.plist配置后的样式如下:

《iOS Jenkins打包遇到的坑》

再次打包就可以了

坑三:jenkins 自动构建 IOS 包签名遇到问题   app: errSecInternalComponent Command /usr/bin/codesign failed with exit code 1

解决办法:

 编译之前添加 security unlock-keychain -p “你的密码” “path to keychain/login.keychain”

根本原因是Jenkins,ssh方式到slave机上,默认是没有账户的,但是访问钥匙串要求必须有用户身份,所以添加一步输入密码解锁钥匙串,可以给Jenkins一个用户身份。 build步骤前添加一步解锁钥匙串。 security unlock-keychain -p “login pwd” ~/Library/Keychains/login.keychain

    原文作者:FM_0138
    原文地址: https://www.jianshu.com/p/4d182d7fbf01
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞