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

Unity 2017.3.1p3 copies my storyboard to the Xcode project, but there doesn't seem to be a way to include images in an xcassets folder. When I manually add the xcassets in Xcode, the launch screen storyboard appears correctly, but Unity crashes on startup:

Uncaught exception: NSInvalidArgumentException: Storyboard () doesn't contain a view controller with identifier 'unitySplashStoryboard'

0 CoreFoundation 0x21a29b23 + 150
1 libobjc.A.dylib 0x211e6dff objc_exception_throw + 38
2 UIKit 0x267143d9 + 0
3 GameAppName 0x00049ff4 _Z16ShowSplashScreenP8UIWindow + 548
4 GameAppName 0x0006d3cc -[UnityAppController(ViewHandling) createUI] + 2160
5 GameAppName 0x000698f0 -[UnityAppController application:didFinishLaunchingWithOptions:] + 1856

Can someone from Unity please document how to make this work? Thanks!

I'm being a squeaky wheel... perhaps some of these fine Unity folks can shed some light?
@Mantas-Puida @Yury-Habets @Aurimas-Cernius @povilas @JeffDUnity3D

I've been digging into this some more by looking at the Unity source code in XCode. What it looks like to me is that in the SplashScreen.mm code, ShowSplashScreen() wants a UIViewController with ID 'unitySplashStoryboard' so I added that to my storyboard. That fixes the first crash above, but then it crashes in ShowSplashScreen() a few lines later when it calls [_controller create: window] because UIViewController doesn't contain the 'create' selector. It clearly is looking for _controller to be a SplashScreenController instance, but it isn't possible to assign custom classes (like SplashScreenController) to LaunchScreen storyboards, so I don't get how this code is supposed to work?

1 Like

Any help on this @karl_jones ?

[quote=“tessellation”, post:4, topic: 697018]
Any help on this @karl_jones ?
[/quote]
This doesn’t sound familiar. Are you able to file a bug report so I can look into it?

Thanks @karl_jones ! - Yes, I filed a bug, the fogbugz number is 1023109

I included a LaunchScreen.storyboard and xcassets with images for it with the bug post.

Hopefully there's a fix I can make in the IOS Trampoline source (i.e. Classes/UI) so I don't have to wait for an official patch. :)

2 Likes

Hi @karl_jones , did that bug post have enough information?

[quote=“tessellation”, post:7, topic: 697018]
Hi @karl_jones , did that bug post have enough information?
[/quote]
Its with QA at the moment. Looks like they have been discussing it with you via email.

@karl_jones , yes, they've reproduced it and passed it on to the engineers.

1 Like

Out of curiosity, if you make your storyboard controller have a custom class of SplashScreenController with storyboard ID unitySplashStoryboard does it work as expected? I've attached a screen shot for reference.

There were supposed to be some docs for this but they must have fallen through the cracks. I'll see what I can do about that.

3465244--274986--Screen Shot 2017-06-27 at 1.29.26 PM.png

1 Like

[quote=“Masterfalcon”, post:10, topic: 697018]
Out of curiosity, if you make your storyboard controller have a custom class of SplashScreenController with storyboard ID unitySplashStoryboard does it work as expected?
[/quote]

No that doesn’t work because storyboards do not allow custom classes.

Thanks, that would be very helpful!

1 Like

[quote=“tessellation”, post:11, topic: 697018]
No that doesn’t work because storyboards do not allow custom classes.
[/quote]

True, but the view controller instance in your storyboard does allow custom classes.

[quote=“Masterfalcon”, post:12, topic: 697018]
True, but the view controller instance in your storyboard does allow custom classes.
[/quote]

I’m not sure what your point is. If you try to compile with that storyboard using a custom class as a launch screen storyboard, you’ll get an error. My experience is that launch storyboards only work with core classes, like UIViewController. It will not work with a derived custom class.

1 Like

I've done some work on this and your changes to ShowSplashScreen() are absolutely right.

In SplashScreen.mm, ShowSplashScreen() should look like this:

void ShowSplashScreen(UIWindow* window)
{
_controller = [[SplashScreenController alloc] init];

[_controller create: window];
[window makeKeyAndVisible];
}

Further, make sure that iPhone and iPad Launch Screen type is set to None in the Splash Screen section of the PlayerSettings Inspector.

1 Like

Thanks @Masterfalcon - while that fixes the crash, I don't think that's the expected solution because then there's a black screen after this and before the Unity Splash screen. I noticed there is code elsewhere in the Unity IOS startup code (I don't recall where at the moment) - where it tries to display the storyboard. This is a good thing as I think it's trying to avoid having a black screen by displaying the Launch Storyboard again. However, I believe this code to display the Launch Storyboard again is broken. The fix above avoids this code, but that is not ideal.

Also there's no way to have xcasset images with your Storyboard. Unity needs to find and copy those associated assets to the IOS (XCode) project folder and add it to the XCode solution/project file.

[quote=“tessellation”, post:15, topic: 697018]
Thanks @Masterfalcon - while that fixes the crash, I don’t think that’s the expected solution because then there’s a black screen after this and before the Unity Splash screen. I noticed there is code elsewhere in the Unity IOS startup code (I don’t recall where at the moment) - where it tries to display the storyboard. This is a good thing as I think it’s trying to avoid having a black screen by displaying the Launch Storyboard again. However, I believe this code to display the Launch Storyboard again is broken. The fix above avoids this code, but that is not ideal.

Also there’s no way to have xcasset images with your Storyboard. Unity needs to find and copy those associated assets to the IOS (XCode) project folder and add it to the XCode solution/project file.
[/quote]

Which other code do you see that is a problem?

I think the xcasset bundle thing is a separate issue, I’ll it discuss with the team.

Sorry, in that method ShowSplashScreen, it creates the view controller from the storyboard to avoid that black screen. Elsewhere above in the SplashScreen class, it checks if the storyboard is being used and it doesn't show the Launch Images or "nib" file alternative. If you remove that code as you suggest in ShowSplashScreen, then you get black after the Storyboard launch screen, which looks bad.

[quote=“tessellation”, post:17, topic: 697018]
Sorry, in that method ShowSplashScreen, it creates the view controller from the storyboard to avoid that black screen. Elsewhere above in the SplashScreen class, it checks if the storyboard is being used and it doesn’t show the Launch Images or “nib” file alternative. If you remove that code as you suggest in ShowSplashScreen, then you get black after the Storyboard launch screen, which looks bad.
[/quote]

I’m facing the same problem. Changing ShowSplashScreen as Masterfalcon mentioned above works (application is booting again) but it does not look good because it is immediate fading to black.

I actually have a fix for that as well. I'm attaching a diff that you can apply to SplashScreen.mm to fix both issues.

3476402--276316--SplashScreen.mm.diff.zip (1.64 KB)

3 Likes

Any ETA when it will be in the release versions?
[quote=“Masterfalcon”, post:19, topic: 697018]
I actually have a fix for that as well. I’m attaching a diff that you can apply to SplashScreen.mm to fix both issues.
[/quote]

1 Like