The Long Weekend Website

Written by Mark

Xcode4: Running Application Tests From The Command Line in iOS

By Mark on April 17th, 2011 in Technobabble
Tags: , , ,

UPDATE Nov 11 2012: If you are using Xcode 4.5, you will also want to read this post – this process has changed a bit!

While researching the “is GHUnit still relevant vis-a-vis Xcode 4” article, I discovered this Carbon Five post by Jonah: Running Xcode 4 unit tests from the command line.

In short, I found a way to run iOS application unit tests from the command line; this article describes that process.

Part of the research is about automation – how well GHUnit and/or OCUnit test suites can be automated.

In my book, command line = automation. Last summer I installed Hudson CI on Paul’s Mac Mini and started automated builds. Why not add unit tests to the mix?

Jonah’s post explains how to make a unit test bundle testable from the command line. Unfortunately, and he notes it as well, it only works for logic tests (e.g. no application tests). His approach uses schemes in Xcode 4.

Jonah’s command:

xcodebuild -workspace workspaceName.xcworkspace -scheme logicTestSchemeName -sdk iphonesimulator4.3 -configuration Debug clean build

I’m still not sure I fully understand schemes/workspaces yet, as they are new to Xcode 4, but this is definitely one case where good ol’ targets appear to work better.

By using the target paradigm, we can build the bundle without creating a new scheme. Instead, just use the test bundle’s name as your build target:

xcodebuild -target unitTestBundleTargetName -configuration Debug -sdk iphonesimulator4.3 clean build

This improved upon the first half of his post – removing the need to create a separate scheme. His post ends with a challenge for application tests:

In case it is of any help to other developers struggling with the difference between command line and Xcode builds.

The “Run Script” build phase of a unit test build target just runs… (edit: references some scripts, omitted for brevity)

Hopefully it will prove possible to use these scripts to match the behavior seen when running tests from within Xcode to automatically run application tests.

So, I included an application test in my unit test bundle, and this was the output:

/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests:94: warning: Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set).

Isn’t it supported? We’ve seen it working in Xcode 4. Maybe it really is supported, but Apple hasn’t updated the testing script because they were so busy just trying to get Xcode 4 in a semi-releasable state (highly likely). Or, it hasn’t been “officially” said to work; e.g. they don’t want to support it yet, so they’re not letting us do it.

After snaking through all the script calls, I found the culprit.

Change line 95 of /Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests from

Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."

to these 2 lines:

export OTHER_TEST_FLAGS="-RegisterForSystemEvents"
RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"

The first line of code seems to make event handling work with Springboard (see comments below). The second line of code I stole from /Developer/Tools/RunPlatformUnitTests. Seems like it’s the default behavior for other platforms, just not the simulator SDK.

EDIT: Running Xcode 4.3? You still need to edit this file in this fashion, but do so according to Roger’s guidelines in the comments section below – you need to change the build phase script & make a copy of your script.

After inserting those lines, your tests should run (I’ve included a sample project with the set up to show the code, it is the “navigation based app” template using Core Data).

Also, it’s important to note that the Simulator will not run 2 instances. You’ll need to shut the Simulator if you have it open.

DISCLAIMER:Yes, I’m asking you to change your /Developer directory. You probably should back everything up, blah blah blah, and I don’t want to be blamed if you have to reinstall Xcode 4.

Also, I originally had Core Data as part of the project, but I was getting an NSCocoaErrorDomain error from my application on the console. After I removed Core Data from the project, the problem went away.

Deniz Demir helped me out there – a little Google brought up his post from late March, where he explained his troubles with Core Data and unit testing. Applying his fix inre: the documents directory makes my code work. Glad to see everyone work at the coal face of the problem!

Best of luck!



  1. 62 Responses to “Xcode4: Running Application Tests From The Command Line in iOS”

  2. Mark Wotton says:

    I’m having some trouble setting this up, even with your sample app.

    This is with Xcode 4.0: after running

    xcodebuild -target CmdlineAppTestingTests -configuration Debug -sdk iphonesimulator4.3 clean build

    Run unit tests for architecture ‘i386′ (GC OFF)
    /Developer/Tools/RunPlatformUnitTests.include:419: note: Running tests for architecture ‘i386′ (GC OFF)
    2011-04-21 16:29:06.533 otest[18816:903] The test bundle at /fast/projects/foo2/CmdlineAppTesting/build/Debug-iphonesimulator/CmdlineAppTestingTests.octest could not be loaded because a link error occurred. It is likely that dyld cannot locate a framework framework or library that the the test bundle was linked against, possibly because the framework or library had an incorrect install path at link time.
    /Developer/Tools/RunPlatformUnitTests.include:448: error: Failed tests for architecture ‘i386′ (GC OFF)

    Apr 21, 2011 | Reply

  3. Mark says:

    Mark,

    Hrm. Not sure what that issue is. I am using Xcode 4.0.1, but I highly doubt that’s the difference.

    A dynamic linking issue… I guess let me have a look at it. Did you make any modifications to the sample project?

    Apr 26, 2011 | Reply

  4. Shaps says:

    If I’m honest I was having trouble understanding how Unit Test are written. Like the kinds of tests I should be writing, how specific I should be. I was also unsure how to implement the Application Tests.

    I finally came across your article and now have a much better understand of these things, especially after going through your sample project.

    I really just wanted to say thank you for your posts, but mostly for your hilarious comments. For the record, I think its because Core Data likes Limp Bizkit too! Hahaha!

    Apr 26, 2011 | Reply

  5. Matthew Johnson says:

    I made this change to my RunPlatformUnitTests file. The application unit tests work fine when run from Xcode, but they don’t work from the command line with xcodebuild. This is the command I’m using:

    xcodebuild -target TestingTestsTests -configuration Debug -sdk iphonesimulator4.3 clean build

    It hangs every time I try to run my application unit tests if I have iOS Simulator running before I run the tests. If I don’t have iOS Simulator running before I run the tests then I get the following error:

    “Terminating since there is no system event server.
    (Run the EventPump or pass the argument “-RegisterForSystemEvents” if you want to run without SpringBoard.”

    My logic tests work fine if I remove the TEST_HOST build setting, but obviously that doesn’t help with application tests.

    Any tips on what might be causing the issues I’m having? I’m eager to get application unit tests running from the command line.

    Thanks!

    May 5, 2011 | Reply

  6. Mark says:

    I should have included this in the post. The simulator NEEDS to be NOT running for all this to work.

    May 8, 2011 | Reply

  7. Matthew Johnson says:

    To clarify, I did have the simulator closed prior to running this. Any further ideas?

    May 13, 2011 | Reply

  8. Mark says:

    Matthew, I got it – for some reason when I first wrote this, OTHER_TEST_FLAGS must have been getting set explicitly. Not sure what changed (other than I upgraded to 4.0.2).

    Now, I’ve added a second line into the script that sets it, so the tests should run now.

    May 17, 2011 | Reply

  9. Mark says:

    @Mark Wotton – The only thing I can see from what you’ve pasted is that your script seems to be running in the wrong place. When I run it, I get:

    /Developer/Tools/RunPlatformUnitTests.include:273: note: Running tests for architecture ‘i386′ (GC OFF)

    That’s line 273, which is part of the function “RunApplicationTests” or something ( check it ). Your pasted comment seems to reference line 419, which is in the “RunBundleTests” or whatever function. I haven’t gone so far as yet to trace the scripting calls and see WHY that’s happening, but I reckon that’s the problem.

    May 17, 2011 | Reply

  10. Dave says:

    Brilliant, just what I needed, thanks!

    May 28, 2011 | Reply

  11. Mandy says:

    Hi, I managed to get the unit tests running without your hack of RunPlatformUnitTests. I just changed the Target Build Settings to remove the Test Host entry i.e. remove $(BUNDLE_LOADER). Not sure of the impact of this but it worked!

    Nov 17, 2011 | Reply

  12. Geoff says:

    Hi Mandy, if you remove that test host entry then you can no longer run Application Tests, only Logic Tests :)

    Nov 17, 2011 | Reply

  13. Mark says:

    Mandy & Geoff, thanks for the updated comments — someone said this the other day on StackOverflow — specifically that the hack is no longer necessary.

    I need to set this up from scratch again on Xcode 4.2 and see if it is indeed the case. Watch for updates!

    Nov 17, 2011 | Reply

  14. Igor says:

    How does this work for a device? With what arguments do you run the RunPlatformUnitTests?

    Dec 17, 2011 | Reply

  15. Dustin says:

    Great post. Regarding the recent comments, I just went through this on a brand new project with Xcode 4.2 and the hack was still necessary. As mentioned above, you can change the build settings to accommodate logic tests but any application tests expecting NSApplication inside the simulator need this setup. I’ve tried to capture all the latest steps and how to detect if you’re inside a test for Core Data access (if necessary) from a Jenkins CI perspective if anyone needs it here:
    http://lifeandcode.net/2011/12/automated-ios-jenkins-builds-with-application-tests-and-core-data/

    Dec 19, 2011 | Reply

  16. Scott Muc says:

    Thanks so much for this post! This helped us get Kiwi tests running form the CLI. It’s a shame that it’s such a kludge to get this working.

    Again, thanks for posting this. I believe this is the only post on the Internet that actually led us in the right direction.

    Jan 6, 2012 | Reply

  17. Mark says:

    Scott,

    Thanks. It feels good, I set out to “Solve A Problem”, and it worked :) .

    Jan 8, 2012 | Reply

  18. Alec says:

    This worked for me. Thanks so much… great post.

    Feb 22, 2012 | Reply

  19. Craig says:

    This is great, it worked for me. The only problem is that the keychain doesn’t seem to work when running from the CLI. Any suggestions?

    Feb 23, 2012 | Reply

  20. Mark says:

    Craig:

    “security” is the command-line tool for dealing with the keychain. I assume you have certificate things you want to sort out.

    Check out this SO post:

    http://stackoverflow.com/questions/5525436/xcode-could-not-find-a-valid-private-certificate-valid-key-pair-for-this-profile

    Feb 23, 2012 | Reply

  21. Dragos says:

    Thanks for all the tips so far. I have the same problems as Craig, meaning all application tests that are relying on the local keychain (I assume that’s the device or the simulator’s keychain) will fail. I’m not referring to certificate things, but rather saving passwords and stuff on the device. Is there anything that can be done to fix those errors?

    Mar 3, 2012 | Reply

  22. Mark says:

    Dragos,

    While I haven’t tested it, pretty much everything in the Keychain can be imported/exported with the app (and thus likely via the command line). Accordingly, I don’t imagine it’d be too difficult to get the passwords you want saved in the keychain on one machine, export them with some password, then use the command line to import that file on your CI build machine.

    Good question though — I will need to do this in the next 1-2 weeks, so if I find something good I’ll put up a blog post on it.

    Mar 5, 2012 | Reply

  23. Roger Moffatt says:

    This was a huge help and I’ve been using a modified RunPlatformUnitTests for a while with great success. BUT Xcode4.3 is now out and seems to break this because the /Developer folder has now been placed inside the readonly Xcode.app bundle which seems to defeat editing of the file. Have you any thoughts on how to run application unit tests in the simulator on Xcode 4.3?

    Mar 6, 2012 | Reply

  24. Mark says:

    Roger,

    I haven’t used the new Xcode version yet. That said, the Xcode.app bundle is just a folder; if you have admin access on the machine you can’t make it not read only?

    Will have a look when I upgrade.

    Mar 6, 2012 | Reply

  25. Roger Moffatt says:

    Hi Mark

    The solution appears to be to NOT edit the version in the .app bundle, but to change the build phase that launches the script to point to a local (modified) copy instead. Obvious when you think about it, but I was scratching my head for a while!

    On a related matter, have you any idea how to force the simulator to launch in retina mode? I can’t use the hardware menu as I’m doing this on a CI server but can’t seem to persuade xcodebuild to trigger the retina simulator rather than the default one?

    Thanks again for the great tip!

    Mar 6, 2012 | Reply

  26. Mark says:

    Roger — How obvious :) Thanks for the tip — I will edit the post above to point to this.

    Mar 7, 2012 | Reply

  27. Peter says:

    I’m having trouble with this still on Xcode 4.3. Going through all the various options I’ve now settled on copying the RunUnitTests and RunPlatformUnitTests scripts, editing them and running my edited versions, as suggested.

    My problem comes when it tries to launch the simulator:

    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:339: error: Test host ‘/Users/pjh/hudson/workspace/iOS_testing/iDevice/build/Debug-iphonesimulator/Reader.app/Reader’ exited abnormally with code 139 (it may have crashed).

    Has anyone else had and overcome this issue?

    It’s about time apple sorted this mess out really!

    Mar 29, 2012 | Reply

  28. Will says:

    Peter – I had the same problem as you. I solved it by editing the script further as per the instructions found here: http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html

    Apr 3, 2012 | Reply

  29. JJ says:

    it used to work. But, after updating to 10.7.4(Lion), I got the error. /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:339: error
    I don’t know the solution yet….

    May 30, 2012 | Reply

  30. Mark says:

    JJ, did you upgrade to Xcode 4.3.2? If you do that, you’ll need to make a copy of the RunPlatformUnitTests file per the discussion in the comments above.

    May 30, 2012 | Reply

  31. JJ says:

    Thank you,Mark for quick response. Yeah I updated and followed the above discussion. So far, no luck. Before updating to 10.7.4, it worked perfectly on 10.7.3. I feel Lion10.7.4 is blocking this Application unit test running from command line. Your environment is 10.7.4?

    May 30, 2012 | Reply

  32. JJ says:

    I was able to fix the issue. “com.apple.UIKit” launch daemon was broken. I re-started all launch daemons and it fixed the issue.

    The following steps what I did….
    Step 1: re-started Launch Daemons
    Step 2: run any application from your Xcode IDE with Simulator
    ( blank simulator was launched.)
    Step 3: close Xcode
    ( don’t close the blank simulator)
    Step 4: run Application Unit Test

    Result: run ApplicationUnitTest from command line and you can see the ApplicationUnit Test UI navigation on the simulator.

    NOTE: when you want to execute continues build, please delete iPhone Simulator folder from ~/Library/Application Support folder before running Application Unit Test.

    A little bit tricky. But if you are not familiar with launching daemons,please read the following site.

    http://spin.atomicobject.com/2011/05/27/testing-eventkit-and-uipasteboard-without-the-simulator/

    May 31, 2012 | Reply

  33. Chuck says:

    Has anyone tried this with Xcode 4.4 or 4.5 beta?

    Aug 13, 2012 | Reply

  34. Mark says:

    Chuck,

    Yes, we just upgraded our continuous integration server to Xcode 4.4, and the above “method” is still working.

    We have not tried on 4.5 yet as we’re working on production software and don’t want to try the beta yet.

    Cheers

    Mark

    Aug 13, 2012 | Reply

  35. Matt Yohe says:

    Something worth noting, “test” shows up as a build action in Xcode 4.4 now. So in theory you can type:
    xcodebuild -scheme asdf test

    And this will run the test build action.

    This works great for OS X apps, it doesn’t however for iOS. On iOS you get this lovely message:

    xcodebuild: error: Failed to build project asdf with scheme asdf.
    Reason: The run destination My Mac 64-bit is not valid for Testing the scheme ‘asdf’.

    Doesn’t help if I use something like: -sdk iphonesimulator5.1

    Aug 18, 2012 | Reply

  36. bryn austin bellomy says:

    Just got Xcode 4.5 DP4 working with this!

    Basically all it took was following these instructions: http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html … and making sure to remove the TEST_HOST build setting (which the article I linked fails to mention). If you do that, you can simply run:

    xcodebuild -scheme MyScheme -sdk iphonesimulator6.0 TEST_AFTER_BUILD=YES clean build

    Aug 24, 2012 | Reply

  37. Jeff L says:

    Bryn, removing TEST_HOST doesn’t truly make application tests run. Only the *logic* tests (the ones that don’t need UIKit) run. Now when I try to run my Kiwi tests on the command line, I see “Terminating since there is no workspace.” and “Unknown Device Type. Using UIUserInterfaceIdiomPhone based on screen size” in place of the normal Kiwi test output that worked in XCode 4.4. Something has apparently changed with XCode 4.5′s build scripts, but I haven’t seen anyone figure it out yet.

    Aug 27, 2012 | Reply

  38. Dustin Mallory says:

    Anyone figured out the appropriate tweaks to get application tests running from the command line with the Xcode 4.5 GM yet? So far I’m still running into problems with the reworked RunPlatformUnitTests.

    Sep 13, 2012 | Reply

  39. bao says:

    It used to work for me, but not since upgrading to Xcode 4.5 GM. Even the sample project downloaded from this page fails.

    Looks like RunUnitTests crashed:

    CmdlineAppTesting/build/CmdlineAppTesting.build/Debug-iphonesimulator/CmdlineAppTestingTests.build/Script-497F3D2113577A030038F395.sh: line 3: 84284 Segmentation fault: 11 “${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests”
    Command /bin/sh failed with exit code 139

    Sep 14, 2012 | Reply

  40. Pascal says:

    Hi.

    We are trying to make it work (in our Jenkins build env) but we always have a RunUnitTests crashed:

    Segmentation fault: 11 “${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests”
    Command /bin/sh failed with exit code 139

    We tried with XCode 4.3, 4.4 and brand new 4.5 GM.

    Did some of you had this segmentation fault and find a solution to fix it?

    Thanks.

    Sep 17, 2012 | Reply

  41. Sveinung Kval Bakken says:

    No solution for the 4.5 GM yet?

    Sep 18, 2012 | Reply

  42. elfenlaid says:

    Hi, all.

    After 6.0 update current solution doesn’t work & produce
    Segmentation fault: 11 “${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests”
    Command /bin/sh failed with exit code 139

    Here a little enhance:
    First of all, comment function RunTestsForApplication() { .. at 80 line and you done.

    Here’s your tests ignition code:
    xcodebuild -target AppTests -sdk iphonesimulator5.0 -configuration Debug build TEST_AFTER_BUILD=YES -arch i386

    But you wouldn’t get any useful test information until add
    export OTHER_TEST_FLAGS=”-RegisterForSystemEvents”
    before
    RunTestsForApplication “${TEST_HOST}” “${TEST_BUNDLE_PATH}” call in Main function
    Currently solution works only if you run tests again 5.0 sdk.
    I haven’t noticed any side effects yet after modifying script, so it’s spike but working one I hope :)
    Sorry for bad english & gl with your tests.

    Sep 20, 2012 | Reply

  43. effzehn says:

    Wow, it seems with the 4.5GM running application tests in the simulator IS NOW SUPPORTED! Could anybody double-check this?

    Sep 25, 2012 | Reply

  44. Edward says:

    Couldn’t you always run application tests in the simulator?

    Sep 26, 2012 | Reply

  45. bao says:

    I think since iOS 5.0 you can run application test in the simulator.

    Sep 28, 2012 | Reply

  46. bao says:

    elfenlaid I tried your approach and got one step closer, but I’m seeing this crash:
    *** Assertion failure in -[UIStatusBarServerThread main], /SourceCache/UIKit_Sim/UIKit-2372/UIStatusBarServer.m:96
    *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Unable to start status bar server. Failed to check into com.apple.UIKit.statusbarserver: unknown error code’

    Have you seen that before?

    Thanks.

    Sep 28, 2012 | Reply

  47. bao says:

    I see. So using Apple’s built-in RunTestsForApplication doesn’t work with iOS6 SDK any more. So elfenlaid your approach has to include -sdk iphonesimulator5.0

    I found another approach to do command line unit testing, which doesn’t require RunTestsForApplication. It requires a little bit more work, but for now it works for Xcode 4.5:
    http://baolei.tumblr.com/post/32428168156/ios-unit-test-from-command-line-ios6-xcode4-5

    Sep 28, 2012 | Reply

  48. Josh Vickery says:

    With XCode 4.5 I had to do the following.

    1. Copy /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests to the root of my project

    2. Edit RunPlatformUnitTests and delete the implementation of RunTestsForApplication()

    3. Edit the run script phase of my UnitTest target to ./RunPlatformUnitTests

    Oct 11, 2012 | Reply

  49. Josh Vickery says:

    I left out part of the run script — the full contents:

    # Run the unit tests in this test bundle.
    export OTHER_TEST_FLAGS=”-RegisterForSystemEvents”
    ./RunPlatformUnitTests

    Oct 11, 2012 | Reply

  50. Aldrich says:

    I managed to do as described with Xcode 4.5. But I’m getting this problem as I run

    xcodebuild -target AppTestsTarget -configuration Debug -sdk iphonesimulator6.0 TEST_AFTER_BUI
    LD=YES clean build

    …/RunPlatformUnitTests.include:273: note: Running tests for architecture ‘i386′ (GC OFF)
    …/RunPlatformUnitTests.include: line 312: /Users/aldrich/Work/MyApp/build/Debug-iphonesimulator/MyApp.app/MyApp: No such file or directory
    …/RunPlatformUnitTests.include:339: error: Test host ‘/Users/aldrich/Work/MyApp/build/Debug-iphonesimulator/MyApp.app/MyApp’ exited abnormally with code 127 (it may have crashed).

    The host app is not built into that path (it goes into a Derived data directory, while the app test target can be found as mentioned), nor does running the above command actually build the host app first, as might be the case. What could possibly be wrong here?

    Oct 16, 2012 | Reply

  51. umangdinesh says:

    @Josh Vickery

    I tried your instructions
    I am getting following error

    Terminating since there is no workspace.
    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:334: note: Passed tests for architecture ‘i386′ (GC OFF)

    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:345: note: Completed tests for architectures ‘i386′

    Oct 17, 2012 | Reply

  52. Aldrich says:

    I cannot get the Sample Project posted here

    http://longweekendmobile.zippykidcdn.com/wp-content/uploads/2011/04/CmdlineAppTesting.zip

    to run the tests on the command line with Xcode 4.5 (well after dealing with the Core Data issue). It builds but does not execute the test. Is that not what this article is about?

    Oct 17, 2012 | Reply

  53. Scott says:

    Your blog post is lovely, but you might credit the original author of the script and the solution:

    http://stackoverflow.com/questions/5403991/xcode-4-run-tests-from-the-command-line-xcodebuild/10823483#10823483

    Oct 25, 2012 | Reply

  54. Scott says:

    Er… that previous comment was directed at bao

    Oct 25, 2012 | Reply

  55. Greg Kraft says:

    I have a similar issue to umangdinesh when following Josh Vickery’s method:

    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:266: note: Started tests for architectures ‘i386′
    Run unit tests for architecture ‘i386′ (GC OFF)
    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:273: note: Running tests for architecture ‘i386′ (GC OFF)
    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include: line 269: 78517 Abort trap: 6 “${TEST_HOST}” ${TEST_HOST_FLAGS} ${OTHER_TEST_FLAGS}
    /Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:339: error: Test host ‘/Users/gkraft/Projects/pointabout_hut/UTs/build/Debug-iphonesimulator/UTs.app/UTs’ exited abnormally with code 134 (it may have crashed).

    Nov 1, 2012 | Reply

  56. Greg Kraft says:

    I believe I was missing:

    RunTestsForApplication “${TEST_HOST}” “${TEST_BUNDLE_PATH}”

    It wasn’t explicitly mentioned, but when replacing:

    Warning ${LINENO} “Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set).”

    …you really want to replace

    RunTestsForApplication(){
    Warning ${LINENO} “Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set).”
    }

    Finally, this is the full xcodebuild command I use:

    xcodebuild -target UTsTests -configuration Debug -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk TEST_AFTER_BUILD=YES clean build

    TEST_AFTER_BUILD can also be set in Xcode testing target’s settings.

    Finally, you want to use

    “${PROJECT_DIR}/RunPlatformUnitTests”

    when replacing

    “${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests”

    in the Xcode run scripts section

    [email protected]

    Nov 1, 2012 | Reply

  57. viteinfinite says:

    @bao, I managed to resolve the ‘Unable to start status bar server’ error by killing the simulator before launching the tests.

    My solution is here:
    http://www.viteinfinite.com/2013/05/how-to-resolve-unable-to-start-status-bar-server-failed-to-check-into-com-apple-uikit-statusbarserver-unknown-error-code-exception/

    May 20, 2013 | Reply

6 Trackback(s)

  1. Dec 19, 2011: Automated iOS Jenkins builds with application tests and Core Data « Life & Code
  2. Dec 20, 2011: lightforce's tech blog » Server Setup for Continuous Integration with iOS Projects
  3. May 28, 2012: Jenkinsを使ったiOSアプリビルド自動化8 テストの実行と集計 | なんてこったいブログ
  4. Jun 6, 2012: Xcode: Running Logic and ApplicationTests form command line. « Red Green Refactor
  5. Oct 27, 2012: Automating unit tests in XCode | danielgorst
  6. Nov 11, 2012: iOS application unit tests from the command line: Xcode 4.5 update | Long Weekend - iPhone & iPad Apps You'll Love!

Post a Comment