Exclude PrivacyInfo.xcprivacy resource on Android#1368
Open
colemancda wants to merge 1 commit into
Open
Conversation
Declaring a resource on the SQLite target makes SwiftPM generate a Bundle.module accessor that unconditionally imports Foundation and calls Bundle.main/Bundle(path:), which requires linking all of Foundation (plus FoundationInternationalization and ICU on affected SDKs) even for consumers that otherwise only need FoundationEssentials. PrivacyInfo.xcprivacy only has meaning for the Apple App Store, so this excludes it under a TARGET_OS_ANDROID environment variable, following the same convention swift-android-native uses to detect an Android cross-compile from Package.swift (which always evaluates on the host and has no direct way to see the build destination). No effect on existing consumers since the variable is unset by default.
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.
Summary
resources: [.copy("PrivacyInfo.xcprivacy")]on theSQLitetarget makes SwiftPM auto-generate aresource_bundle_accessor.swiftfile withBundle.module, which unconditionally imports Foundation and callsBundle.main/Bundle(path:).libFoundation.so— and, since it has its own unconditional dependency onlibFoundationInternationalization.so+ ICU there, all three — for consumers who otherwise only needFoundationEssentials.PrivacyInfo.xcprivacyonly has meaning for the Apple App Store, so this excludes it from the target's resources when aTARGET_OS_ANDROIDenvironment variable is set, following the same convention swift-android-native uses to detect an Android cross-compile —Package.swiftalways evaluates on the host, so it has no direct way to see the actual build destination.PrivacyInfo.xcprivacycontinues to ship exactly as before everywhere else.Test plan
swift package dump-package— without the env var,resourcesstill includesPrivacyInfo.xcprivacyTARGET_OS_ANDROID=1 swift package dump-package—resourcesis empty andPrivacyInfo.xcprivacymoves toexcludereadelf -d/nmthatBundle.main/Bundle(path:)no longer appear as undefined symbols