I am converting an existing Xcode project (framework) into a Swift package. The project must be built using whole module optimization (WMO) otherwise it cannot build (specifically it must compile using whole module).
Steps so far in converting to use SPM: added Package.swift manifest to the root of the framework project, set target paths to custom sources folders, pushed the project to Github and to test this, added the Swift package as a dependency to a local app project. Problem: The package will not build when I build the app project. (The build error is the usual error I get when not using WMO.) This is true even if the containing app project is configured to use whole module compilation.
It seems adding
swiftSettings:[.unsafeFlags(["-whole-module-optimization"])] to the manifest file would resolve this, but SPM appears to not allow this setting for published packages: "Error: The package product cannot be used as a dependency of this target because it uses unsafe build flags."
So my question is: How do I get a published Swift package to build using whole module compilation?
(Note: I believe Cocoapods supported this by adding the flag via
pod_target_xcconfig setting in the podspec, but I don't see a way to do this with SPM.)