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

来源:互联网 发布:怎么报考网络教育 编辑:程序博客网 时间:2024/04/28 16:53

这几天折腾了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.keychainKeychain "/Users/XXX/Library/Keychains/login.keychain" no-timeout

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

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

xcodebuild -target ${TARGET_NAME} -configuration ${BUILD_CONFIGURATION} -sdk phones buildxcrun -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)

1 0