Question

I am trying to run shell script from php file to build and archive the ios application. Here is what i have done so far

In my test.php file i have written below code:

<?php
    echo shell_exec("sh build.sh");
?>

In build.sh i have written:

PROJDIR="/Library/WebServer/Documents/ExpertIPA/IPA/MyApp"
PROJECT_NAME="MyApp"
APPLICATION_NAME="MyApp"
TARGET_SDK="iphonesimulator6.0"
PROJECT_BUILDDIR="${PROJDIR}/build/Release-iphoneos"
TARGET_TEST_NAME="ExpertApp"
BUILD_HISTORY_DIR="${PROJDIR}/ipa/" #where you want the .ipa to go
DEVELOPER_NAME="iPhone Distribution: developer Name"
PROVISONING_PROFILE="/Library/WebServer/Documents/ExpertIPA/IPA/ExpertApp/
MyApp_distribution.mobileprovision"


echo Building Project
cd "${PROJDIR}"
build_type_iOS=$2


xcodebuild clean -configuration "${build_type_iOS}"
xcodebuild -target "${PROJECT_NAME}"  -configuration Release


if [ $? != 0 ]
then
   exit 1
fi

/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}/${PROJECT_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa"  --embed "${PROVISONING_PROFILE}"

when i running my build.sh file from terminal it creates MyApp.ipa successfully, also when i am running test.php on mac terminal its working fine, but when i am running test.php from browser it gives following error message.

Error message:

BUILD NATIVE TARGET MyApp OF PROJECT MyApp WITH CONFIGURATION Release === Check dependencies Code Sign error: The identity 'iPhone Distribution: Profile_Name' doesn't match any valid, non-expired certificate/private key pair in your keychains

Was it helpful?

Solution

The private key & cert xcodebuild is looking for are generally stored in your keychain. When you're logged in as yourself you can see your keychain with the Keychain Access GUI. Use that GUI to export the cert and private key.

Then look into using the 'security' command line tool to import the private key & certificate pair that xcodebuild is looking for into the keychain for the _www user. You may have to actually create a keychain for the _www user (I've only ever done builds with a normal user that you can login as).

OTHER TIPS

I think it looks for something like ~/.ssh/id_rsa and cannot find it when you run from browser (user www or www-data)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top