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.
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: https://www.youtube.com/watch?v=s4skYI4GaOg
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
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):
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
public class CopyXcodeLaunchImageOnPostProcess
{
const string XCODE_IMAGES_FOLDER = "Unity-iPhone/Images.xcassets";
const string SOURCE_FOLDER_NAME = "Splash.imageset";
const string SOURCE_FOLDER_ROOT = "Xcode Storyboard/splash/splash/Assets.xcassets";
[PostProcessBuildAttribute(1)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string sourcePath = $"{SOURCE_FOLDER_ROOT}/{SOURCE_FOLDER_NAME}";
string targetPath = $"{path}/{XCODE_IMAGES_FOLDER}/{SOURCE_FOLDER_NAME}";
FileUtil.DeleteFileOrDirectory(targetPath);
FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
}
}
}
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)
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
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…
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.
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?
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.
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?
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.
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.
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.