Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute tests from command line via xcodebuild on Jenkins

I'm using the following command to execute the tests:

xcodebuild test -workspace MyApp.xcworkspace -scheme MyScheme -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'

This works fine locally, however when I try this on Jenkins it fails with the following error:

xcodebuild test -workspace MyApp.xcworkspace -scheme MyScheme -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'

xcodebuild: error: Unable to find a destination matching the provided destination specifier: { platform:iOS Simulator, OS:8.1, name:iPhone 6 }

The requested device could not be found because no available devices matched the request.

Available destinations for the "MyScheme" scheme:

Build step 'Execute shell' marked build as failure

Finished: FAILURE

So I launched Xcode GUI on Jenkins to check if the iPhone 6 simulator is present, and it's there. Another interesting thing is when I run the same xcodebuild command without specifying the name and the OS for the destination on my local, I get the list of all available simulators, like so:

Available destinations for the "MyScheme" scheme: { platform:iOS Simulator, id:683233C4-EC2B-48A3-826B-10EF62A875CD, OS:8.1, name:iPad 2 } { platform:iOS Simulator, id:6358A6F5-2FD0-4377-BD32-0A2C3329276D, OS:8.1, name:iPad Air } { platform:iOS Simulator, id:224533ED-94DA-46CC-B1DB-1781A1C80710, OS:8.1, name:iPad Retina } { platform:iOS Simulator, id:D114BC7E-A913-4063-A349-C119BAFC06DA, OS:8.1, name:iPhone 4s } { platform:iOS Simulator, id:7AF6D6F4-C6BC-4A47-B83C-3A4B43ABE0DD, OS:8.1, name:iPhone 5 } { platform:iOS Simulator, id:BE82D607-466A-43E5-863D-6A05F217C117, OS:8.1, name:iPhone 5s } { platform:iOS Simulator, id:0AFCC9AB-7C59-48C7-9BFB-FBF4865B7A63, OS:8.1, name:iPhone 6 Plus } { platform:iOS Simulator, id:D183FF05-3023-4FB5-BEA0-290EA881040A, OS:8.1, name:iPhone 6 } { platform:iOS Simulator, id:26038DBD-791C-421E-99F4-9153CA726A2F, OS:8.1, name:Resizable iPad } { platform:iOS Simulator, id:31B2F0AE-3547-4189-A561-CD2088F6C645, OS:8.1, name:Resizable iPhone }

But when I do the same on the Jenkins, this list is empty.

I'm using Xcode Version 6.1 (6A1052d) on both local and Jenkins, my schemes are properly shared so I can see them in the GUI when I launch it on the Jenkins. I'm not sure if it's relevant, but I'm using workspace cleanup plugin and I remove all derived data before build on Jenkins.

Edit: I discovered that when prepending the destination value with generic/ I get the proper simulator list on the Jenkins, it still complains that I couldn't find the simulator to run on, even though the one I used is on the list:

xcodebuild test -workspace MyApp.xcworkspace -scheme MyScheme -destination 'generic/platform=iOS Simulator,name=iPhone 6,OS=8.1'

xcodebuild: error: Unable to find a destination matching the provided destination specifier: { platform:iOS Simulator, OS:8.1, name:iPhone 6 }

The requested device could not be found because no available devices matched the request.

Available destinations for the "MyScheme" scheme: { platform:iOS Simulator, id:20D0A659-A25A-40E1-9C11-FC6ECA004012, OS:8.1, name:iPad 2 } { platform:iOS Simulator, id:7B5DF104-BE34-415F-8818-3907B6CB9C63, OS:8.1, name:iPad Air } { platform:iOS Simulator, id:2DDF024E-811D-4D93-BD8E-EF34BFC9D8CA, OS:8.1, name:iPad Retina } { platform:iOS Simulator, id:FFE95D35-B9DD-449E-83D0-50777BF5B783, OS:8.1, name:iPhone 4s } { platform:iOS Simulator, id:EF5A0D8A-6A1F-492C-B451-8F3B8B5EC5EE, OS:8.1, name:iPhone 5 } { platform:iOS Simulator, id:A1FCF8DA-BD9F-4ABC-8E0A-4B8547362274, OS:8.1, name:iPhone 5s } { platform:iOS Simulator, id:1B75E350-7FC8-4407-8116-F3674F3AC187, OS:8.1, name:iPhone 6 Plus } { platform:iOS Simulator, id:694CAA87-765D-4FDF-8B27-75E5B537F48E, OS:8.1, name:iPhone 6 } { platform:iOS Simulator, id:FF5588C0-14B5-4303-A2AC-9ACF63B1852C, OS:8.1, name:Resizable iPad } { platform:iOS Simulator, id:E402C9C9-97BA-4909-96B3-3D3C7F6CCC3B, OS:8.1, name:Resizable iPhone }

Build step 'Execute shell' marked build as failure

Finished: FAILURE

like image 597
lawicko Avatar asked Nov 11 '14 11:11

lawicko


People also ask

How do I build and run a unit test in xcodebuild?

xcodebuild provides several options for running unit tests. To build and run unit tests from the command line, execute the following command in Terminal: To build unit tests without running them from the command line, execute the following command in Terminal:

Does xcodebuild run tests sequentially or sequentially?

Note: xcodebuild runs your tests sequentially. For instance In Listing 17, xcodebuild will first test iOS in the Simulator before executing it on the iPod touch. How do I implement the Build For Testing and Test Without Building features from the command line?

How do I run a test in Xcode?

The test action is what you use to run tests from a certain scheme in an Xcode project: If your app uses a workspace, perhaps because of CocoaPods, you'll need to pass the -workspace option instead of -project: -workspace MyAwesomeApp.xcworkspace. You can run instruments -s devices to see a list of know devices to use as the -destination option.

What is xcodebuild command-line tool?

The xcodebuild command-line tool drives tests just like the Xcode IDE. Run xcodebuild with the action test and specify different destinations with the -destination argument.


1 Answers

Turns out Jenkins was using a user that didn't have enough permissions. I figured it out when I created another job and tried to sign the archive. By default, Jenkins uses 'jenkins' user to do stuff, but if you ssh or screen share to your build server with other user, than you are screwed. I decided to remove my Jenkins daemon and instead use JenkinsApp.

like image 156
lawicko Avatar answered Sep 27 '22 23:09

lawicko