Right now in Defold, I must specify the ios launch images according to a number of resolution.Can Defold possible to specify a launchscreen.storyboard and one image to adapt different ios devices?
You should be able to generate all the launch image size you need using one of these tools:
https://www.appicon.build/
https://apetools.webprofusion.com/
And there are more similar online tools out there of course!
Specifying all the launch images will significantly increase the bundle size.So I want to use one single launch image.
In Xcode, I can set launch screen file:
Well, probably not, it you have a compressed black png file. They’re quite small.
The Defold engine launches very fast, so chances are you’l only see the launch screen flicker quickly before the game starts, and you’ll start rendering yourself.
We do have a ticket (DEF-2995) for supporting storyboards, but we currently don’t have an ETA on it.
In the meantime, it should be possible to use a story board by specifying it in the Info.plist your self. I think @Johan_Beck-Noren did this a few weeks ago?
So what I need to do is leaving all the launch image blank in the game.project, and specify UILaunchStoryboardName in my own info.plist?
As @Mathias_Westerdahl pointed out, we have ticket for this but it’s currently unclear/undecided how we should expose this functionality to our users in a good and clean way.
I have managed to use a storyboard with a bundled Defold game my doing a bunch of stuff manually. It’s not super easy and a lot of things can go wrong. Below is a rough guide how I did it:
1. Create a empty game project in Xcode. Make sure it has a LaunchScreen file and that it is set correctly in the project settings:
2. Modify the LaunchScreen.storyboard file to your liking:
3. Archive the empty Xcode project via Product->Archive.
4. Wait for it to finish archiving. Then right click on the newly created archive and select Show in Finder.
5. Right click the archive in Finder and select Show Package Contents.
6. Navigate to the .app folder under Products/Applications/, right click and select Show Package Contents.
7. Inside Base.lproj are the compiled versions of your LaunchScreen.storyboard. You need to copy the Base.lproj folder (and any other compiled asset that the storyboard needs) to your Defold bundled .app folder.
8. Navigate to your Defold bundled game, select Show Package Contents.
9. Copy+paste the assets described in step 7 into your Defold bundled app.
8. Now you need to update the Info.plist in the Defold bundled app so that it points to the storyboard instead of the static images. Open the Info.plist
file in a text editor and add the following key-value pair:
<dict>
...
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
...
</dict>
9. Finally, you need to sign your app manually, via a terminal. (Please read these commands carefully and understand what’s going on. You will need to replace certain parts of these to cater for your setup and file locations.)
# Navigate to where your bundled app is located
$ cd <PATH_TO_THE_BUNDLED_APP>
# Remove the previous codesignature
$ rm -rf <YOUR_GAME>.app/_CodeSignature
# Generate a entitlement.plist
$ security cms -D -i "<PATH_TO_YOUR_MOBILE_PROVISION_FILE>.mobileprovision" > provision.plist
$ /usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlement.plist
# Copy your mobile provisioning profile into the bundled .app folder
$ cp "<PATH_TO_YOUR_MOBILE_PROVISION_FILE>.mobileprovision" <YOUR_GAME>.app/embedded.mobileprovision
# Do the actual code signing
$ codesign -f -s "iPhone Developer: <Your Name>" --entitlements entitlement.plist <YOUR_GAME>.app
Have you measured this? Is this a case of premature optimization?
I took a King game (total file size 69.9Mb) and checked the size of the orange King logo splash:
- The launch images has a total size of 717Kb
- Black/blank launch images has a total size of 2Kb
The process of adding LaunchScreen storyboard is much simpler now.
- Create Xcode project with desired storyboard.
- Click build.
- Navigate to the DerivedData dir and locate there a compiled version of the storyboard.
- Copy it to the
/res/ios
dir in your Defold project. - Add
/res
as the “Bundle Resources” property in game.project. - Add
UILaunchStoryboardName
to the Info.plist.