0

I've got a crontab running a shell script for an automated build of an ios app. Running the shell script from the command line compiles and builds the .ipa with no issue. But when the crontab runs the shell script, the app gets compiled but does not fully finish with an .app or .ipa file. Why doesn't it run the same way?

    CONFIGURATION="Adhoc"
    OUTPUT_DIR="$PWD/Build/Products/Adhoc-iphoneos"
    HOCKEY_TOKEN="token"
    DEVELOPER_NAME="name"

    ########
    #
    # Cleanup
    #
    if [ -f "$OUTPUT_DIR/AppName-App.app.dSYM.zip" ]; then
      rm -f "$OUTPUT_DIR/AppName-App.app.dSYM.zip"
    fi

    ########
    #
    # Build The App
    #
    xcodebuild \
      -workspace "AppName.xcworkspace" \
      -scheme "AppName-App" \
      -configuration "$CONFIGURATION" \
      ONLY_ACTIVE_ARCH=NO clean build

    ########
    #
    # Code Sign
    #
    xcrun \
      -sdk iphoneos PackageApplication \
      -v "$OUTPUT_DIR/AppName-App.app" \
      -o "$OUTPUT_DIR/AppName-App.ipa" \
      --sign "$DEVELOPER_NAME"\
      --embed AppName/BuildResources/AppName.mobileprovision

    ########
    #
    # Zip the dSYM
    #
    zip -r "$OUTPUT_DIR/AppName-App.app.dSYM.zip" "$OUTPUT_DIR/AppName-App.app.dSYM"

    ########
    #
    # Upload to HockeyApp
    #
     curl \
      -F "status=2" \
      -F "notify=0" \
      -F "notes=automated build" \
      -F "notes_type=1" \
      -F "ipa=@$OUTPUT_DIR/AppName-App.ipa" \
      -F "dsym=@$OUTPUT_DIR/AppName-App.app.dSYM.zip" \
      -H "X-HockeyAppToken: $HOCKEY_TOKEN" \
      https://rink.hockeyapp.net/api/2/apps/upload
mylegfeelsfunny
  • 507
  • 1
  • 8
  • 20

1 Answers1

0

When there are differences between a script executed in a logged in shell and via cron, it's almost always environment. Do you know what the value of $PWD is when run via cron? Looks like the provisioning profile you're embedding is using a relative path and might not be found.

I would try making all the paths absolute so you know exactly what the environment is when run in cron.

Also, you aren't showing the actual error messages. Those would obviously help. If you aren't redirecting to a file, cron will mail them to the owner of the crontab.

z00b
  • 356
  • 2
  • 3
  • I believe you are right. This is the error that gets logged when the cron runs. **The following build commands failed: Check dependencies (1 failure)** `whoami` says its running as the same user as me. – mylegfeelsfunny Apr 28 '14 at 15:33