jenkins xcodebuild命令行打包iOS项目问题汇总

这几天折腾了jenkins对iOS swift项目的持续集成,碰到了很多问题,记录下吧

1. 缺少scheme

xcodebuild: error: The project named “Foo” does not contain a scheme named “Bar”. The “-list” option can be used to find the names of the schemes in the project.

解决办法:
The root cause is that the default behavior of Schemes is to keep schemes ‘private’ until they are specifically marked as shared. In the case of a command-line initiated build, the Xcode UI never runs and the xcoderun tool doesn’t have its own cache of Schemes to work with.
To your schema be visible for command-line build you must mark it as a shared scheme.

Choose Scheme > Manage Schemes (from the Product Menu).
Ensure the ‘Shared’ box is checked for that scheme
A new .xcscheme file has been created in your project at
WorkspaceName.xcworkspace/xcshareddata/xcschemes.
Commit this file to your repository

2. Error: User interaction is not allowed.

运行下面的命令可解决

$ security unlock-keychain -p  ~/Library/Keychains/login.keychain
$ security show-keychain-info ~/Library/Keychains/login.keychain
Keychain "/Users/XXX/Library/Keychains/login.keychain" no-timeout

3. Xcode 7后导出IPA命令发生变化

以前我是通过下面的命令打包的,但现在的swift项目这样导出的包在iPhone安装后直接闪退

xcodebuild -target ${TARGET_NAME} -configuration ${BUILD_CONFIGURATION} -sdk phones build
xcrun -sdk iphoneos PackageApplication -v ${APP_NAME} -o ${IPA_PATH}

Xcode7之后取消了原来的-exportFormat,而是使用exportOptionsPlist 来取代,具体的使用方法可以在Terminal打xcodebuild –help查看。
我们需要自己创建一个plist作为Export Options,只要有这个配置文件,那我们在使用这个命令的时候就能打出跟手动用Xcode Archive之后export出的ipa一样了。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>teamID</key>
  <string>XXXXXXX</string>
  <key>method</key>
  <string>enterprise</string>
  <key>compileBitcode</key>
  <false/>
  <key>uploadSymbols</key>
  <false/>
</dict>
</plist>

4. 最新的xcodebuild 导出ipa命令

xcodebuild archive -project {xcodeproj} -scheme '{scheme}' -sdk iphoneos  -archivePath {archive_path}
xcodebuild -exportArchive -archivePath  {archive_path} -exportPath {export_path}  -exportOptionsPlist {export_plist_path}

[本文独立博客地址](http://www.offbye.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

offbye

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值