Travis CI无法构建我的应用程序,因为Xcode项目设置为需要代码签名而Travis没有我的证书。我可以通过禁用代码签名来解决这个问题,但随后沙盒和权利无法正常工作。我知道通常从命令行构建时,您可以将CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
传递给xcodebuild
以禁用代码签名,但如何在Travis CI中执行此操作?
这是我的.travis.yml
:
language: objective-c
xcode_workspace: "Mac Linux USB Loader.xcworkspace"
xcode_scheme: "Mac Linux USB Loader"
这就是错误(我已经编写了许多以前指向Cocoapods的行,因为它们并不相关:
Check dependencies
Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “T47PR9EQY5” were found.
答案 0 :(得分:16)
您是否尝试在travis.yml上添加此内容:
language: objective-c
script:
- xcodebuild [DEFAULT_OPTIONS] CODE_SIGNING_REQUIRED=NO
或者导入开发(以及在您的构建中使用的分发)密钥链的证书/密钥并复制您的团队配置文件,以使代码签名工作。像这样:
language: objective-c
before_script:
- ./scripts/add-key.sh
script:
- xcodebuild [DEFAULT_OPTIONS] CODE_SIGNING_REQUIRED=NO
add-key.sh
#!/bin/sh
KEY_CHAIN=ios-build.keychain
security create-keychain -p travis $KEY_CHAIN
# Make the keychain the default so identities are found
security default-keychain -s $KEY_CHAIN
# Unlock the keychain
security unlock-keychain -p travis $KEY_CHAIN
# Set keychain locking timeout to 3600 seconds
security set-keychain-settings -t 3600 -u $KEY_CHAIN
# Add certificates to keychain and allow codesign to access them
security import ./scripts/certs/dist.cer -k $KEY_CHAIN -T /usr/bin/codesign
security import ./scripts/certs/dev.cer -k $KEY_CHAIN -T /usr/bin/codesign
security import ./scripts/certs/dist.p12 -k $KEY_CHAIN -P DISTRIBUTION_KEY_PASSWORD -T /usr/bin/codesign
security import ./scripts/certs/dev.p12 -k $KEY_CHAIN -P DEVELOPMENT_KEY_PASSWORD -T /usr/bin/codesign
echo "list keychains: "
security list-keychains
echo " ****** "
echo "find indentities keychains: "
security find-identity -p codesigning ~/Library/Keychains/ios-build.keychain
echo " ****** "
# Put the provisioning profile in place
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp "./scripts/profiles/iOSTeam_Provisioning_Profile_.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
cp "./scripts/profiles/DISTRIBUTION_PROFILE_NAME.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
答案 1 :(得分:11)
在使用Xcode 7项目+ Swift + iOS 9 + travis-ci上提供的持续集成工具时,请在下面找到我的 .travis.yml 文件,该文件修复了此错误消息和其他错误消息。组织:
# http://docs.travis-ci.com/user/languages/objective-c/
# https://github.com/facebook/xctool
language: objective-c
osx_image: xcode7
# xcode_project: SampleNotifcations/SampleNotifcations.xcodeproj
# xcode_workspace: SampleNotifcations/SampleNotifcations.xcworkspace
# xcode_scheme: SampleNotifcationsTests
podfile: SampleNotifcations/Podfile
# xcode_sdk: iphonesimulator9.0
script:
xctool
-workspace SampleNotifcations/SampleNotifcations.xcworkspace
-scheme SampleNotifcationsTests
-sdk iphonesimulator
-destination 'platform=iOS Simulator,name=iPhone 6 Plus'
build
test
ONLY_ACTIVE_ARCH=NO
CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO
before_install:
- brew update
- brew uninstall xctool && brew install --HEAD xctool
来源:
答案 2 :(得分:3)
如果您不需要为iphoneos
构建,例如如果您只想知道项目是否构建或单元测试是否通过。您可以指定iphonesimulator
sdk。通过这样做,xctool
将不会签署代码。
script: xctool -sdk iphonesimulator -workspace {WORKSPACE}.xcworkspace -scheme {SCHEME} build test
答案 3 :(得分:2)
language: objective-c
script: xctool -project [xcodeproject] -scheme [scheme] build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
您可以参考this .travis.yml
答案 4 :(得分:1)
.travis.yml:
language: objective-c
osx_image: xcode7.2
script:
- xctool -workspace XXX.xcworkspace -scheme XXX -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
- xctool test -workspace XXX.xcworkspace -scheme XXXTests -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
before_script:
- chmod a+x ./scripts/add-key.sh
- sh ./scripts/add-key.sh
add-key.sh:
#!/bin/sh
# Create a custom keychain
security create-keychain -p travis ios-build.keychain
# Make the custom keychain default, so xcodebuild will use it for signing
security default-keychain -s ios-build.keychain
# Unlock the keychain
security unlock-keychain -p travis ios-build.keychain
# Set keychain timeout to 1 hour for long builds
# see http://www.egeek.me/2013/02/23/jenkins-and-xcode-user-interaction-is-not-allowed/
security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain
# Add certificates to keychain and allow codesign to access them
security import ./scripts/certs/XXXDevelop.p12 -k ~/Library/Keychains/ios-build.keychain -P $PASSWORD -T /usr/bin/codesign
security import ./scripts/certs/XXXDistribution.p12 -k ~/Library/Keychains/ios-build.keychain -P $PASSWORD -T /usr/bin/codesign
# Put the provisioning profile in place
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp "./scripts/profile/XXXdevPP.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
cp "./scripts/profile/XXXdisPP.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
答案 5 :(得分:0)
我可以通过语言设置Objective-C,就像这样在" .travis.yml"
language: objective-c