Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed external xcframeworks regardless of linking type #6217

Merged
merged 2 commits into from Apr 22, 2024

Conversation

fortmarek
Copy link
Member

Resolves #6100

Short description πŸ“

This PR supersedes #6182 and #6183. I discussed this issue with @kwridan at SwiftHeroes and we both agreed that the best approach for the missing privacy report is to follow what Apple is doing by embedding xcframeworks. That being said, to minimise the impact this change might have (especially regarding resources), we will be only embedding xcframeworks if they are external.

How to test the changes locally 🧐

Generating privacy report for app_with_spm_dependencies should include GoogleMobileAds

Contributor checklist βœ…

  • The code has been linted using run mise run lint:fix
  • The change is tested via unit testing or acceptance testing, or both
  • The title of the PR is formulated in a way that is usable as a changelog entry
  • In case the PR introduces changes that affect users, the documentation has been updated

Reviewer checklist βœ…

  • The code architecture and patterns are consistent with the rest of the codebase
  • Reviewer has checked that, if needed, the PR includes the label changelog:added, changelog:fixed, or changelog:changed, and the title is usable as a changelog entry

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fortmarek

switch self {
case .macro: return false
case let .xcframework(xcframework):
return xcframework.linking == .dynamic
return xcframework.linking == .dynamic || xcframework.isExternal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, we need to also restrict by xcframework type framework (.framework)

XCFramework Type Result Note
Static Library .a ❌ Embedding simply copies the .a to /Frameworks with all the symbols included
Dynamic Library .dylib βœ… Embedding copies the .dylib to /Frameworks as expected
Static Framework .framework βœ… Embedding copies the .framework to /Frameworks and strips symbols from framework binary
Dynamic Framework .framework βœ… Embedding copies the .framework to /Frameworks as expected

e.g. MyStaticLibrary.xcframework gets processed to a libMyStaticLibrary.a which shouldn't be embed.

It doesn't look like we capture the framework type information in the xcframework metadata - we can base it based on the library extension

Suggested change
return xcframework.linking == .dynamic || xcframework.isExternal
return xcframework.linking == .dynamic || (xcframework.isExternal && xcframework.infoPlist.libraries.first?.path.extension == "framework")

or can uplift this to be a property on the metadata

Suggested change
return xcframework.linking == .dynamic || xcframework.isExternal
return xcframework.linking == .dynamic || (xcframework.isExternal && xcframework.type == .framework)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha πŸ‘ I updated the PR with the first suggestion

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see also the wrong linking for xcframeworks https://github.com/tuist/tuist/pull/6153/files

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe xcframework.linking is just wrong

@fortmarek fortmarek merged commit 3bebe42 into main Apr 22, 2024
8 checks passed
@fortmarek fortmarek deleted the fix/xcfameworks-privacy branch April 22, 2024 15:54
fortmarek added a commit that referenced this pull request Apr 26, 2024
fortmarek added a commit that referenced this pull request Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support privacy manifest files
3 participants