Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Xcode Storyboard option for Splash Screens (Launch Screens) in iOS build

Discussion in 'iOS and tvOS' started by Marat_Gilyazov, Jan 17, 2020.

  1. Marat_Gilyazov

    Marat_Gilyazov

    Joined:
    Feb 23, 2016
    Posts:
    5
    Recently Apple announced, that "starting April 2020, apps submitted to the App Store must use an Xcode storyboard to provide the app’s launch screen". If as well as me you never heard about this "stroryboard" thing and have no idea how to make it work in Unity - welcome aboard.

    Unity kinda supports storyboards, but not fully + documentation is very poor.

    We'll create a simple *.storyboard file with colored background and an image in the center and link it to our Unity project.
    1. Create a new Xcode project and modify Launchscreen.storyboard file in it. That's it, no need to compile the project.
      Here is the step-by-step instruction how to do this:


    2. In Unity go to your Player Settings -> Splash Image, check the "Use Storyboard for Launch" checkbox and choose the Launchscreen.storyboard file from the project we just created.

      If you'll build your unity-project for iOS now, it'll use this storyboard settings, BUT if you used some images in it (as we did), then these images will be lost, or saying more correctly - they'll be not copied to the imported Xcode project :(

    3. Ok, let's copy our assets by post-process script in the build-time:

      Put this script in your "Assets/Editor" folder (create an "Editor" folder if it's not here yet):
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Callbacks;
    3. using UnityEngine;
    4.  
    5. public class CopyXcodeLaunchImageOnPostProcess
    6. {
    7.     const string XCODE_IMAGES_FOLDER = "Unity-iPhone/Images.xcassets";
    8.     const string SOURCE_FOLDER_NAME = "Splash.imageset";
    9.     const string SOURCE_FOLDER_ROOT = "Xcode Storyboard/splash/splash/Assets.xcassets";
    10.  
    11.     [PostProcessBuildAttribute(1)]
    12.     public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
    13.     {
    14.         if (buildTarget == BuildTarget.iOS)
    15.         {
    16.             string sourcePath = $"{SOURCE_FOLDER_ROOT}/{SOURCE_FOLDER_NAME}";
    17.             string targetPath = $"{path}/{XCODE_IMAGES_FOLDER}/{SOURCE_FOLDER_NAME}";
    18.  
    19.             FileUtil.DeleteFileOrDirectory(targetPath);
    20.             FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
    21.         }
    22.     }
    23. }
    SOURCE_FOLDER_NAME - is your image set name in "storyboard" project from (1) step
    SOURCE_FOLDER_ROOT - is the relative path to the root folder where your SOURCE_FOLDER_NAME image set lives (relative to your unity projects-root, so, both "Assets" and "Xcode Storyboard" folders are in the root folder in my case)

    Checked in:
    - Unity 2019.2.17f1+ Xcode 11.3.1 on MacOS 10.15.2
    - Unity Cloud (2019.2.16f1) + Xcode 11.2.1
     
    Last edited: May 27, 2021
    Gametyme, JonBFS, e2000 and 10 others like this.
  2. mark_gr

    mark_gr

    Joined:
    Jan 16, 2015
    Posts:
    25
    Thanks for the write up! We just got this notice and are wondering what to do...
    Currently we do not use the "Use Storyboard for launch screen" option, but in out info.plist it says

    <key>UILaunchStoryboardName~ipad</key>
    <string>LaunchScreen-iPad</string>
    <key>UILaunchStoryboardName~iphone</key>
    <string>LaunchScreen-iPhone</string>
    <key>UILaunchStoryboardName~ipod</key>
    <string>LaunchScreen-iPhone</string>

    mentioning LaunchStoryboard, curious if we are ok as long as we dont use the "Legacy Launch Images" options or if we have to use the "Storyboard for launch screen" option...
     
  3. tl1024768

    tl1024768

    Joined:
    Feb 27, 2020
    Posts:
    5
    bump, will Unity generate Storyboard itself for "Legacy Launch Images" method?
     
  4. GerodruS

    GerodruS

    Joined:
    Aug 3, 2015
    Posts:
    7
    Thank you for this excelent guide!

    Anyone experiencing problems with screen orientation?
    Trying to start using xcode storyboard. Stuck on a problem: if i'm quickly restarting my app, sometimes i see launchscreen in portrait orientation, and game starts in landscape orientation. After that the next restart launchscreen appears in landscape orientation and game -- in portrait. Despite of unity project settings, where only landscape orientation is allowed.

    Unity 2018.4.6f1, iOS 12 on iPhone XS with "lock screen orientation" is on.
     
  5. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    I'm using Unity 5.4.4p1 and I see the same items in my info.plist file. Does this mean that Unity has been using storyboard for launch screens for a long time, and there is nothing to do?
     
  6. Mr-Oliv

    Mr-Oliv

    Joined:
    Sep 14, 2012
    Posts:
    33
    @Marat_Gilyazov thanks for the walk through! Worked right away. Much appreciated!
     
    Marat_Gilyazov likes this.
  7. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,064
    Hello, is launch screen storyboard supported in Unity 2018?
     
  8. luismoyanomedina

    luismoyanomedina

    Joined:
    Sep 10, 2018
    Posts:
    3
  9. luismoyanomedina

    luismoyanomedina

    Joined:
    Sep 10, 2018
    Posts:
    3
    @GerodruS I have the same problem lol, have you find any solution to it?
     
  10. stevenchan_playstudios

    stevenchan_playstudios

    Joined:
    Mar 1, 2017
    Posts:
    39
    @GerodruS, I also have the same problem.
     
  11. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    Can we use this technique in unity 2019.2 which I believe doesn’t have the unity story board button?
     
  12. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    I'm pretty sure it does. 2018.4 does. I'm pretty sure it has been there for many years. IT JUST NEVER WORKED PROPERLY.
     
    Ianaa and protopop like this.
  13. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    Cool thank you. I’m gonna try it in my next update to make sure I’m up and running without issues before hand
     
  14. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    If you find a way to use a storyboard, that doesn't then fade to grey, or messes up the orientation (or changes orientation randomly), please share your steps, as I don't believe Unity will have fixed the above mentioned issues until the next deadline.
     
  15. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    Yikes! Im kind of scared now:)

    Unity 2019.2 has the storyboard check mark so at least that's there

    Screen Shot 2020-05-09 at 12.55.18 PM.png
     
  16. addsouza

    addsouza

    Joined:
    Jul 20, 2016
    Posts:
    1
    I have the same problem with messed up orientation. I've disabled Portrait mode in my app but for some reason, every once in a while the launch screen will show up in portrait mode. Has anyone found a solution for this?
     
  17. TripleTopping

    TripleTopping

    Joined:
    Jan 22, 2020
    Posts:
    1
    Great post. Does anyone know if this method can also somehow be used to include localization strings into the storyboard? It doesn't seem like localizations are exported with storyboards.
    We are building everything in Unity Cloud Build, so adding this to Xcode manually after the Unity build isn't really an option.
     
  18. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I followed the method kindly given in the original post, but it does seem to work correctly.

    I use Build And Run in Unity to open Xcode, which does a build to my device as expected. On launching the game, it briefly shows a black screen, then my storyboard (which is also brief, my game loads quickly), then the Unity Splash Screen. But once I have stopped the process in Xcode and closed the app on my iPhone (including swiped it away in multitasking), when I open the game again I just get a black screen then the Unity Splash Screen.

    Using:
    Unity 2018.4.16f1
    Xcode 11.3

    Any Suggestions?

    EDIT: I forgot to add. Images.xcassets has my image set, but also "LaunchImage", which has black screens.

    EDIT 2: I can now get it to work using the method in the pinned thread about this subject, but I would prefer to use this method if possible.
     
    Last edited: Jun 20, 2020
  19. oya_sum

    oya_sum

    Joined:
    Mar 6, 2018
    Posts:
    1
    I suffer from the same probrem.

    I wrote the following code right after startup, which improved on iPhone 7.

    Screen.autorotateToPortrait = false;
    Screen.autorotateToPortraitUpsideDown = false;
    Screen.autorotateToLandscapeLeft = true;
    Screen.autorotateToLandscapeRight = true;

    But, on iPhone X, half of the screen became black. I think this response is wrong because it became a strange bug behavior.

    I want solution...

    Using:
    Unity 2019.4.0f1
    Xcode 11.3.1
     
    ohbashunsuke likes this.
  20. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Im getting this error after build, on Unity 2020.3.8 , also was getting it on Unity 2019.4
    This error doesn't make the unity build fail by the way.
    If I do as instructed there and go to the LaunchScreen file and check the 'Use as Launch screen', this error doesn't appear anymore on Unity build but I get a build error later on Xcode 12 telling me to uncheck that same checkbox.

    So either Unity or Xcode complains about that checkbox, seems unity wants that checked but Xcode wants it unchecked.

    Unity 2020.3.8
    MacOSX Big Sur 11.3.1
    iOS Build


    Anybody ? any hint?
    Thanks in advance.
    pistoleta
     
  21. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,623
    >>but I get a build error later on Xcode 12 telling me to uncheck that same checkbox.
    I do not see this localy, you should bug report with small repro project attached
     
  22. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    So the problem is on Unity's side? I mean, what's the correct setup of that checkbox in the launchscreen file? I maybe should have mentioned I'm using the workspace file in Xcode instead of the default project file since Firebase libraries force me to do so. Not sure if has something to do.
     
  23. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    In Unity Player Settings, go to the Splash Image section, then click to turn on Use Storyboard for Launch Screen. Then you should use the Custom Storyboard option below that to select the LaunchScreen.storyboard you have created, as shown in the video at the start of this thread.

    Use Build (not Build&Run) to create the Xcode project, then open the Workspace file that is created for your game.
     
  24. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Thats exactly how I did it, however the video doesn't say anything about this option:

    As I said, if I don't check it Unity complains with:


    And if I check it (which seems to be the logical option) Xcode says:


    Which is solved by disabling the 'Use as launch screen' checkbox as they say here:
    https://stackoverflow.com/questions/37764156/launch-screens-may-not-set-custom-classnames/37769167

    Thanks for your answers I hope now I explained myself better.
    PS: I ever use Build&Run
     
  25. ajon542

    ajon542

    Joined:
    Oct 22, 2013
    Posts:
    25
    After many hours of trying to figure out some weird scaling issues with the launch screen image when using the settings "Image and background (relative size)" and "Image and background (constant size)", I discover this!

    This solution works perfectly. Thanks!
    Tested with Unity 2020.3.6 and Xcode 12.2.
     
    Marat_Gilyazov likes this.
  26. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    Thanks a ton for this post! I am getting a second or 2 of background color before my splash image shows on iPad only. On iPhone it works like a charm. Is this the status quo or is there something I can do to fix. I have "initial view controller" and "Use as launch screen" checked. Unity 2020.3.17