I have a library I created with Swift Package Manager, and I'd like to use it in both my Containing App and Safari App Extension.
- I've added the library to the Project using the new "Swift Packages" tab in Xcode.
- The Safari App Extension Target has my library added under "Frameworks and Libraries".
With this configuration I get "Undefined symbol" compiler errors. If I add the library to the App under "Frameworks, Libraries, and Embedded Content", then I get:
"Swift package product '{SWIFT PACKAGE}' is linked as a static library by '{APP NAME}' and '{EXTENSION NAME}'. This will result in duplication of library code."
The odd thing is that the project compiles fine in Xcode 11.3.1. Did something change with SPM in the Xcode 11.4 beta? Maybe I should use a dynamic library? Or am I doing something else wrong?
This appears to be fixed in Xcode 11.4.1. The release notes in feedback assistant say:
Swift Packages
Resolved Issues
Fixed an issue where an error like "Swift package product A is linked as a static library by B and C. This will result in duplication of library code." was incorrectly emitted if an app and an embedded app extension or helper tool statically linked the same package product. If you previously set the
DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC
build setting to work around this issue, you can delete this setting now. (59310009, 61227255)
I wish the communication from Apple was better about things like this. Do I ask about this bug in the SPM section of the Swift.org forums? Probably not, I'd be told that Xcode issues should be posted here. But then nothing really happens. I wish we could just tag teams like @Xcode @SPM to get their attention about issues like this.
Another gripe is that the Xcode 11.4.1 release notes inside the Mac App Store just say "Bug fixes and stability improvements". Why don't they at least mention to check the Feedback Assistant for the full release notes? Since the release notes in the App Store were empty, and the new iPhone SE was released that day, I figured Xcode 11.4.1 was just to add the iPhone SE simulator. It was luck that I tried compiling the project again - and dug deeper looking for actual release notes.
I just feel like this could have easily been resolved before Xcode 11.4 was even released if we had a better way to communicate with people working on these tools.
Anyway, thank you to everyone who offered workarounds.