Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Xcode target from command line

Tags:

xcode

I am new to running unit tests using Catch.

I am using the Catch to run unit tests in my Xcode project. I have added a target to my project which includes my Catch files and tests cases. Selecting that target and running from Xcode runs fine. I am now trying to get it to run from the command line which will be the way it is run from Jenkins. I have a shell script that contains:

xcodebuild clean install
xcodebuild -target TestApp  -configuration “Debug”  -sdk iphonesimulator7.1   CONFIGURATION_BUILD_DIR=TestBuild ONLY_ACTIVE_ARCH=NO

The result is:

** INSTALL SUCCEEDED **

Build settings from command line:
    CONFIGURATION_BUILD_DIR = TestBuild
    ONLY_ACTIVE_ARCH = NO
    SDKROOT = iphonesimulator7.1

--- xcodebuild: WARNING: Configuration “Release” is not in the project. Building default configuration.

=== BUILD TARGET CreativeSDKTest OF PROJECT CreativeSDKImage WITH THE DEFAULT CONFIGURATION (Release) ===

Check dependencies

** BUILD SUCCEEDED **

But the application doesn’t launch in the simulator. Maybe I’m not seeing the obvious but from all the docs I’ve read, this should launch the application.

like image 787
user2665402 Avatar asked Apr 17 '14 17:04

user2665402


People also ask

How do I run Xcode from command line app?

in file window go to search input field and type 'terminal' and click on its icon when you find it. Now you should see 'Terminal. app' in 'Executable' field. go to the 'Arguments' tab, click on + and copy and paste this line there: ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}

How do I access targets in Xcode?

You can access Target Membership by selecting file and opening the right menu in Xcode (the menu is called Inspectors ). Then, in File Inspector at the bottom of the menu, find Target Membership . It's very important to check all files in your project because without this you won't be able to build a new app target.

How do I run a command line argument in Xcode?

Open your scheme (⌘<) and select the Run > Arguments tab. Add the arguments you want to pass on launch one at a time. Double-click to edit any argument: The arguments are vended by CommandLine.

How do I run Xcode on Mac terminal?

Installing XcodeType “gcc” into the terminal and hit “Enter” (gcc is a compiler that turns source code into executable applications). Alternatively, typing “xcode-select — install” into the terminal works just as well.


1 Answers

I think you'll need to tell xcodebuild to test the project:

xcodebuild clean install
xcodebuild -target TestApp  -configuration “Debug”  -sdk iphonesimulator7.1   CONFIGURATION_BUILD_DIR=TestBuild ONLY_ACTIVE_ARCH=NO clean test

(See the end of the last command)

EDIT: In fact you probably don't even need the first command and just the second will do.

like image 61
Rich Avatar answered Oct 04 '22 12:10

Rich