问题
I have a launchscreen with a image, so far working well.
But now I have 3 schemas: dev, hom and prod.
I would to know how to change the launch screen image according the schema selected at the build time?
EDIT
I have in mind two options, but I do not know which one is best:
Option 1: Create two storyboards and create a variable to set the name of the correct storyboard in the app delegate. This variable I will use in the Info.plist key (Launch screen interface file base name).
Option 2: Create two scenes at the Launchscreen.storyboard and programatically set the correct scene according the enviroment.
回答1:
Use targets, add a target for each environment, each target will have its own info.plist and you just set a different launch screen storyboards for each target , set it once in the relevant info.plist and you ready to select any target and run.
回答2:
Your second option definitely won't work, since you cannot execute any code on a LaunchScreen and the LaunchScreen is displayed before any code could be executed (even in your AppDelegate), so you cannot change the LaunchScreen file in runtime.
Your first option is almost correct. Indeed a viable solution could be creating several Storyboards for the different launch screens, but you need to tweak the Info.plist file in a build script, you cannot do this in runtime either. Be aware that I haven' actually tested this method, but in theory it should work.
来源:https://stackoverflow.com/questions/46075804/in-ios-how-to-change-launchscreen-image-according-environment-dev-hom-prod