Search code examples
iostravis-cixcodebuild

TravisCI.yml for iOS, destination not correct


I have a simple iOS app that I want to use in Travis CI. I use a matrix with TEST_SDK and TEST_DESTINATION. However, the destination doesn't seem to work properly.

This is my .travis.yml:

language: objective-c
osx_image: xcode9.2
cache: cocoapods
before_install:
  - pod repo update
  - pod update
env:
  matrix:
    - TEST_SDK=iphonesimulator11.1 TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.1"
    - TEST_SDK=iphonesimulator11.2 TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.2"
script:
  - xcodebuild test -workspace iOSApp.xcworkspace -scheme iOSApp -sdk $TEST_SDK -destination $TEST_DESTINATION | xcpretty

The problem is that when I run the script locally, I get this output: xcodebuild: error: Unknown build action '7'.

When I run xcodebuild test -workspace iOS.xcworkspace -scheme iOS -sdk $TEST_SDK -destination platform="iOS Simulator",name="iPhone 7 Plus",OS=11.2 | xcpretty it works fine.

Therefore, I replaced the .travis.yml with : - TEST_SDK=iphonesimulator11.2 TEST_DESTINATION=platform="iOS Simulator",name="iPhone 7 Plus",OS=11.2 for example. However, this errors again with xcodebuild: error: Unknown build action '7'.

How can I get this to work correctly?


Solution

  • I got it working with this:

    export TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.1"

    and for the build use TEST_DESTINATION in double quotes like

    xcodebuild test -workspace iOSApp.xcworkspace -scheme iOSApp -sdk $TEST_SDK -destination "$TEST_DESTINATION" | xcpretty