Merge Info.plist entries structurally so plugins can declare any value type - #377
Open
gwleuverink wants to merge 4 commits into
Open
Merge Info.plist entries structurally so plugins can declare any value type#377gwleuverink wants to merge 4 commits into
gwleuverink wants to merge 4 commits into
Conversation
…on a parse failure
…e other build helpers
gwleuverink
marked this pull request as ready for review
August 25, 2026 09:56
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 #368.
Thanks to @CodyPChristian for the thorough report. A plugin declaring
SKAdNetworkItems(an array of dicts, required by every ad network) abortednative:run ioswith a TypeError, becauseinjectPlistEntriesbuilt the plist by string concatenation and assumed every value is a string or a list of strings. Tracing that assumption turned up more than the crash:FirebaseAppDelegateProxyEnabled: falseships as<string></string>today and only works because Firebase happens to read an empty string as NOCFBundleURLTypes) landed inside the innerCFBundleURLSchemesarray, since the regex stopped at the first nested</array>NSAppTransportSecurity, or a bool onto any existing key, was silently ignoredresources/ios/Info.plistlost its bools and arrays, and nested keys were hoisted to the top levelPhotos & videoproduced a plist Xcode rejectsThe fix
PlistDocumentreads the plist through the DOM and merges by type: scalars replace, lists union on content, dicts merge key by key, empty arrays and nulls contribute nothing, a type mismatch is replaced by the incoming value. Keys nobody touches keep their original markup byte for byte, and strings are escaped by the DOM.The compiler opens each plist once and merges every source into it in one pass: the plugin's
resources/ios/Info.plist, itsinfo_plistentries, its background modes, and the app-level overrides last so they still win. The regex helpers are gone. Cody's suggestion to emit by type is the direction taken; the regex merge had to go with it, because once plugins can contribute nested structures its non-greedy.*?</array>corrupts them.This is the second run at the problem. #6 went stale with Shane's review open, and that review doubles as the checklist here: indentation follows depth, bools render as Apple's
<true/>, empty arrays stay arrays, integers and reals get their own tags, everything is type-hinted, and the tests assert structure by parsing the output back rather than grepping for key names. Placeholders still only resolve in values, not keys, as before.Two consequences of the union semantics worth knowing. A list never loses items, so a
${PLACEHOLDER}that changes between builds keeps both values until the scaffold is regenerated, the same way an unregistered plugin's keys already linger. And an app-level override replaces a plugin's scalar but unions with its list.Verification
Probe plugin manifest, built on the simulator:
plutil -pon the installed bundle's Info.plist:A second build produced the same plist, so nothing duplicates on rebuild. Unit tests pin the merge rules on
PlistDocument; compiler tests pin that each source reaches both the device and simulator plists. Suite green.Decisions for Simon and Shane
Things the trace surfaced that I left alone because they change behaviour beyond this issue:
native:install --force, and a changed.envvalue for such a plugin never lands either. Pre-existing on main. Either track plugin-contributed keys and drop the ones no longer declared, or document--forceas the way to remove a plugin.compile()returns early unless a plugin has Swift sources,info_plistentries or dependencies, so a plugin whose only iOS data isbackground_modes,entitlementsor aresources/ios/Info.plistfile contributes nothing, silently. This PR makes that plist file meaningful for the first time, so the gate bites harder now. Widening it is a few lines; happy to fold it in here.plugins()that matches no installed package is accepted without a word, sinceisPluginAllowedcompares strings. A warning at discovery time would turn "my plugin does nothing" into a two-minute fix.PropertyListcodec, so merging both as they stand leaves two plist codecs in the package. Whichever lands second should sit on the other's class;PlistDocumentcan take the entitlements merge as-is if first wins is not something you want to keep.