-
Notifications
You must be signed in to change notification settings - Fork 134
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
Swift Package Manager - Add static library variants to allow use inside frameworks #405
Conversation
Hi @bpollman 👋 When we let Swift Package Manager decide on dynamic vs static linking, it fails to choose the correct option. We are aware of "Do not embed -> framework disappears" bug in Xcode and we hoped it would be resolved in the next version but unfortunately it's still there in Xcode 12.4 I created a new iOS app project with 1 framework and 1 app extension target bundled to it. I used The workaroundLink
Now, at compile time the compiler should be able to find symbols in I hope that may help you 🤞 Last resort workaroundAs suggested in a discussion in Swift Forums you may remove Please let me know if that works for you |
Thanks for the great response! Will look into the workaround you mentioned. Another approach that could work would be to present the library both ways, ie:
Hoping that a proper solutions comes with Xcode soon 🤞 |
@bpollman that's a very good idea! can you please go ahead and make this change? then i will merge the PR ✅ I just want to remind you that if you are shipping your framework, your clients will not be able to use |
eadd96f
to
b451e82
Compare
Thanks @buranmert! Changes have been made. With luck these sorts of workarounds won't be necessary by the time we need to ship a framework. |
Package.swift
Outdated
.library( | ||
name: "DatadogStatic", | ||
targets: ["Datadog"]), | ||
.library( | ||
name: "DatadogStaticObjc", | ||
targets: ["DatadogObjc"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Xcode changes its behavior one day, these may end up being linked dynamically
can we please enforce static linking by adding type: .static
explicitly?
.library( | |
name: "DatadogStatic", | |
targets: ["Datadog"]), | |
.library( | |
name: "DatadogStaticObjc", | |
targets: ["DatadogObjc"]), | |
.library( | |
name: "DatadogStatic", | |
type: .static, | |
targets: ["Datadog"]), | |
.library( | |
name: "DatadogStaticObjc", | |
type: .static, | |
targets: ["DatadogObjc"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point. Changes have been made.
…ide nested frameworks
b451e82
to
fc961b7
Compare
What and why?
Datadog cannot be added to a Framework via SPM due to the
dynamic
property being setting inPackage.swift
When adding Datadog using SPM as a package to a framework, the
type: .dynamic
property causes Xcode to insist on embedding the Datadog inside the framework. The Embed Framework step is automatically created and removing, causes Datadog to be removed from the project.Note that with LaunchDarkly, the package only appears in
Link Binary with Libraries
as desired.Debug builds of the project will build and run fine. However, archiving and uploading to TestFlight will succeed but the archive produced is not valid and will crash on launch as the Datadog library is missing
Screenshot
Crash on Launch Log
How?
Removal of the
type: .dynamic
property allows Xcode to choose the right course of action for the project.I am not sure if removing this property will cause issues for other applications but we are currently using ~20 other dependencies via SPM and this is the only one that sets the
dynamic
properly and causes this error.Review checklist