Why Travis cannot run my tests? - ios

I used Xcode 9.0 and iPhone 7 in my development.
In my .travis.yml I added:
language: swift
osx_image: xcode9
script:
- xcodebuild clean test -project BullsEye.xcodeproj -scheme BullsEye
-destination "platform=iOS Simulator,name=iPhone 7,OS=11" CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet
but when I run it in travis I get this:
The command "xcodebuild clean test -project BullsEye.xcodeproj -scheme BullsEye
-destination "platform=iOS Simulator,name=iPhone 7,OS=11" CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet" exited with 70.
or with 66.
I made my scheme Shared in Xcode.
What is the problem and how can I fix it?
In logs I'm also getting:
Ineligible destinations for the "BullsEye" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
and
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:11, name:iPhone 7 }
The requested device could not be found because no available devices matched the request.

Looking at your latest build log, the following error message
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:11, name:iPhone 7 }
seems to indicate that you aren't using a valid -destination value.
Indeed, I believe that 11 isn't an accepted value for OS. Can you try with 11.0 instead? i.e. -destination "platform=iOS Simulator,name=iPhone 7,OS=11.0"
I've also submitted a PR here.

Related

iOS UITests pass on Xcode but fails with xcodebuild

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"

Travis: xcodebuild: error: Unable to find a destination matching the provided destination specifier

I'm trying to implement continuous integration using travis-ci.org.
Here is my current .travis.yml config:
language: swift
osx_image: xcode8.3.3
xcode_project: AutomatediOSBuild.xcodeproj #3
xcode_scheme: Debug
#xcode_sdk: iphonesimulator10.0
script:
- xcodebuild -scheme AutomatediOSBuild -project AutomatediOSBuild.xcodeproj -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1' build test
But I'm getting the following error on travis:
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:10.3.1, name:iPhone 6s }
The requested device could not be found because no available devices matched the request.
The command "xcodebuild -scheme myProject -project myProject.xcodeproj -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1' build test" exited with 70.
If I run in the command line:
xcodebuild -scheme myProject -project myProject.xcodeproj -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1' build test
I have no errors. Any of you knows why I'm getting this errors? or if there is any work around this error?
I'll really appreciate your help.
The Travis environment for xcodebuild is likely different from yours, namely you have locally the correct Simulator corresponding to your -destination option, but your Travis-ci container does not.
The Job logs should give you a bit more info, like :
The requested device could not be found because no available devices matched the request.
585
586 Available destinations for the "stackoverflow" scheme:
587 { platform:iOS Simulator, id:5B...65, OS:13.2.2, name:iPad (7th generation) }
588 { platform:iOS Simulator, id:1A...DA, OS:13.2.2, name:iPhone 8 }
Travis lists the available simulators for the selected osx_image on the documentation, and this mokacoding post gives good explanations.
I also found out that you must give the exact OS version, e.g. in my example above:
xcode_destination: platform=iOS Simulator,name=iPhone 8,OS=13.2 # fails
xcode_destination: platform=iOS Simulator,name=iPhone 8,OS=13.2.2 # works
I had a similar issue with a target I created with Xcode 9.4 and was trying to run on travis with Xcode 9.3. The tvOS deployment target in Build Settings was 11.4. I changed it back to 11.1 and travis started working:
--- a/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj
+++ b/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj
## -974,7 +974,7 ##
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
- TVOS_DEPLOYMENT_TARGET = 11.4;
+ TVOS_DEPLOYMENT_TARGET = 11.1;
};
React Native Docs:
https://reactnative.dev/docs/running-on-simulator-ios
1. View Devices:
xcrun simctl list devices
2. Look for the id for your device (The issue is that it doesn't match):
6FC6D243-9AD0-4CA5-BCD0-3AE32D536A27
3. Run iOS Simulator with new ID
npx react-native run-ios --udid=6FC6D243-9AD0-4CA5-BCD0-3AE32D536A27

Travis fails to launch simulator on xcode8

I am having issue with Travis building and testing a new ios app I am being developing.
language: objective-c
os: osx
osx_image: xcode8
before_install:
- pod repo update > /dev/null
- pod update
- gem install xcpretty
script:
- xcodebuild clean test -workspace project.xcworkspace -scheme project -destination "platform=iOS Simulator,name=iPhone 6" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
This is my .travis.yml and everytime I run it Travis get me this error:
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:latest, name:iPhone 6 }
Ineligible destinations for the "project" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
The command "xcodebuild clean test -workspace project.xcworkspace -scheme project -destination "platform=iOS Simulator,name=iPhone 6" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO" exited with 70.
I also tried putting the id of the simulator with the same result.
Please note that the same xcodebuild command is building without any issue in my workarea.
Make sure your iOS Deployment Target value in Build Settings is set to a value that your osx image on Travis supports.
If your app is brand new, the iOS Deployment Target may be set to 10.1. The newest image Travis is providing comes with Xcode 8.0, which does not have iOS 10.1 simulators in them yet.
Update
Travis-CI is supporting xcode8.1 and iOS 10.1

Compile for ios simulator and run UITest in 2 times

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.

xctool: how can I choose the iphone6 simulator?

I am running test using xctool, and I would like to be able to choose the simulator. I am using the following line:
xctool -workspace MyProject.xcworkspace -scheme MyProject test -reporter junit:test-results.xml -reporter teamcity -sdk iphonesimulator
However, the simulator that is open is the iPhone 4s simulator. Does anybody knows how to select the iPhone 6 simulator.
Using the -destination flag you can select a specific device to be run for your simulator :
-destination platform='iOS Simulator',OS=8.4,name='iPhone 6'
You should try the following command (replacing MyProject by the name of your project):
xctool -workspace MyProject.xcworkspace -scheme MyProject test -reporter junit:test-results.xml -reporter teamcity -sdk iphonesimulator -destination platform='iOS Simulator',OS=8.4,name='iPhone 6'

Resources