Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved Error pushing build to Apple App Store

Discussion in 'Unity Build Automation' started by MidniteOil, Mar 17, 2022.

  1. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    Resolved. Fixed this be changing my TARGET_NAME to default-ios

    Greetings devs,

    I have an iOS game that I've been pushing to the Apple App Store using a Windows application called Apple App Uploader. The app was free for a year but my trial period has ended.

    I stumbled across this bash script that I can add to the post-build step of my cloud build to push the app to the app store:
    #!/bin/bash
    echo "Uploading IPA to Appstore Connect..."
    #Path is "/BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa"
    path="$WORKSPACE/.build/last/$TARGET_NAME/build.ipa"
    if xcrun altool --upload-app -t ios -f $path -u $ITUNES_USERNAME -p $ITUNES_PASSWORD ; then
    echo "Upload IPA to Appstore Connect finished with success"
    else
    echo "Upload IPA to Appstore Connect failed"
    fi

    I've put the script in my project, updated my build number and pushed the changes to my repo. Added the specified environment variables and run the build. It fails with what looks to be two issues:
    1. It's not finding the build at the specified path
    2. It's failing to authorize (I am using an app-specific-password I created for my account).

    *** Error: Error uploading '/opt/workspace/workspace/greg-bradburn.ninjaeggs-ios.default-ios/.build/last/iOS/build.ipa'.
    *** Error: Unable to upload archive. The file '/opt/workspace/workspace/greg-bradburn.ninjaeggs-ios.default-ios/.build/last/iOS/build.ipa' cannot be found. (-43)
    *** Error: Unable to upload archive. Failed to get authorization for username 'NinjaEggs31' and password. (
    "Error Domain=NSCocoaErrorDomain Code=0 \"Status code: 0\" UserInfo={NSLocalizedDescription=Status code: 0, NSLocalizedFailureReason=The auth server returned a bad status code.}"
    NSLocalizedFailureReason = "Failed to get authorization for username 'NinjaEggs31' and password. (\n \"Error Domain=NSCocoaErrorDomain Code=0 \\\"Status code: 0\\\" UserInfo={NSLocalizedDescription=Status code: 0, NSLocalizedFailureReason=The auth server returned a bad status code.}\"\n)";

    Here are relevant config settings for my cloud build:






    Anyone on this forum push their game to iOS via cloud build that can tell from these errors what I need to change to get it working?

    Thanks,

    -MidniteOil
     
    Last edited: Mar 17, 2022
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,090
    Your environment variable 'TARGET_NAME' needs to match the name of your cloud build configuration.

    At the moment you have it set to 'iOS' but it should be 'default_ios' which is the name of your config (spaces are replaced with underscores and it's all lowercase)

    I'm not sure about the password error but it might just be because you have a bad build path. Try it again with the above fix and see how you get on.
     
    MidniteOil likes this.
  3. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    Yeah, figured that part out. I generated a new app-specific password and have updated the environment variables accordingly. I think the ITUNES_USERNAME needs to be the email address for my Apple Developer account and the ITUNES_PASSWORD needs to be the app-specific password. I've kicked off a new build with those settings so we'll see how it goes.
     
    tonemcbride likes this.
  4. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    It worked. The build completed successfully and was pushed to the App Store!!!

    Woo Hoo!!!
     
    tonemcbride likes this.
  5. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    FWIW, I've been using the following open source utility to upload to the store...

    https://github.com/simonnilsson/ios-uploader

    The repo page even has links to numerous binaries, if you don't fancy messing around with Node.js

    That said, that bash script is nice and simple and easily integrated with UCB by the looks of it. Nice find!
     
    MidniteOil likes this.
  6. Gwom

    Gwom

    Joined:
    Aug 5, 2015
    Posts:
    21
    If anyone else stumbles here and doesn't have any luck with the correct password, try the following which worked for me, without changing the password - note I was porting over this system from a different project so maybe the first time with a new title:
    • Make sure the App is setup in iTunesConnect, and in the Testflight section, try adding all the test information (though will probably always show a warning), and setup an internal testing group
    • Try to do it again, it might work the second time after failing
    upload_2022-7-4_13-53-20.png