I'm new to Travis CI and have set up a basic build and test against a single project and environment. The .travis.yml
looks like this:
language: objective-c
osx_image: xcode7
xcode_project: ./[project]/[project].xcodeproj
xcode_scheme: [project]
xcode_sdk: iphonesimulator9.0
That works great but I also want to test against. other iOS simulator versions (e.g. 8.4).
I realize I can use xctool
from a script section like so in my .travis.yml
and this works fine too:
script:
xctool -project ./[project]/[project].xcodeproj -scheme [project] -sdk iphonesimulator9.0 build test
Yet, I can't see how to run any other iOS version. The Objective-C docs for Travis CI say a host of simulator iOS versions is available for osx_image: xcode7
, but when $ xcodebuild -version -sdk
is run on the CI machine it only shows iOS 9 being available.
What am I missing here to be able to test other iOS versions against an XCode installation?
The trick to finding the available simulators is running:
$ xcrun instruments -s devices
and you will see the properties for the installed devices:
Known Devices:
Travis’s Mac (129) [00000000-0000-1000-8000-005056A6DCD8]
iPad 2 (8.1) [22540C0C-46B4-4FF8-9B74-6321081CA975]
iPad 2 (8.2) [03655E8B-725B-4C03-A505-8EEA0BE5A966]
iPad 2 (8.3) [BBC2737B-BE8D-403B-804F-5A36560AD47B]
etc...
So then I built a matrix with env vars (reference) and defined the UDIDs for the simulator/OS version combos I wanted to test against. The script section is executed once for each unique environment variable/value defined. My .travis.yml file looks like this:
language: objective-c
osx_image: xcode7
## Create a build matrix to execute against multiple simulators/iOS versions
## The UDID will be used below to determin the destination to test against
## where the script section will be run once for each definition
## ISO_DEVICE is not used in the script but is useful to know what OS version is tested and will show up in Travis to make it easer to read
env:
- UDID="FCBB11B4-D7C8-4085-9067-2CEDA2BFC895", IOS_DEVICE="iPhone 6 Plus (9.0)"
# - UDID="363ADE93-270B-4C2E-9286-C3C1FABE3CDD", IOS_DEVICE="iPhone 4s (8.1)"
- UDID="BE52C183-B4AF-408D-AE90-278FA4AD89EC", IOS_DEVICE="iPhone 5 (8.3)"
- UDID="FCBB11B4-D7C8-4085-9067-2CEDA2BFC895", IOS_DEVICE="iPhone 6 Plus (9.0)"
- UDID="BEEA639C-46EB-48EF-8377-A22B781A7EE2", IOS_DEVICE="iPad Air 2 (8.4)"
### Setting up the simulator for auto-test and running the build via the xcodebuild tool:
script:
# The xcrun with devices here will print out a list of available devices you can snag the UDIDs for
- xcrun instruments -s devices
- echo staring build and test...
- open -a "simulator" --args -CurrentDeviceUDID $UDID
- xcodebuild test -project ./MovingHelper/MovingHelper.xcodeproj -scheme MovingHelper -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,id=$UDID"
- osascript -e 'tell app "Simulator" to quit'
An example of this build can be seen here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With