Swift Package can be MAKE_MERGEABLE?

Hello, I'm Software Engineer and my work is developing SDK.

I'm on developing 1 Swift Package for general logic and 1 SDK (Xcode Framework Project) for business logic. (SDK depends on Swift Package)

Until now, I merge them with @_implementationOnly. And I want to migrate to MAKE_MERGEABLE.

Can I mark Swift Package Dependency as MAKE_MERGEABLE on SDK Xcode Framework Project?

Or can I mark Swift Package MAKE_MERGEABLE on Package.swift?

Or I can't make Swift Package MAKE_MERGEABLE?

Yes, swift packages can be built as mergeable. Though it currently takes more build options than just using an Xcode setting. In the package manifest, you would need to pass -Wl,-make_mergeable in unsafeFlags in the linkerSettings. You also need to ensure the library's type is explicitly set to .dynamic too, otherwise, the build system could default differently.

This also may require setting adding linker options for clients merging the package. For more information, review https://developer.apple.com/documentation/Xcode/configuring-your-project-to-use-mergeable-libraries#Manually-configure-merging

This is not a solution. it failed at the build time with error: "The package product 'MyPackage' cannot be used as a dependency of this target because it uses unsafe build flags."

Unfortunately, it's "NO". Currently, building and distributing the XCFramework is the only way to make your package as mergeable. When you try to configure the linkerSettings to enable MAKE_MERGEABLE, it will failed building w/ error saying "The package product cannot be used as a dependency of this target because it uses unsafe build flags." even though the product was defined as .dynamic

If someone has any good solution, please let me know!

I add local packages via Add Files to project and then add package product in General tab, Frameworks, Libraries section. this way I can add -Wl,-make_mergeable to unsafe flags. Package compilation itself works fine, but main app target fails ld: -make_mergeable can only be used when creating a dynamic library. filed feedback to apple about it https://feedbackassistant.apple.com/feedback/13547751.

Swift Package can be MAKE_MERGEABLE?
 
 
Q