Fix iOS LaunchImage Contents.json mixing Any-scale + specific scales#142
Open
barrymortenson wants to merge 1 commit into
Open
Fix iOS LaunchImage Contents.json mixing Any-scale + specific scales#142barrymortenson wants to merge 1 commit into
barrymortenson wants to merge 1 commit into
Conversation
Drop the unscaled splash variants (splash.png, splash-dark.png) when any scaled variant (@2x or @3x) is present so the generated Contents.json contains only specific-scale entries. Xcode's asset compiler rejects Image Sets that mix entries with no `scale` key ("Any" scale) and entries with specific scales when the "Any" entries reference bitmap content: error: Image set has a child with bitmap content and the "Any" scale. The image set also has children with specific scales and content. ** ARCHIVE FAILED ** Simulator builds skip GenerateAssetSymbols so the bug only surfaces on release/archive builds (Bifrost or `xcodebuild archive`). Projects with only unscaled splashes (splash.png ± splash-dark.png) are unchanged — a single "Any"-scale entry on its own is valid. Fixes NativePHP#141.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #141.
What
InstallsSplashScreen::installIosSplashScreen()buildsLaunchImage.imageset/Contents.jsonfrom whichever of six hard-coded splash variants exist inpublic/. The first two (splash.png,splash-dark.png) have noscalekey, so Xcode treats them as"Any"scale. When@2xand/or@3xvariants also exist, the generated Contents.json has a mix Xcode's asset compiler rejects:Simulator builds skip
GenerateAssetSymbolsso the bug stays invisible until a release archive runs the asset compiler. That made it survive in our project until Bifrost's first App Store build hit it.How
If any scaled variant exists, drop the unscaled ones from the candidate set before the existence loop:
Behavior matrix
public/containssplash.png(±-dark)@2xand@3xvariantsThe 1x splash files are effectively ignored when scaled variants are present. iOS handles a missing 1x by downsampling from 2x; no currently-supported iOS device uses 1x scale anyway (the original iPhone is the only 1x device and is unsupported by modern iOS).
Alternative considered
I considered just adding
'scale' => '1x'to the two unscaled entries in$splashVariants. Simpler diff, but it changes the meaning for projects that ship a singlesplash.pngand rely on it being the "Any" fallback across densities —scale: 1xwould constrain it to 1x devices only. The conditional-skip approach in this PR avoids that behavior change.Test plan
@2xand@3xentries; archive succeeds.splash.png(no scaled variants): generated Contents.json contains the single unscaled entry; archive succeeds.tests/Unit/Traits/InstallsAndroidSplashScreenTest.phpcovers Android only). Happy to add anInstallsIosSplashScreenTestin a follow-up if you'd like — the Android test gives a clear pattern to follow.