Search code examples
xcodemacoscocoaxcodebuild

How do I run a Cocoa app after building it from the command line with xcodebuild?


I'm building a Mac OS X Cocoa application from the command line using an Xcode project like this:

xcodebuild -scheme MyApp -configuration Debug

How do I run it once it's done building?


Solution

  • I wrote a script to do this:

    #!/bin/bash
    
    x=$( xcodebuild -showBuildSettings -project MyApp.xcodeproj | grep ' BUILD_DIR =' | sed -e 's/.*= *//' )
    
    DYLD_FRAMEWORK_PATH=$x/Debug DYLD_LIBRARY_PATH=$x/Debug $x/Debug/MyApp.app/Contents/MacOS/MyApp
    

    (I figured this out by running the application from Xcode and then ps -wwE -p on the process to see its environment variables.)