Travis fails to launch simulator on xcode8 - ios

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

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"

Why Travis cannot run my tests?

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.

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

xcode >= 8 cannot compile my objective-c library

I'm trying to compile my objective-c library with Xcode (or xcodebuild) but it seems that Xcode is only taking the last two numbers of my "Base SDK" (10.1 in my case) build setting :
xcodebuild -scheme mylib -workspace mylib_objc.xcworkspace -sdk "iphonesimulator10.1" build
output error :
/bin/sh -c /Users/user/Library/Developer/Xcode/DerivedData/mylib_objc-dcainaehwbdhdeeyoykilqflodnx/Build/Intermediates/mylib.build/Debug-iphonesimulator/mylib.build/Script-AEDFEE9B1B25C0FD00756827.sh
XCode has selected SDK: iphonesimulator with version: 0.1 (although back-targetting: 7.0)
...therefore, OTHER_SDK_TO_BUILD = iphoneos0.1
RECURSION: I am the root ... recursing all missing build targets NOW...
RECURSION: ...about to invoke: xcodebuild -configuration "Debug" -project "mylib.xcodeproj" -target "mylib" -sdk "iphoneos0.1" build RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR="/Users/user/Library/Developer/Xcode/DerivedData/mylib_objc-dcainaehwbdhdeeyoykilqflodnx/Build/Products" BUILD_ROOT="/Users/user/Library/Developer/Xcode/DerivedData/mylib_objc-dcainaehwbdhdeeyoykilqflodnx/Build/Products" SYMROOT="/Users/user/Library/Developer/Xcode/DerivedData/mylib_objc-dcainaehwbdhdeeyoykilqflodnx/Build/Products"
xcodebuild: error: SDK "iphoneos0.1" cannot be located.
Command /bin/sh failed with exit code 64
I then tried with a coworker who has xCode 8 (and therefore base sdk=10.0), the error was xcodebuild: error: SDK "iphoneos0.0" cannot be located.
Any idea how to force the compilation ?
You are buiding your library with an old build script. Checkout my answer here
Build fat static library (device + simulator) using Xcode and SDK 4+
and update your script then you should be fine.

Xcode command line test execution issues

I'm in a strange situation where I can get xctool to run my test but I cant figure out the equivalent command line to get xcodebuild and/or fastlane scan to run my tests.
I have an iPad only application with a single scheme and two targets (otto and ottoTests)
Working XCTool Commandline
xctool -scheme otto \
-sdk iphonesimulator \
CODE_SIGN_IDENTITY=""\
CODE_SIGNING_REQUIRED=NO \
-reporter pretty\
-reporter junit:./test-reports/otto.xml\
build test
Xcodebuild - fail
xcodebuild -sdk iphonesimulator \
-scheme otto \
test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
I get this error that
A build only device cannot be used to run this target
So I'm kind of at a loss here exactly what is different between xcodebuild and whatever xctool is running.
AFAICS, you are missing the -destination argument in the xcodebuild command. Refer to this tutorial for sample code.
You're missing the -destination argument.
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme MyWatchKitApp
-destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' \
build
To list all valid values for destination run instruments -s devices.
e.g.
$ instruments -s devices
Known Devices:
Apple TV 1080p (10.0) [A0DA01A6-CAC6-4562-93B9-749920DCEFAA] (Simulator)
Apple Watch - 38mm (2.0) [9D6C53FB-0D69-4A0A-83CB-CBB55EE63AA6] (Simulator)
Apple Watch - 38mm (2.0) [BF24D5AC-8DB5-4D18-A6FD-B92292084B8A] (Simulator)
Apple Watch - 42mm (2.0) [286C7921-3689-4832-B0C7-52B412C0C2F5] (Simulator)
Apple Watch - 42mm (2.0) [16144840-5E1B-4934-A82D-E2A49FF79392] (Simulator)
iPad 2 (8.1) [8D0AD02D-C78F-4D59-BBA5-1E7AB452A852] (Simulator)
iPad 2 (9.3) [16D6261C-8FBD-4865-8E6A-840800A96C4A] (Simulator)
iPad Air (10.0) [374DB3F8-65CB-4AD1-919F-808C0C2FCEE1] (Simulator)
iPad Air (8.1) [E83D1680-C5EE-4E86-B847-16FF8C0B7F98] (Simulator)
iPad Air (9.3) [82F4AEC6-A778-44D9-88DB-A95126904E1A] (Simulator)
iPad Air 2 (10.0) [E68ED558-4E83-46A3-892C-93786CF947FC] (Simulator)
iPad Air 2 (9.3) [F1521496-CA53-41CC-A1DA-F605B961B3E5] (Simulator)
iPad Pro (12.9 inch) (10.0) [D87A6656-DEB4-41BB-B45A-2A3D85BFED8A] (Simulator)
iPad Pro (9.3) [968E6D5E-6881-4DB2-B274-2BF0DC0FDE24] (Simulator)
iPad Pro (9.7 inch) (10.0) [55B31895-0A68-4060-8441-A845F63FA4FB] (Simulator)
iPad Retina (10.0) [7725C135-7211-43E2-8BB4-9455C3820DB4] (Simulator)
iPad Retina (8.1) [E4825B7A-5A53-49AF-AD27-62711CA97B66] (Simulator)
iPad Retina (9.3) [F0523C54-9F37-4209-844C-9CA4A174791A] (Simulator)
Unfortunately you can't just copy and paste these lines. You'll need to use your impressive human pattern matching skills to fill in the proper values for the platform=, name=, and OS= parameters to -destination.
Source http://www.mokacoding.com/blog/xcodebuild-destination-options/

Resources