-
Notifications
You must be signed in to change notification settings - Fork 215
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
NordicDFU dynamic linking? #501
Comments
@philips77 can you take a look on that? |
So, if you change the library to .dynamic, does this work for you? It fixes the issue? |
Are you referring to this line: Line 17 in 2295212
But we don't specify that parameter, so SPM should be able to link it any way you want, right? |
Correct, but we also need to make ZIPFoundation dynamic. I already opened a issue there.
Yes, it is this line. We need to change to. .library(name: "NordicDFU", type: .dynamic, targets: ["NordicDFU"]), But it will not work unless ZIPFoundation is also dynamic. Regarding SPM should be able to link it anyway. This is the real issue. It looks like it does not. According to this comment on swift forum there is no way of influence that beyond package manifest. See also this comment about possible solutions. For me the only think that worked was making dynamic IOS-DFU-Library and ZIPFoundation. |
@mateusforgi as soon as ZIPFoundation makes their change, either make a PR here or let us know and we'll change it as well. |
@dinesharjani thanks, I will open a pr as soon as they make their change. |
No, no.. that change on our side would force the lib to be dynamically linked. Now it can be linked dynamically or staticly, depending on settings in your project's SPM config. |
I guess you're referring to https://stackoverflow.com/a/70812112 which says that xcode always prefers static linking, right? Unless we specify otherwise. |
@philips77 correct. But as NordicDFU is a dependency from my SDK, this answer from stack overflow does not solve the issue because it assumes I am adding a package to an App. The final user would not add my SDK to their app, NordicDFU would be downloaded by swift package because it is a dependency from my SDK. So the solution of adding to "Frameworks, Libraries, and Embedded Content" does not work. The real issue is that swift package manager does not allow to import a dependency and say how it will be linked, the only way to do that is by saying it on the package manifest. Things that I did and worked.
|
Can we change the linking type to .dynamic?
.library(name: "NordicDFU", type: .dynamic, targets: ["NordicDFU"])
I have a XCFramework, that depends on NordicDFU but it cannot link to NordicDFU at runtime because NordicDFU is not linked with dynamic type.
On apple documentation it says this:
Leave this parameter so Swift Package Manager can choose between static or dynamic linking (recommended).
But on the other part it says this:
A library’s product can be either statically or dynamically linked. It’s recommended that you don’t explicity declare the type of library, so Swift Package Manager can choose between static or dynamic linking based on the preference of the package’s consumer.
It is kind of confusing as it recommends the dynamic linking but It also says to let the type as nil.
https://developer.apple.com/documentation/packagedescription/product/library(name:type:targets:)
Note: ZIPFoundation would need to have dynamic linking too.
The text was updated successfully, but these errors were encountered: