views:

17

answers:

1

I am trying to set command line arguments for Xcode project related to iPhone Simulator Application.

When i try to run the following script the line "make new launch argument with properties{name:"file:///Users/aakash/Desktop/sample_h.html",active:yes} "

gives error: execution error: Xcode got an error: Can’t make or move that element into that container. (-10024)

Here's the script:

!/bin/zsh

BUILD_PATH=$(dirname $0)

while [[ -z $BUILD_FILE && $BUILD_PATH != "/" ]]; do
    BUILD_FILE=$(find $BUILD_PATH -name '*.xcodeproj' -maxdepth 1)
    BUILD_PATH=$(dirname $BUILD_PATH)
done

if [[ -z $BUILD_FILE ]]; then
    echo "Couldn't find an xcode project file in directory"
    exit 1
fi

open -a Xcode "$BUILD_FILE"

BUILD_FILE=${BUILD_FILE//\//:}

SIMULATOR_SDKS=( /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/*.sdk )

SIMULATOR_SDK=${SIMULATOR_SDKS[-1]} 
SIMULATOR_SDK_STRING=$(basename ${(L)SIMULATOR_SDK%.[a-z]*})

if [[ -z $SIMULATOR_SDK ]]; then
    echo "Couldn't find a simulator SDK"
    exit 1
fi

echo $BUILD_FILE
echo $BUILD_PATH

osascript <<SCRIPT
application "iPhone Simulator" quit
application "iPhone Simulator" activate


tell application "Xcode"
    open "$BUILD_FILE"
    set targetProject to project of active project document

    tell targetProject
        set active build configuration type to build configuration type "Debug"
        set active SDK to "$SIMULATOR_SDK_STRING"
        set value of build setting "SDKROOT" of build configuration "Debug" of active target to "$SIMULATOR_SDK"
        make new launch argument with properties{name:"file:///Users/aakash/Desktop/sample_h.html",active:no}

        if (build targetProject) is equal to "Build succeeded" then
                launch targetProject
        else
                application "iPhone Simulator" quit
        end if
    end tell
end tell
SCRIPT

Any Clues??? Is there any other way to set arguments for Xcode Project or am i doing it wrong? Please help.

A: 

For building from the command line, I generally use a Makefile that launches xcodebuild, the command-line front-end to Xcode. You could also use a zsh script to do the same thing, if you prefer. It's pretty easy to set project build options using the command-line tool.

mipadi
xcodebuild does not work with iphone simulator app.You have to launch "build and go" in Xcode to run the application.
Freakotrotter