2015-09-25 30 views
3

我是Travis CI的新手,並且已經針對單個項目和環境設置了基本構建和測試。 .travis.yml看起來像這樣:在.travis.yml中定位多個iOS版本

language: objective-c 
osx_image: xcode7 
xcode_project: ./[project]/[project].xcodeproj 
xcode_scheme: [project] 
xcode_sdk: iphonesimulator9.0 

這很好,但我也想測試。其他iOS模擬器版本(例如8.4)。

我知道我可以在我的.travis.yml使用xctool從腳本部分像這樣,這工作太細:

script:  
    xctool -project ./[project]/[project].xcodeproj -scheme [project] -sdk iphonesimulator9.0 build test 

然而,我不能看到如何運行任何其他iOS版本。 Objective-C docs for Travis CI表示大量模擬器iOS版本可用於osx_image: xcode7,但$ xcodebuild -version -sdk在CI機器上運行時,它僅顯示iOS 9可用。

我在這裏錯過了什麼能夠測試其他iOS版本對XCode安裝?

回答

6

訣竅尋找可用的模擬器運行:

$ xcrun instruments -s devices 

,你會看到屬性已安裝的設備:

Known Devices: 
Travis’s Mac (129) [00000000-0000-1000-8000-005056A6DCD8] 
iPad 2 (8.1) [22540C0C-46B4-4FF8-9B74-81CA975] 
iPad 2 (8.2) [03655E8B-725B-4C03-A505-8EEA0BE5A966] 
iPad 2 (8.3) [BBC2737B-BE8D-403B-804F-5A36560AD47B] 

etc... 

於是我建有包膜矩陣瓦爾(reference )併爲我想測試的模擬器/操作系統版本組合定義了UDID。腳本部分爲每個定義的唯一環境變量/值執行一次。我.travis.yml文件看起來像這樣:

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' 

此版本的例子可以看出here