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

Add mergeable libraries support to dynamic libraries #4367

Closed
wants to merge 17 commits into from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Sep 24, 2024

📜 Description

  • Add make_mergable linker flags to supported SDKs

From the ld manual. Opened in a file so it's easier to browse.

man ld | col -b | open -tf
Mergeable Library Options
 -make_mergeable
     Adds additional metadata to a dylib which makes it a mergeable
     library.  It can still be used as a dylib, or can be merged into
     other binaries when they link it with a -merge* option.

Also, users have to build with Xcode >= 15.

When you include your mergeable library in an XCFramework, Xcode adds the key MergeableMetadata to the XCFramework’s Info.plist file to indicate to other projects that your library in the XCFramework is mergeable. You can only use XCFrameworks with mergeable metadata in Xcode 15 and later; in earlier versions, Xcode returns a build error.

💡 Motivation and Context

Users can enable mergable libraries featue for dynamic sentry frameworks.

See https://developer.apple.com/documentation/xcode/configuring-your-project-to-use-mergeable-libraries for more info.

💚 How did you test it?

Closes #3719

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Copy link

github-actions bot commented Sep 24, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 9d7c072

@denrase denrase mentioned this pull request Sep 24, 2024
@denrase
Copy link
Collaborator Author

denrase commented Sep 24, 2024

I'm using Xcode 16.0 (16A242d) on macOS 15.0 (24A335) and i'm currently not able to build an app binary which embeds the frameworks into the app binary. The sample from #4301 is also not working anymore. Also tried on another machine with Xcode 15.1 with the same result.

@denrase
Copy link
Collaborator Author

denrase commented Sep 24, 2024

Turns out just enabling it is not enough, we also have to remove Sentry from the Embedded Frameworks in the sample applications. Just setting to automatic will not remove the framework, but leave it there and also embed it in the app.

@denrase
Copy link
Collaborator Author

denrase commented Sep 25, 2024

Updated the build script. watchos and watchsimulator cant even build if the MERGED_BINARY_TYPE key is present, even if set to none. So we temporarily remove it from the project file using sed.

Very annoying.

This seems kinday finicky to me and adding too much complexity just to have the samples be mergale binaries. We could revert the samples and the Sentry.framework target config from supporting mergeable.

@brustolin @philipphofmann WDYT?

@denrase denrase marked this pull request as ready for review September 25, 2024 09:22
@brustolin
Copy link
Contributor

This seems kinday finicky to me and adding too much complexity just to have the samples be mergale binaries. We could revert the samples and the Sentry.framework target config from supporting mergeable.

Im not sure If I get this.
We dont need the samples to use mergeable binaries if this makes things harder. But we do need at least one Test project for at least one target (iOS most likely) that have mergeable enabled that uses Sentry.

@@ -5417,6 +5418,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MERGEABLE_LIBRARY = YES;
Copy link
Contributor

@brustolin brustolin Sep 25, 2024

Choose a reason for hiding this comment

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

h: We should use the SDK.xcconfig file instead of changing this in the project settings.
This will also help not having the flag for watchOS and tvOS

@@ -16,22 +15,51 @@ generate_xcframework() {
local configuration_suffix="${4-}"
local createxcframework="xcodebuild -create-xcframework "
local GCC_GENERATE_DEBUGGING_SYMBOLS="YES"

local OTHER_LDFLAGS="-Wl,-make_mergeable" # Default value with -make_mergeable flag
Copy link
Contributor

Choose a reason for hiding this comment

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

l: Do we still need this flags after enabling MERGEABLE_LIBRARY in the project settings?

@denrase
Copy link
Collaborator Author

denrase commented Sep 30, 2024

Closed in favor of #4381

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.

Enable "mergeable library" feature
2 participants