fix(ios): settle the build number before bundling the app - #406
Open
CodyPChristian wants to merge 1 commit into
Open
fix(ios): settle the build number before bundling the app#406CodyPChristian wants to merge 1 commit into
CodyPChristian wants to merge 1 commit into
Conversation
An iOS build stamps its self-update identity before it knows its build
number, so every uploaded build ships an identity describing the PREVIOUS
build and devices never re-extract app.zip.
handle() called bundleLaravelApp() first. That runs createAppZip(), which
writes bundled.version and seals the .env carrying
NATIVEPHP_APP_VERSION_CODE, both read from the config as it stands at that
moment. Only afterwards did configureXcodeProject() -> updateBuildNumber()
resolve the real number from App Store Connect and stamp
CURRENT_PROJECT_VERSION.
The two therefore disagree in the artifact. From a build uploaded to
TestFlight:
CFBundleVersion 7 <- what App Store Connect sees
CFBundleShortVersionString 1.0
bundled.version 1.0b2 <- what decides re-extraction
app.zip .env NATIVEPHP_APP_VERSION_CODE=2
The upload succeeds because CFBundleVersion is new. On launch
AppUpdateManager.shouldUpdateWithVersion() compares bundled.version against
the installed identity, finds 1.0b2 unchanged, and skips the update — so the
device runs the previously extracted PHP. Testers install a new build, see
the old app, and can only fix it by deleting and reinstalling. Nothing
reports an error at any point.
Android is unaffected and shows the intended order: PackageCommand calls
updateBuildNumberFromStore('android') before buildAndroid() writes the
bundle. An .aab and .ipa from the same session confirm it — the .aab
contains 1.0b7 against versionCode 7, the .ipa 1.0b2 against
CFBundleVersion 7.
updateAppVersion() and updateBuildNumber() now run in handle() before
bundleLaravelApp(), under the existing NATIVEPHP_XCODE_BUILD guard, and are
no longer called from configureXcodeProject(). Each still runs exactly once,
so the non-store path cannot double-increment. Nothing else moves: the
Xcode project is still stamped from the same resolved value, just after the
zip rather than before it.
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.
An iOS build stamps its self-update identity before it knows its build number, so every uploaded build ships an identity describing the previous build and devices never re-extract
app.zip.What happens
handle()callsbundleLaravelApp()first. That runscreateAppZip(), which writesbundled.versionand seals the.envcarryingNATIVEPHP_APP_VERSION_CODE— both read from the config as it stands at that moment. Only afterwards doesconfigureXcodeProject()→updateBuildNumber()resolve the real number from App Store Connect and stampCURRENT_PROJECT_VERSION.The artifact
From a build uploaded to TestFlight:
CFBundleVersion7— what App Store Connect seesCFBundleShortVersionString1.0bundled.version1.0b2— what decides re-extractionapp.zip→.envNATIVEPHP_APP_VERSION_CODE=2The upload succeeds because
CFBundleVersionis new. On launch,AppUpdateManager.shouldUpdateWithVersion()comparesbundled.versionagainst the installed identity, finds1.0b2unchanged, and skips the update — so the device runs the previously extracted PHP.The symptom in the field is that testers install a new TestFlight build, see the old app, and can only fix it by deleting and reinstalling. Nothing reports an error at any point, on either side, which is what makes it hard to attribute.
Android is unaffected, and shows the intended order
PackageCommandcallsupdateBuildNumberFromStore('android')beforebuildAndroid()writes the bundle, andupdateBuildNumberFromStore()refreshes the runtime config as well as.env— soPreparesBuildstamps the correct identity.An
.aaband.ipaproduced in the same session confirm the asymmetry:.aab1.0b7✅.ipa1.0b2❌The change
updateAppVersion()andupdateBuildNumber()now run inhandle()beforebundleLaravelApp(), under the existingNATIVEPHP_XCODE_BUILDguard, and are no longer called fromconfigureXcodeProject().Each still runs exactly once, so the non-store path cannot double-increment. Nothing else moves — the Xcode project is stamped from the same resolved value, just after the zip instead of before it.
Verifying
After building with
--release --upload-to-app-store, the identity should match the build number:bundled.versionshould equal{CFBundleShortVersionString}b{CFBundleVersion}. Before this change it does not.