21

Travis CI fails to build my app because the Xcode project is set up to require code signing and Travis doesn't have my certificates. I could fix this by disabling code signing, but then sandboxing and entitlements won't work. I know when building from the command line ordinarily, you can pass CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO to xcodebuild to disable the code signing, but how do you do this in Travis CI?

Here's my .travis.yml:

language: objective-c
xcode_workspace: "Mac Linux USB Loader.xcworkspace"
xcode_scheme: "Mac Linux USB Loader"

And here's the error (I've code out many previous lines referring to Cocoapods, as they're not relevant:

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

6 Answers 6

17

Did you try to add this on you travis.yml:

language: objective-c

script:
  - xcodebuild [DEFAULT_OPTIONS] CODE_SIGNING_REQUIRED=NO

Or import a development (and distribution if you are going to use on your build) cert/key to the keychain and copy your team provisioning profile, to make the code signing work. Like this:

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/
0
11

Please find my .travis.yml file below, which fixes this error message and others, when using an Xcode 7 project + Swift + iOS 9 + the continuous integration tool available on travis-ci.org:

# 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

Sources:

0
3

If you don't need to build for iphoneos, e.g. if you just want to know if the project builds or your unit tests pass. You can specify the iphonesimulator sdk. By doing this, xctool will not sign the code.

script: xctool -sdk iphonesimulator -workspace {WORKSPACE}.xcworkspace -scheme {SCHEME} build test
1
  • Thanks, but I'm not using iOS.
    – SevenBits
    Commented Feb 20, 2016 at 18:03
2
language: objective-c
script: xctool -project [xcodeproject] -scheme [scheme] build  CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

You can refer to this .travis.yml

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/

my dir tree

link to details

0

I can passing just setting Objective-C with language , like this in ".travis.yml"

language: objective-c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.