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?
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
Related
When I run my UITest from XCode they all pass correctly but when I use xcodebuild - some of them fail with error:
Failure: UITestBase.swift:63: Failed to get matching snapshot: Lost connection to the application (pid 43193).
Currently I'm using 11.6, it did work fine on Xcode 10.x, xcodebuild points to correct Xcode where tests pass from IDE
xcodebuild command that I'm using:
xcodebuild clean test -workspace APP.xcworkspace -scheme APPUITests -configuration Release OTHER_SWIFT_FLAGS="-DCOCOAPODS -DAPPProdTarget" -destination "platform=iOS Simulator,name=iPhone 11,OS=13.6"
Started learning how to integrate continuous integration (CI) using Travis platform for a personal project "Building a simple framework for iOS Development on Xcode". And, after a successful run creating a .travis.yml file with a set of configurations somehow I got caught up with a bunch of errors that I'm not quite familiar with.
Here's a snapshot of the travis.yml file
language: swift
os: osx
osx_image: xcode10.2
script:
- set -o pipefail && xcodebuild -project SWToaster.xcodeproj -scheme SWToaster -configuration Debug -destination 'platform=iOS Simulator,OS=12.0,name=iPhone XR' ONLY_ACTIVE_ARCH=YES
- set -o pipefail && xcodebuild test-without-building -enableCodeCoverage YES -scheme SWToasterTests -destination 'platform=iOS Simulator,OS=12.0,name=iPhone XR' ONLY_ACTIVE_ARCH=YES
And here is a snapshot of error messages:
Anyone sort of help will be appreciated
Resolved the issue by making sure the following requirements are met
Listed supported iOS Simulator SDK on Travis
Checked supported Xcode version on Travis
Then updated a .travis.yml config file as follows.
language: swift
os: osx
osx_image: xcode10.2
env:
matrix:
- TEST_SDK=iphonesimulator12.2 OS=12.2 NAME='iPhone 7'
script:
- set -o pipefail && xcodebuild -version
- set -o pipefail && xcodebuild -showsdks
- set -o pipefail && xcodebuild -project SWToaster.xcodeproj -scheme SWToaster -configuration Debug -destination "platform=iOS Simulator,OS=12.0,name=iPhone XR" ONLY_ACTIVE_ARCH=YES
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -project SWToaster.xcodeproj -scheme SWToaster -sdk $TEST_SDK -destination "platform=iOS Simulator,OS=$OS,name=$NAME" ONLY_ACTIVE_ARCH=YES
I try to compile my app for UITesting and in a second time run the UITest on iOS simulator. But I need to do this in 2 times.
In one time I use :
xcodebuild -workspace './MyApp.xcworkspace' -scheme 'MyScheme' -derivedDataPath '~/Documents/derived_data/' -destination 'platform=iOS Simulator,id=6EE927C0-FC0E-4235-8915-3BFF1F128B76,OS=9.2' build test | xcpretty
Any Idea how to copy and launch MyApp.app, MyAppUITests-Runner.app in the simulator?
Thanks.
Alak
Edit:
Anyway to launch something like :
xcrun simctl launch "UITest"
and get xcactivitylog from this ?
try this:
xcodebuild -workspace App.xcworkspace -scheme "App-Scheme" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' test
it will compile the App and run the UI Test in the simulator.
i want to get my project's code coverage (which is managed by cocoapods), i run the following cmd :
xcodebuild -scheme KVODemo -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 6' -enableCodeCoverage YES -workspace KVODemo.xcworkspace test
but i can not find the Coverage.profdata file (for normal project which is not managed by cocoapods is under the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata)
i just want to know how to get the code coverage for cocoa pods project.
ok , after a detail look at the cmd xcodebuild , i noticed something.
here is some info in the "man xcodebuild":
xcodebuild -showBuildSettings
[-project name.xcodeproj |
[-workspace name.xcworkspace -scheme schemename]]
the $PROJECT_TEMP_ROOT i mentioned in my question is the result of
xcodebuild -showBuildSettings |grep PROJECT_TEMP_ROOT
and this should the same as the xcodebuild -showBuildSettings -project xxx.xcodeproj
because my project is managed by cocoa pods, so i should get the $PROJECT_TEMP_ROOT in this way :
xcodebuild -showBuildSettings -workspace xxx.xcworkspace -scheme xxx
and finally , find the Coverage.profdata in the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata
I'm having some trouble with my cocoapods running Travis CI. Everything seems to install correctly, but the xcodebuild script fails
$ set -o pipefail && xcodebuild test -workspace Example/UIKitPlus.xcworkspace -scheme UIKitPlus-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c
xcodebuild: error: Failed to build workspace UIKitPlus with scheme UIKitPlus-Example.
Reason: The run destination iPad 2 is not valid for Testing the scheme 'UIKitPlus-Example'.
The command "set -o pipefail && xcodebuild test -workspace Example/UIKitPlus.xcworkspace -scheme UIKitPlus-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c" exited with 70.
https://travis-ci.org/JamieREvans/UIKitPlus/builds/54649639
I'm not sure why this is failing, because I can run my tests on the iPad 2 simulator, using that scheme, without any issues.
Is this a Travis issue or is my Travis script wrong?
I've managed to get it build by adding a destination to the xcodebuild command line, e.g. -destination "platform=iOS Simulator,name=iPhone 6"