Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Xcode 9 - Multiple Provisioning Profiles

Discussion in 'Unity Cloud Build' started by dannyd, Aug 13, 2018.

  1. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    Something that has come up a number of times are questions around supporting multiple provisioning profiles. We have finally made this available (along with more customization of the Xcode build process in Xcode 9+). Longer term, we are working on simplifying the process around supporting multiple provisioning profiles since it's a common use case, but I wanted to provide this example for others who might want to modify the Xcode build process that runs in Unity Cloud Build in some way.

    As some background, Unity Cloud Build relies on Fastlane for building Xcode projects (at least for Xcode 9+), so what is being added here is the ability to customize the Fastlane process when building in Unity Cloud Build. All of the configuration options are going to be very specific to Fastlane, so some basic familiarity with the toolset is helpful.

    The easiest way to describe what is available is probably by providing a basic example of how you might configure your project to build with multiple profiles currently. The following example assumes you are building an app with an application identifier of "com.unity3d.cloudbuild.base" and a stickers extension with an app identifier of "com.unity3d.cloudbuild.base.stickers".

    This setup currently requires adding three extra files to your repository:

    1. An options file named "Assets/ucb_xcode_fastlane.json" - both the name and location are important. This file controls the paths to your custom Fastfile/Gymfile and which lanes in the Fastfile should be run. Supports the following properties (all of which are optional):
    • fastfile - a path to your custom Fastfile, relative to the root of your repository.
    • gymfile - a path to your custom Gymfile, relative to the root of your repository.
    • lanes - lanes within the Fastfile referenced above.
      • pre_build - lane to run before the actual Xcode build steps.
      • post_build - lane to run after the actual Xcode build steps.

    Example "Assets/ucb_xcode_fastlane.json":
    Code (JavaScript):
    1. {
    2.     "fastfile": "Assets/ucb/Fastfile",
    3.     "gymfile": "Assets/ucb/Gymfile",
    4.     "lanes": {
    5.         "pre_build": "use_stickers_profile",
    6.         "post_build": ""
    7.     }
    8. }

    2. A custom Fastfile to install the provisioning profile and update the provisioning settings in the Xcode project. This file can be placed wherever you want in the repo, but it needs to match the path of the "fastfile" in ucb_xcode_fastlane.json above.

    If you've configured pre_build/post_build lanes, an options hash is passed to those lanes when they run containing:
    * project_dir - root of the repo this project is building from.
    * build_target - build target identifier for this build.
    * output_directory - final output directory where the Xcode project will build to.

    In this example, we are installing the provisioning profile at "Assets/ucb/Stickers.mobileprovision" in the repo, and updating the "Unity-iPhone-Stickers" target in the Xcode project to use that profile.


    Example "Assets/ucb/Fastfile":
    Code (CSharp):
    1. lane :use_stickers_profile do |options|
    2.     profile_path = File.join(options[:project_dir], 'Assets/ucb/Stickers.mobileprovision')
    3.     FastlaneCore::ProvisioningProfile.install(profile_path)
    4.     update_project_provisioning(
    5.         xcodeproj: 'Unity-iPhone.xcodeproj',
    6.         target_filter: 'Unity-iPhone-Stickers',
    7.         profile: profile_path
    8.     )
    9. end

    3. A custom Gymfile to define the application identifier to provisioning profile mapping as part of customizing the export options. This file can be placed wherever you want in the repo, but it needs to match the path of the "gymfile" in ucb_xcode_fastlane.json above. For available options, see the fastlane docs.

    In this example, we are specifying that the "com.unity3d.cloudbuild.base.stickers" application identifier should map to a UUID of "1e33640e-9a55-4357-a632-ca6c48a53a96" (which is the UUID of the provisioning profile at "Assets/ucb/Stickers.mobileprovision").


    Example "Assets/ucb/Gymfile":
    Code (CSharp):
    1. export_options(
    2.     provisioningProfiles: {
    3.         "com.unity3d.cloudbuild.base.stickers" => "1e33640e-9a55-4357-a632-ca6c48a53a96"
    4.     }
    5. )

    And that's it. Again, longer term we are working to simplify this process and make more of the Fastlane process customizable so if there is something specifically you want to see here please let us know.
     
    hba_infinity and ollieblanks like this.
  2. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    Hey @dannyd ,

    Thanks for releasing this so we can get multiple provisioning profiles for iOS builds in Cloud Build.

    Now for the annoying part, I've followed the instructions above in a Unity project using the agens plugin and seem to be getting a Check Dependencies error. Further down, we also get the error

    From everything I have read up for fastlane and gym, it should be using the correct Provisioning Profile with the same development team as the one for our game as well.

    I have attached a couple of images of what Cloud Build is reporting.

    I have censored all the personal data from this image, but from my understanding, I am using the correct provisioning profiles, mapping them to the correct AppId and UUID. The correct Team_ID is also being used according to the codesign_identity.
    StickersError1.JPG.png

    Is there any help or things you can see which would be causing the error shown in the attached images?

    Thanks,

    hba
     

    Attached Files:

    Last edited: Aug 21, 2018
  3. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    @hba_infinity - In general, that would suggest that target is set to use automatic signing rather than manual. We try to forcibly override all targets to use manual signing for this exact reason. Looking at your build log, it appears that you are running an "update_project_team" step in your custom lane - you almost certainly do NOT want that in there. Having the development team set is only relevant when using automatic signing.
     
  4. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    @dannyd Apologies about that, those screenshots were taken when playing around with Fastlane and attempting to get this to work. The original attempt definitely did not have "update_project_team" line in there, but still produced the same outcome.

    StickersError3.JPG.png

    From my understanding, from this first attempt, we were only using Automatic Signing, and our sticker pack is also using only Automatic Signing.

    Screenshot of our Unity Player Settings Identification area.
    StickersError5.JPG.png

    Screenshot of our Sticker Pack and using Automatic Signing
    StickersError4.JPG.png
     
  5. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    @hba_infinity - I probably wasn't clear enough above. Unity Cloud Build can ONLY support manual signing (automatic signing would require being logged in to your Apple account which we obviously do not have credentials for). What does your "use_stickers_profile" lane look like? Does the profile being used for signing the stickers extension rely on the same certificate as the profile used to sign the app?
     
  6. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    @dannyd , I've double checked and the profile being used is the same one for both our main application and for the stickers.

    StickersError6.png

    The project xcode project file, .mobileprovision, and sticker names are (from everything I can see) correct, and seem to be linking up correctly.

    The Gymfile looks exactly like the example posted, but with the Application Identifier and UUID changed to be our personal values. The ucb_xcode_fastlane.json file also looks exactly like the one provided, but the Fastfile and Gymfile are located inside the same Assets/Editor/iOS/Fastlane folder as the mobileprovision.
     
  7. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    @hba_infinity sorry for the slow response. I would uncheck "automatic signing" in the sticker pack for now. Will look for a proper fix and follow back up.
     
  8. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    @hba_infinity - try adding this after the "update_project_provisioning" step in your custom lane:

     
  9. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    Hey @dannyd ,

    It seems like adding the 'disable_automatic_code_signing(path: 'Unity-iPhone.xcodeproj')' line seemed to fix the problem. Our Cloud Build is now set up and can build with stickers on iOS with the provided Provisioning Profile.

    Thanks for all the help, and we appreciate the work you and the rest of the Unity team is doing to get all these awesome features available in a not-so-painful way!
     
  10. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    Hey @dannyd,

    Apologies to bother again, but it seems there is another roadblock with adding Stickers to our project. This time it is during the submission process where we are getting the error

    From everything I can tell from Cloud Build, the Stickers pack is being Signed and Built correctly, although now it seems they are not being added to the final IPA.

    Any help on this matter would be appreciated.
     
  11. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    Hey @dannyd,

    Just thought I would provide some more information about the problem mentioned above. From what I can tell by exploring the ipa file from our built game with Stickers, it looks like Stickers are being included into the build and are signed correctly, the only problem is that the MessagesApplicationExtensionSupport folder inside the ipa is empty, to which I am not sure what should be added into there using Fastlane or Cloud Build.

    Here are some images of the structure of our ipa file -

    This is the folder structure of the main directory of the ipa folder. MessagesApplicationExtensionSupport folder is located here and is in the correct directory -
    ipaDirectory.JPG

    Unfortunately, there are no files inside the MessagesApplicationExtensionSupport folder.
    MessageAppSupportDirectory.JPG

    Just exploring the ipa, the Unity-iPhone-Stickers project has been built into the project using all the information we provided from the information in the original posts.
    StickerDirectory.JPG

    Any help on this issue would be appreciated.

    Thanks,

    hba
     
  12. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    751
    @hba_infinity - sorry for the slow response, I've been out of the office on leave (and am still out for a few weeks so unlikely to respond very quickly). I don't really have any more insight into what's going on there. Are you able to produce a working binary locally when manually archiving through Xcode? Might also be worth checking with the author of the plugin to see if they have any additional insight as they are likely much more familiar with the stickers process and potential pitfalls.
     
  13. unity_2CJsTDGbiKcAXw

    unity_2CJsTDGbiKcAXw

    Joined:
    Oct 8, 2018
    Posts:
    1
    всем привет, подскажите пожалуйста как мне к установленной Unity добавить еще одну платформу для сборки, которую ранее я посчитал не нужной скачивать
     
  14. hba_infinity

    hba_infinity

    Joined:
    May 30, 2016
    Posts:
    34
    @dannyd - I ended up finding out what the problem was, it wasn't anything on the Unity Cloud Build side and was actually a bug in the Stickers plugin we were using. I've got the creators of that plugin to fix it, so hopefully it is all aok on their end. Once that was updated, the build looked to have everything in order. Now to go through the iTunes Connect side of things again to face the next (inevitable) problem.

    Thanks for your help.
     
  15. GoodCatchUnity3

    GoodCatchUnity3

    Joined:
    Jun 13, 2018
    Posts:
    2
    Hello,
    Thank you for this thread, we are edging ever-closer to making use of UCB. We are now able to sign a sticker extension target in Xcode using UCB. Here a summary of issues and fixes. Hopefully it can help others.

    Initial setup
    -We are able to manually code-sign in a locally built project.
    -Auto-Signing is marked as off in Unity Proj settings. Profiles build fine on a manually signed local build (no scripts used for signing, needs manual adjusting).
    -Our target XCode version is 9.4. The Unity version used for the project is 2018.1.9f2, UCB is set to use the latest of 2018.1

    Fix 1
    Fix 2
    Fix 3
    Useful information can also be gathered from fastlane and gym forums that deal with XCode builds and auto-code signing but are not directly related to unity Cloud Build.

    Hope this helps,
    Thomas

    PS: it has also been an ordeal to post this message. The Forum keeps telling me that I am posting spam and the rules are not clear. Therefore some errors above are posted as keywords.
     
    Last edited: Nov 23, 2018