Avoid loading xcframeworks as Bundles #3213
Open
+18
−0
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.
(NS)Bundle caches bundles as it loads them, so if a loaded bundle's metadata changes during program execution, it will not be reflected by the Bundle API. Carthage does this when it updates a preexisting XCFramework using
mergeIntoXCFramework(in:settings:)
.This leads to situations where a variant framework inside an XCFramework is "missed" by Carthage and not copied by
extractXCFrameworks(in:for:)
untilcarthage build
is run a second time. For example, consider the following dependencies:When
carthage build --use-xcframeworks --platform iOS,watchOS
with an empty Carthage/Build directory:Carthage/Build/A.xcframework
.A.xcframework
but does not extract anything (becauseA.xcframework
's Info.plist only indicates watchOS variant frameworks).A.xcframework
, and does not extract anything (because, as cached by the system,A.xcframework
's Info.plist only indicates watchOS variant frameworks). Building B fails.If I run
carthage build --use-xcframeworks --platform iOS,watchOS
again, Carthage loads the Bundle forA.xcframework
and sees both the watchOS and iOS variants, so building B succeeds.While there's not an official way to flush the Bundle system's metadata cache, there's a long-standing private CoreFoundation call that does it. We can use that, and assertion-fail in Debug builds if it ever goes away.