Search Unity

TestFlight and Cloud build

Discussion in 'Unity Cloud Build' started by kujo, Jul 17, 2015.

  1. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    We have recently started using the new TestFlight from Apple as it makes it really easy to submit build to our client without having to have them give UDID's and keeps things simple for them.

    I was wondering if there is a way to use both the Cloud to do the build but distribute through TestFlight? When I download the IPA at the moment and upload it using the Application Loader, I get a warning:

    To use TestFlight Beta Testing, build 0.0.19 must contain the correct beta entitlement.
     
  2. hypeNate

    hypeNate

    Unity Technologies

    Joined:
    Apr 4, 2014
    Posts:
    258
    Pix10 likes this.
  3. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    843
    Nice guide.

    You could also of course have a separate Project dedicated to just Testflight builds.
     
  4. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    Perfect - exactly what I needed. Thanks
     
    hypeNate likes this.
  5. Varaunited

    Varaunited

    Joined:
    Sep 8, 2017
    Posts:
    1
    Hi guys ,

    @kujo @Pix10 @hypeNate i am trying to upload .ipa file to test flight app , but unfortunatley the build is not shown in test flight , Dont know where i went wrong .Builds option is diabled in test flight .Please help me in fixing this issue

    Regards,
    S.DamodharaReddy.
     
  6. alan_motionlab

    alan_motionlab

    Joined:
    Nov 27, 2014
    Posts:
    89
    you now need to manually confirm export compliance through iTunes Conenct once you have uploaded it and its been processed.
     
  7. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    114
    Is this still the method to use after 1 1/2 years, or is there another way?

    I cant find a list of stores that cloud build accepts as "Push To" options, so I assume iTunes is not an option?
     
  8. technicat

    technicat

    Joined:
    Nov 22, 2006
    Posts:
    1,273
    The process as described in the doc above still works. I build in UCB with the distribution profile, download the ipa from UCB when it's done, upload the ipa to iTunesConnect using Application Loader in Xcode (External Tools), then when I get the iTunesConnect email saying it's ben processed, go to the TestFlight section in iTunesConnect and see the build is there and do whatever is needed to distribute to TestFlight users (declare it has no encryption, submit for testing, etc.)
     
    nobluff67 likes this.
  9. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    829
    I found that you can add a PostProcess on the build that automatically provides export compliance (handy to save you having to do it manually within iTunes Connect each time):

    Code (CSharp):
    1. #if UNITY_IOS
    2. using UnityEngine;
    3. using UnityEditor.Callbacks;
    4. using UnityEditor;
    5. using UnityEditor.iOS.Xcode;
    6. using System.IO;
    7.  
    8. public class ProvideExportCompliance
    9. {
    10.     [PostProcessBuild]
    11.     public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    12.     {
    13.         // Performs any post build processes that we need done
    14.         if( buildTarget == BuildTarget.iOS )
    15.         {
    16.             // PList modifications
    17.             {
    18.                 // Get plist
    19.                 string plistPath = pathToBuiltProject + "/Info.plist";
    20.                 var plist = new PlistDocument();
    21.                 plist.ReadFromString(File.ReadAllText(plistPath));
    22.  
    23.                 // Get root
    24.                 var rootDict = plist.root;
    25.  
    26.                 // Add export compliance for TestFlight builds
    27.                 var buildKeyExportCompliance = "ITSAppUsesNonExemptEncryption";
    28.                 rootDict.SetString( buildKeyExportCompliance , "false" );
    29.                
    30.                 // Write to file
    31.                 File.WriteAllText( plistPath , plist.WriteToString() );
    32.             }
    33.         }
    34.     }
    35. }
    36. #endif
     
  10. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    114
    @tonemcbride Do you need to attach this to a game object or just have it in your project? Thanks for the tip.
     
  11. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    829
    No, it doesn't need to be a GameObject or in any scenes. Just put it into it's own .cs file and put it in the Editor folder. It'll run after the build because it has the [PostProcessBuild] flag.
     
    nobluff67 likes this.
  12. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    114
    Just went through this process yesterday, works extremely well if you follow the instructions, and this includes the code provided by @tonemcbride . Thanks.
     
  13. alan_motionlab

    alan_motionlab

    Joined:
    Nov 27, 2014
    Posts:
    89
    @tonemcbride - stumbled across this thread looking for something else, but this is a great find. Always annoys me having to handle the export as I usually upload as I leave the office and the iTunes pages aren't mobile friendly.

    Thanks!!
     
  14. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    829
    No problem, glad it helped. Apple have only had 12 years to get iTunes Connect working on mobile devices so we can't blame them ;)
     
    alan_motionlab likes this.
  15. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    829
    I recently wrote an OSX script to automatically download the latest iOS cloud build and upload it to TestFlight. I'm posting it here in case anyone finds it useful. Here's the prerequisites:

    1) Cloud build must be setup to build with app-store provisioning profiles

    2) OSX must have terminal access to the 'jq' command. For homebrew users you can do 'brew install jq' from the terminal to install that.

    3) Take the script below, save it as something like upload.sh and make it executable using 'chmod +x upload.sh'

    4) Edit the script and replace the following parameters:

    APIKEY - Get your cloud build API key on this page (https://developer.cloud.unity3d.com/preferences/)

    ORGID / PROJECTID / BUILDID - Replace these with your own company and build info. You can get this by looking at the URL of a recent cloud build

    APPLOADER_EMAIL / APPLOADER_PASSWORD - Replace these with your Application Loader username & password.

    Code (CSharp):
    1. # Get the JSON data of the latest Cloud Build
    2. curl --header "Content-type: application/json" --header "Authorization: Basic APIKEY" "https://build-api.cloud.unity3d.com/api/v1/orgs/ORGID/projects/PROJECTID/buildtargets/BUILDNAME/builds" -o ipaLocation.txt
    3.  
    4. # Retrieve the URL of the IPA file
    5. cat ipaLocation.txt | jq '.[0].links.download_primary.href' | sed '1s/^/url = /' > ipaLocationStripped.txt
    6.  
    7. # Download the IPA build
    8. curl --config ipaLocationStripped.txt -o build.ipa
    9.  
    10. # Upload the build to iTunes Connect
    11. /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool --upload-app -f build.ipa -u 'APPLOADER_EMAIL' -p 'APPLOADER_PASSWORD'
    12.  
     
    whiteflux, nobluff67 and technicat like this.