Jenkins配置Xcode自动管理证书的问题

之前配置Jenkins时Xcode还是用的手动管理证书,然后最近想把手动管理证书改为自动管理证书,但是Jenkins貌似不支持构建自动管理证书的项目,于是问题来了,怎么办呢。百度了一下,发现有大神说通过Shell sed替换命令将自动选择证书改为手动配置证书。
sed -i "" s/'ProvisioningStyle = Automatic;'/'DevelopmentTeam = T5******24;ProvisioningStyle = Manual;'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
但是呢,由于我们现有项目中含有Widget组件开发,所以单单这么配置,似乎不够。于是决定找出项目中各自的配置文件分别用sed命令替换成指定的配置文件。但是问题又出现了,因为Widget跟项目中证书对应的参数名称是相同的,但是配置文件不是一个,用sed命令替换指定字符串的话,会将所有的PROVISIONING_PROFILE所对应的值全部改掉,这不是我们想要的结果啊。于是怎么办呢,最后找到了一个办法临时解决这个问题,那就是替换指定行,虽然方法很傻,但是的确解决了这个问题。

sed -i "" s/'ProvisioningStyle = Automatic;'/'DevelopmentTeam = T5******24;ProvisioningStyle = Manual;'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i "" s/'PROVISIONING_PROFILE = "";'/'PROVISIONING_PROFILE = "NewDevProfile";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i ""  8635s/'PROVISIONING_PROFILE = "NewDevProfile";'/'PROVISIONING_PROFILE = "AAWidgetProfile_dev";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i ""  8660s/'PROVISIONING_PROFILE = "NewDevProfile";'/'PROVISIONING_PROFILE = "AAWidgetProfile_dev";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i "" s/'DEVELOPMENT_TEAM = "";'/'DEVELOPMENT_TEAM = T5******24;'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i "" s/'PROVISIONING_PROFILE_SPECIFIER = "";'/'PROVISIONING_PROFILE_SPECIFIER = "NewDevProfile";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i ""  8636s/'PROVISIONING_PROFILE_SPECIFIER = "NewDevProfile";'/'PROVISIONING_PROFILE_SPECIFIER = "AAWidgetProfile_dev";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i ""  8661s/'PROVISIONING_PROFILE_SPECIFIER = "NewDevProfile";'/'PROVISIONING_PROFILE_SPECIFIER = "AAWidgetProfile_dev";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj
sed -i "" s/'CODE_SIGN_IDENTITY = "iPhone Developer";'/'CODE_SIGN_IDENTITY = "iPhone Developer: ****** (Q2******23)";'/g /Users/qa/.jenkins/workspace/IOS_Client/AAyongche5.0/AAzuche.xcodeproj/project.pbxproj

后来配好了之后又报了错

error: Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's.

    Embedded Binary Signing Certificate:    Not Code Signed
    Parent App Signing Certificate:         iPhone Developer: Emil Adz (9QNEF95395)

原来是导入证书后右键简介看下不要选择总是信任,选择系统默认就好了。
关于这个解决方案,肯定不是最好的,先分享出来解决一下目前的发生的问题,我也一直会继续寻找一个最优的解决方案,然后分享出来。

你可能感兴趣的:(iOS,Xcode,iOS项目经验)