Since updating to Xcode 11.4, I can't build my mac catalyst app anymore:
multiple configured targets of 'SwiftPackage1' are being created for macOS
I don't find this error message very helpful for what I should do to fix this.
My app has 2 swift packages set to "iOS + macOS" and an iMessage app set to "iOS". Also, if I try to click delete on the swift package, Xcode just crashes instead...
He may not be able to tell you, as an Apple employee. Unless it's fixed in Xcode 11.5 (you should give it a try), we likely won't see a fix until Xcode 12 in the fall, if at all.
I narrowed down the cause further. The bug seems to be that the package is also being used by the iMessage app (even though the iMessage app is not for mac).
Workaround:
Delete the package from the iMessage app, and you can build the Mac app again. Then you can re-add the package to the iMessage app when you build for iOS.
Experiencing the exact same error and landed here (Xcode 11.5). The suggestion to remove the framework from all other targets did work for me though of course it's a very annoying workaround and isn't going to work long term.
I am starting seeing this problem for the first time in Xcode 12 beta 5. My package contains GUI elements, and it is when I try to view the GUI elements in the canvas that the error comes. It builds and runs fine on the real hardware, and also in the simulator.
There is an app and an app clip embedded into the app in my case, both have the same dependency. If the app is build for maccatalyst target - the error occurs. I guess removing the app clip solves the issue as it is not really needed for maccatalyst for now. But yeah, the error message is pretty confusing.
I've encountered this problem with building for previews and it's been much harder to work around in 14.0 than in older releases. In prior Xcodes, I was able to get previews to work with sufficient iterations of deleting DerivedData and dinking around with my package manifest. But I couldn't get it working at all (on my real production project) in Xcode 14.0 with just those actions.
I spent a while trying to find a minimal test case and eventually reduced it to a tiny SwiftPM package named MyPackage containing a single library target, MyLibrary, which includes a single module/target named MyTarget. (You can find my test project here.)
From there, a combination of two things led to the problem:
Having a resource (in my case, a xib) in the module, and
Manually creating the build scheme.
What I found was that an auto-created build scheme works, but the auto-created scheme contains three build targets:
MyLibrary,
MyPackage_MyModule, and
MyModule.
I can build for previews successfully with this scheme. But if I create a scheme manually, I cannot add all three of these targets to its build phase. The only target available to add to its build phase is MyLibrary. And that target alone is not sufficient; building for previews fails with the error “multiple configured targets of 'MyPackage_MyModule' are being created for macOS”.
Apple feedback report FB10114642 includes a video demonstrating the problem, in case anyone at Apple wants to investigate.
I fixed it by cleaning Build Folder, fully exit Xcode and any simulators, reopen xcode and build for simulator again, close the app and go back to Xcode. Once that is complete reopen your canvas and press refresh/start and it should work again. (Assuming it's not an error elsewhere)
Seems like the simulator stores a reference to the package when my mac is put to sleep that is only released when fully exitted.
If you look at the Package+Library+Module scheme in my sample project, you'll see that it has BuildActionEntry stanzas for MyModule and MyPackage_MyModule that are not in the Library-only scheme.
Hey! I have the same problem when i use the new buildtool plugin system for generating assets via SwiftGen. (we took the sample implementation of @abertelrud as a guide)
Basically I have two SPM targets, where in one the assets are generated and a second target which imports the asset target.
If I select the Components scheme in Xcode 14 and want to preview a SwiftUI view the following error
appears.
multiple configured targets of 'SwiftGenPlugin' are being created for macOS
----------------------------------------
SchemeBuildError: Failed to build the scheme "Components"
multiple configured targets of 'SwiftGenPlugin' are being created for macOS
Prepare build:
error: multiple configured targets of 'SwiftGenPlugin' are being created for macOS