简体   繁体   中英

How to run an Xcode built app from the command line (bash)

Following on from my question How to run an xcode project from bash?

I've found the built *.app in the build directory, but I'm trying to figure out how to get xcode to open it as it can't just be run as a Mac OS X program.

Any ideas?

thanks to chuan at this post: XCode Test Automation For IPhone

I'm stuck with the same problem trying to launch my debug output from building my xcode project. I just experimented with the following

open ./prog.app&

seems to do the trick.

I've solved my problem using a bash file that uses rsync to sync working directories and then AppleScript which builds and runs the project.

sync.sh:

#!/bin/bash

# script for moving development files into xcode for building
developmentDirectory="/"
xcodeDirectory="/"
echo 'Synchronising...'
rsync -r $developmentDirectory $xcodeDirectory \
--exclude='.DS_Store' --exclude='.*' --exclude='utils/' --exclude='photos'
echo 'Synchronising Done at:'
echo $(date)

buildandrun:

set projectName to "projectName"
# AppleScript uses : for / in directory paths
set projectDir to "Users:username:Documents:" & projectName & ":" & projectName & ".xcodeproj"
tell application "Xcode"
    open projectDir
    tell project projectName
           clean
           build
           (* for some reasons, debug will hang even the debug process has completed. 
              The try block is created to suppress the AppleEvent timeout error 
            *)
           try
               debug
           end try
    end tell
    quit
end tell

Then, finally, I'm using a shell script called run.sh aliased in my .bash_profile:

run.sh:

#!/bin/bash

bash utils/sync.sh
osascript utils/buildandrun

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM