Search Unity

Can't get LaunchScreen.storyboard to work! Need docs.

Discussion in 'iOS and tvOS' started by tessellation, Apr 3, 2018.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Not much, and it has been there for years, and it's still a buggy mess.
     
    Numa likes this.
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    Is this the button? (I'm using the same version as you)
    BTW This setting is all I have been using to set the launch screen storyboard and it has been working just fine.

    QQ20200422-114337@2x.png
     
    Last edited: Apr 22, 2020
  3. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    Oh ok @Neonlyte that gives me hope! If you select "Replace" when making a new build does it copy the storyboard file to your xcode project and sets it as the launch screen?

    It doesn't do any of that for me. Also, does it bypass the quick grey splash screen between yout storyboard and your app launching? Or is that an unavoidable Unity quirk?

    One more question, how did you create the storyboard?

    If I set my storyboard manually, I see:
    - Storyboard (simple white screen in my case)
    - grey screen (which is the default images Unity generates by default if you don't set any launch images, even if I check the "Use storyboard" box)
    - App launches.

    Maybe there's something I need to clear in my project to make Unity realise I don't want to use the launch images anymore?
    I noticed that ticking the storyboard box just hides the rest of the launch screen settings but doesn't actually clear anything. I cleared all this manually but it looks like you could have a logo animation + background, a launch screen, and a storyboard at the same time.
     
    Last edited: Apr 23, 2020
  4. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    Yes
    If you can see your white storyboard first, that means it is working. If you are not sure, you can always delete the LaunchImage image set from Images.xcassets and clear the "Asset Catalog Launch Image Set Name" build settings (see below) and then see if you can still see the dark grey screen when you run. My gut is that the second dark grey screen you see is rendered by Unity after the storyboard disappeared, though I have never seen anything like that in my project, and I am not doing anything special.
    upload_2020-4-22_23-25-4.png
    The launch animation is not related to the iOS launch screen as it is rendered by Unity after the app is considered launched by the OS.
    If an Xcode project has both Launch image set and a LaunchScreen storyboard, Xcode would use the one specified in the project settings. Do note that Unity would rename copied storyboard to LaunchScreen.
    upload_2020-4-22_23-28-53.png
     
  5. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    It turns out you can't have a space in the storyboard name or Unity will ignore the whole thing!
    As soon as I removed the space the storyboard was copied to the project and set properly. It's very unfortunate that the default storyboard created by XCode has a space in it.

    I then applied Zilppuri's fix to support orientation and now I'm all good.

    Thanks so much!
     
    Petr777 likes this.
  6. benbenmushi

    benbenmushi

    Joined:
    Jan 29, 2013
    Posts:
    34
    Zilppuri fix is brilliant and fix the main orientation issue with unity 2017.4.

    But since 2017.4.38 unity introduced this:
    "iOS: Launch Screen storyboards are validated to ensure that they have the correct settings to be used as a launch screen."

    This validation break Zilppuri fix...

    Now in order to succesfully build an xcode project with unity with a custom storyboard, you need the storyboard to contain both:
    - launchScreen="YES" in its document properties
    - a custom ViewController Class (the one who fixes that unity orientation issue)

    But Xcode will not compile the storyboard if it has the two.
    I now have this during my xcode archive process:
    "Builds/iOS/LaunchScreen.storyboard:Bqq-lu-R9T: error: Launch screens may not set custom classnames"


    I dont know why unity introduced this kind of requirement.
    I noticed no incorrect behaviour on a LaunchScreen storyboard without the launchScreen="YES" property (I might have miss something here).

    Now I may add another post-process to remove the launchScreen="YES" after unity has done its verification. But it only add more complexity on an already messy workaround.
     
  7. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    That particular launchScreen="YES" check is to adhere to Apple's semantics, as launch screen storyboard must be marked as such, and must not contain any custom logic (no animation via code etc). Setting to NO may work now, but not necessarily in the future.
     
    benbenmushi likes this.
  8. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    Attaching the storyboard I am using in my project as a reference.
     

    Attached Files:

  9. unity_NXKZmenm0Rh4aA

    unity_NXKZmenm0Rh4aA

    Joined:
    May 13, 2020
    Posts:
    1
    Hi guys,
    Im on Unity 2017.4.20f2 and trying to migrate to launch screen storyboard due to Apple deadline.
    Im using custom storyboard from ios player settings in unity and the launch screen appears.
    The issue is my app is landscape right/left only and when i hold the device in portrait,the launch screen comes up in portrait .
    Note:my app comes up in only landscape as expected after the launch screen.
    Is there something im missing?
     
  10. benbenmushi

    benbenmushi

    Joined:
    Jan 29, 2013
    Posts:
    34
    In my previous post I explaned how unity 2017.4.38f1 broke our storyboard implementation based on Zulppuri fix.
    The Apple deadline is comming and we dont have many choices beside downgrading our unity version.

    This is not perfect but at least we should not be rejected by apple...
    https://developer.apple.com/ios/submit/ => "Starting June 30, 2020, app updates must use an Xcode storyboard to provide the app’s launch screen."

    Here is a summary of what we did to make it work correctly on Unity 2017.4.27f1:
    (We use a single image as our splash screen)
    (Most (all?) of this come from Zulppuri fix)
    Every files are available here:
    https://gist.github.com/bhallionOhbibi/a2385077fe9b5e3013817f39055127bb
     
  11. WermHat

    WermHat

    Joined:
    Jul 13, 2012
    Posts:
    88
    Hopefully Unity has addressed this in the next (and last) 2017 LTS release
     
  12. Callum-Abele_Lockwood

    Callum-Abele_Lockwood

    Joined:
    Jan 7, 2020
    Posts:
    1
    I am also experiencing the same orientation issues already discussed by other developers on this thread.

    For reference I am currently testing on 2018.4.23f but this issue has been present on older versions (so far I have checked 20f 16f and 11f)

    The app I work on is designed to work only in landscape orientation, however if I launch the app holding a device in a portrait orientationthe UnityAppController.mm allows this resulting in a skewed user interface. This persists in the app until a new landscape orientation change. After this I can no longer rotate to portrait again.

    This only occurs when I attempt to use a Storyboard as a launch screen.

    I'm aware there is a work-around to this issue documented here

    https://issuetracker.unity3d.com/is...53.489444515.1591105626-1777745623.1590666203

    Commenting out lines 159-177 in UnityAppController.mm, this does solve my issue but its not a long term solution

    With the impending Apple deadline at the end of June can we please have a proper fix for this?
     
  13. benbenmushi

    benbenmushi

    Joined:
    Jan 29, 2013
    Posts:
    34
    Hello fellow developers,

    Today I tried to build our game with the lastest 2017.4.40f1 which include:

    Improvements
    • iOS: Changed builtin xib launch screens to storyboard

    I did the build with a regular storyboard including the default view controller and the property launscreen="YES"
    The bug is still present...
    When launching the app while maintaining the device on vertical position. The screen is still rotating to portrait mode right before the game is displayed. Resulting in a very poor and unpolished user experience...
    This is a bit better from the previous version but still not OK.

    Has anyone tried it ? Has anyone had success ?
     
  14. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    I'm still having the orientation bug with 2019.4.0f1, but the double storyboard +custom script workaround discussed here works for now.
    However Unity is now giving me an error after the build saying that LaunchScreen.storyboard isn't set as launch screen (we can't set it as launch screen since it uses a custom class which is not allowed), but the app runs fine.
     
  15. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Does the fade to gray also happen?
     
  16. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    @AcidArrow Sorry for the late reply!
    It looks like that problem has been resolved, so if your app is just using portrait orientation I think you should be good. The release notes for Unity 2020 also mentions that they've fixed the bug forcing you to name your storyboard "LaunchScreen", but I don't think that was backported to 2019.4
     
  17. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Thanks for the reply.

    Our game is Landscape only, so looking forward to struggling with getting storyboard to orient itself properly.
     
  18. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    that's a side-effect of apple not allowing "launch screen" storyboards to have custom view controller, as the default one allows all orientations. On the bright side: they added the possibility to override view controller in ios13 and we are working on using this (and backporting, sure)
     
  19. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Does that mean it will only work correctly on iOS 13 only?

    Does the launch storyboard not respect UISupportedInterfaceOrientations settings in info.plist?
     
    ArtyBrest likes this.
  20. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    >>Does the launch storyboard not respect UISupportedInterfaceOrientations settings in info.plist?
    nope - but thats on apple
    >>Does that mean it will only work correctly on iOS 13 only?
    if, by "correctly", you mean "adhere to what you set up in unity in regard to orientations or status bar or whatever-i-forgot", then yes - pre ios13 it will rotate (well, at least thats how i remember it).

    in case: I just retested the fix with ios13 device and it works fine with landscape only app on iphone held vertically.
     
    AcidArrow likes this.
  21. Pincape

    Pincape

    Joined:
    Dec 4, 2018
    Posts:
    5
    I'm quite disappointed that this wasn't fixed before the Apple deadline and now we need to start implementing workarounds ourselves to be able to submit iOS builds! Just tested this on Unity 2019.4.2 and 2018.4.23 and still not working!
     
    PandaArcade likes this.
  22. qmpaden

    qmpaden

    Joined:
    Feb 2, 2019
    Posts:
    9
    Serious Bug in Unity: All of the IOS, Apple TV, and devs on my team are unable to build due to Unity not properly creating the new spec for Launchscreen.storyboard, or adhering to the xcode project storyboard build implementation for Apple Devices.

    Also, the 2020 builds arent recognizing the new Metal implementation in the builds they create now for some reason.. something to do with Apple new Arm64 builds and a huge issue with Unity creating the Game Center capability in xcode project builds..

    Unfortunately because of this, we have to stop our updates to IOS and Apple's App Store this month until a bug fix comes through for 2019.4 LTS or 2018.4 LTS.

    Diving into Xcode to solve the launchscreen storyboard issue is very troubling for our studio due to the nature of how much we create new ios updates and builds.. please help us Unity :'(
     
    ArtyBrest and PandaArcade like this.
  23. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    @Alexey Just tried this with 2020.1.0f1, iOS13 13.5.1
    The orientation bug is still there (for a landscape app, the splash screen is displayed properly at first, but then it switches to a cropped portrait one). Earlier you said it worked fine on iOS13, am I missing something?

    I thought this would have fixed the issue, but maybe it's something else?
    iOS: On iOS13 it is now possible to customize launchscreen viewcontroller, so it will adhere to unity settings for statusbar appearance and enabled orientations. (1253671)

    Also, the double storyboard trick explained in this post doesn't work anymore no 2020.1. The app crashes on startup with this error:
    Uncaught exception: NSInternalInconsistencyException: Custom instantiated <UnityViewControllerStoryboard: 0x14fbc5980> must be kind of class CustomSplashViewController

    Is there anything we can do besides downgrading to 2019.4 and doing the storyboard swap?

    Thanks for your help
     
  24. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    oooh i see. We always try to instantiate storyboard with our view controller, so if you had your own custom view controller class set in storyboard it will fail like that. On the other hand "launch screen" storyboard forbid setting custom viewcontroller class. So i am not sure how this happens. Can you submit a bug with a small repro project?

    Dunno, i never saw this bug resurfacing. Can you submit a bug with small repro and more details (like device you tested on)
     
    Last edited: Aug 3, 2020
  25. unity_grJWwPgd0nddEA

    unity_grJWwPgd0nddEA

    Joined:
    Feb 4, 2020
    Posts:
    16
    I'm seeing the same issue as well, splash screen displayed properly at first, then shows the wrong orientation if you have the portrait rotation lock on the device.

    And on old iOS, my app its crashing at the first run
     
    Numa likes this.
  26. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    On pre-iOS 13 this is expected. On iOS 13+ we have found yet another issue and the fix is in testing/backporting. I will post the solution here (it is trampoline only fix) if someone needs that urgently
     
    Numa likes this.
  27. unity_grJWwPgd0nddEA

    unity_grJWwPgd0nddEA

    Joined:
    Feb 4, 2020
    Posts:
    16
    Ow nice! Do you have any ETA on this? And this will be on the 2019 LTS?
     
  28. zappra

    zappra

    Joined:
    Feb 23, 2020
    Posts:
    1
    I'm also experiencing this issue, it's the first time I've tried to implement storyboards. My app supports auto rotation in landscape mode. If I launch the app in portrait orientation the splash screen glitches really badly right before the game becomes active. It looks dreadful!

    Unity 2020.1.1f1

    Are there any workarounds? This is blocking me releasing an update.

    Edit: I tried the suggested workaround here which worked

    https://issuetracker.unity3d.com/is...9.1123632818.1596874679-1934427731.1537615412
     
    Last edited: Aug 9, 2020
    unity_grJWwPgd0nddEA likes this.
  29. unity_grJWwPgd0nddEA

    unity_grJWwPgd0nddEA

    Joined:
    Feb 4, 2020
    Posts:
    16
    If anyone is needing an urgent fix, this indeed does the trick:


    On the file: UnityAppController+ViewHandling.mm comment out the line [_window makeKeyAndVisible]; on the createUI method.

    Code (JavaScript):
    1. - (void)createUI
    2. {
    3.     NSAssert(_unityView != nil, @"_unityView should be inited at this point");
    4.     NSAssert(_window != nil, @"_window should be inited at this point");
    5.  
    6.     _rootController = [self createRootViewController];
    7.  
    8.     [self willStartWithViewController: _rootController];
    9.  
    10.     NSAssert(_rootView != nil, @"_rootView  should be inited at this point");
    11.     NSAssert(_rootController != nil, @"_rootController should be inited at this point");
    12.  
    13.     //[_window makeKeyAndVisible]; <- COMMENT OUT THIS LINE.
    14.     [UIView setAnimationsEnabled: NO];
    15.  
    16.     // TODO: extract it?
    17.  
    18.     ShowSplashScreen(_window);
    19.  
    20. #if UNITY_SUPPORT_ROTATION
    21.     // to be able to query orientation from view controller we should actually show it.
    22.     // at this point we can only show splash screen, so update app orientation after we started showing it
    23.     // NB: _window.rootViewController = splash view controller (not _rootController)
    24.     [self updateAppOrientation: ConvertToIosScreenOrientation(UIViewControllerOrientation(_window.rootViewController))];
    25. #endif
    26.  
    27.     NSNumber* style = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"Unity_LoadingActivityIndicatorStyle"];
    28.     ShowActivityIndicator([SplashScreen Instance], style ? [style intValue] : -1);
    29.  
    30.     NSNumber* vcControlled = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"UIViewControllerBasedStatusBarAppearance"];
    31.     if (vcControlled && ![vcControlled boolValue])
    32.         printf_console("\nSetting UIViewControllerBasedStatusBarAppearance to NO is no longer supported.\n"
    33.             "Apple actively discourages that, and all application-wide methods of changing status bar appearance are deprecated\n\n"
    34.         );
    35. }

    and on the class SplashScreen.mm make the OrientationMask _supportedOrientations; public by adding the @Public in front of it:

    Code (JavaScript):
    1. @implementation SplashScreenController
    2. {
    3.     @public OrientationMask _supportedOrientations;
    4. }
    And changing adding the following lines to the method ShowSplashScreen :
    Code (JavaScript):
    1. UIView* storyboardView = _controller.view;
    2.         _controller.view = nil;
    3.         _controller = [[SplashScreenController alloc] init];
    4.         _controller.view = storyboardView;
    5.         _controller->_supportedOrientations = { false, false, true, true }; //Portrait, PortraitUpSideDown, LandscapeRight, LandscapeLeft

    Code (JavaScript):
    1. void ShowSplashScreen(UIWindow* window)
    2. {
    3.     NSString* launchScreen = [[NSBundle mainBundle].infoDictionary[@"UILaunchStoryboardName"] stringByDeletingPathExtension];
    4. #if PLATFORM_IOS
    5.     // since launch images are no longer supported on ios we MUST have UILaunchStoryboardName filled
    6.     assert(launchScreen != nil && @"UILaunchStoryboardName key is missing from info.plist");
    7. #endif
    8.  
    9.     const bool hasStoryboard = launchScreen != nil && [[NSBundle mainBundle] pathForResource: launchScreen ofType: @"storyboardc"] != nil;
    10.     if (hasStoryboard)
    11.     {
    12.         UIStoryboard *storyboard = [UIStoryboard storyboardWithName: launchScreen bundle: [NSBundle mainBundle]];
    13.  
    14.         _controller = [storyboard instantiateInitialViewController];
    15.        
    16.         //Add the following lines:
    17.         UIView* storyboardView = _controller.view;
    18.         _controller.view = nil;
    19.         _controller = [[SplashScreenController alloc] init];
    20.         _controller.view = storyboardView;
    21.         _controller->_supportedOrientations = { false, false, true, true }; //Portrait, PortraitUpSideDown, LandscapeRight, LandscapeLeft
    22.        
    23.         window.rootViewController = _controller;
    24.     }
    25.     else
    26.     {
    27.         _controller = [[SplashScreenController alloc] init];
    28.         [_controller create: window];
    29.     }
    30.  
    31.     [window makeKeyAndVisible];
    32. }
    33.  
     
  30. stevenchan_playstudios

    stevenchan_playstudios

    Joined:
    Mar 1, 2017
    Posts:
    39
    It works, Unity please back port to Unity 2019.4 LTS please.

     
  31. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    I think the latest LTS should have all the fixes
    as a side note:
    we did things differently but this could help too, indeed
    in the latest LTS we did similar thing, too (well, in a less hacky way, but oh well)
     
  32. unity_grJWwPgd0nddEA

    unity_grJWwPgd0nddEA

    Joined:
    Feb 4, 2020
    Posts:
    16
    Just tested with 2019.4.8f1 and still not fixed.
    Still see the Portrait Splash Screen for a couple of seconds when opening the app when having the Rotation Locked.
     
  33. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    it should be fixed in 2019.4.9f1 (also please make sure you check on ios13+, or earlier ios we cant do anything and the solution above could be used)
     
  34. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    It seems fixed for me on iOS13 and 2019.4.9f1
     
  35. unity_grJWwPgd0nddEA

    unity_grJWwPgd0nddEA

    Joined:
    Feb 4, 2020
    Posts:
    16
    But does unity plan to fix pre iOS12 behaviour? Or should I keep this fix forever?

    Because I'm still seeing the portrait splash screen in landscape only game for a couple of seconds on iOS13 and unity 2019.4.9f1
     
  36. chico_barnstorm

    chico_barnstorm

    Joined:
    Jun 11, 2014
    Posts:
    10
    In case it helps anyone... We had this very same issue. We were using our own class to fix some of the problems mentioned in this thread. However, the storyboard is now expected to be of type UnityViewControllerBase (somewhere in between Unity2018.4.17f1 and 28f1). Obviously, we were not ticking "Use as Launch Screen" because that doesn't allow custom classes.
    Our fix was to typedef our class as UnityViewControllerBase in iOS13+ for the new behaviour, but keep the old stuff for previous iOS versions. Our class header now looks like this:
    Code (CSharp):
    1. #if (PLATFORM_IOS && defined(__IPHONE_13_0)) || (PLATFORM_TVOS && defined(__TVOS_13_0))
    2. #include "UnityViewControllerBase.h"
    3. typedef UnityViewControllerBase your_custom_class_here;
    4. #else
    5. @interface your_custom_class_here : UIViewController {}
    6. @end
    7. #endif
     
  37. LouisSong

    LouisSong

    Joined:
    Apr 13, 2013
    Posts:
    4
    This works to me.Thank you!