0

How can I execute set of shell script using NSTask

The Below string must be executed using NSTask.

    NSString *aString = @"MY_USERNAME=\"SAM\"\
PROJDIR=\"/Path\"\
APPLICATION_NAME=\"AppName\"\
PROJECT_NAME=\"${APPLICATION_NAME}\" # .xcodeproj ommitted\
TARGET_SDK=\"iphoneos6.0\"\
PROJECT_BUILDDIR=\"${PROJDIR}/build/Release-iphoneos\"\
TARGET_TEST_NAME=\"UnitTests\"\
BUILD_HISTORY_DIR=\"/Users/${MY_USERNAME}/Desktop\"\
DEVELOPPER_NAME=\"iPhone Developer: Name (********)\"\
PROVISONNING_PROFILE=\"/Users/${MY_USERNAME}/Desktop/***************.mobileprovision\"\
/usr/libexec/PlistBuddy -h\
/usr/libexec/PlistBuddy -c \"Print :netId\" \"path/Info.plist\"\
myversion=40675\
/usr/libexec/PlistBuddy -c \"Set :netId '${myversion}'\" \"path/Info.plist\"\
# compile project\
echo Building Project\
cd \"${PROJDIR}\"\
xcodebuild -target \"${PROJECT_NAME}\" -sdk \"${TARGET_SDK}\" -configuration Release\
#Check if build succeeded\
if [ $? != 0 ]\
then\
exit 1\
fi\
/usr/bin/xcrun -sdk iphoneos PackageApplication -v \"${PROJECT_BUILDDIR}/${APPLICATION_NAME}.app\" -o \"${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa\" --sign \"${DEVELOPPER_NAME}\" --embed \"${PROVISONNING_PROFILE}\"";
Ganesh Nayak
  • 802
  • 11
  • 38
  • 3
    You are probably better off writing that "script" to a temporary file; and running `sh /path/to/file.sh` as an `NSTask`. – trojanfoe Feb 20 '13 at 11:17
  • I agree, but I would like to modify the script right after the completion of the task. – Ganesh Nayak Feb 20 '13 at 11:18
  • 1
    Err, not sure what you mean. If you are dynamically writing that script before it's executed then you can re-write it (or write another) with any variation you like before starting it using `NSTask`. – trojanfoe Feb 20 '13 at 11:23

0 Answers0