I noticed that in Xcode 15.0, xcodebuild command to archive the app fails unless I remove the #Preview macro from the app.
$ xcodebuild archive -scheme <Your Scheme> -sdk iphoneos -allowProvisioningUpdates -archivePath build.xcarchive
and the error is:
{
"kind": "finished",
"name": "compile",
"pid": 42409,
"output": "<unknown>:0: warning: compiler plugin not loaded: '\/Applications\/Xcode-15.0.0-Release.Candidate.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/usr\/bin\/swift-plugin-server; fai
led to initialize\n\/Users\/xyz\/Dev\/experiments\/fastlane-test\/fastlane-test\/ContentView.swift:22:1: error: external macro implementation type 'PreviewsMacros.SwiftUIView' could not be found for macro
'Preview(_:body:)'\n#Preview {\n^\nSwiftUI.Preview:2:41: note: 'Preview(_:body:)' declared here\n@freestanding(declaration) public macro Preview(_ name: String? = nil, body: @escaping @MainActor () -> View) = #ex
ternalMacro(module: \"PreviewsMacros\", type: \"SwiftUIView\")\n ^\n",
"process": {
"real_pid": 42409
},
"exit-status": 1
}
** ARCHIVE FAILED **
How to reproduce:
If I comment out the default #Preview statement in the ContentView.swift, the same command passes flawlessly. What am I missing?
I think the problem is that your Terminal is running in Rosetta (i386) mode.
You can test this out by running
> arch
which will probably return
i386
To switch architectures:
> arch -arm64 /bin/zsh
then
> arch
should show
arm64
Then your xcodebuild should work as expected
You can also check the info on your Terminal app and it'll probably be set to "Open using Rosetta":

For the record. This problem stopped reproducing with Xcode 15.3 and no longer occurs with later versions of Xcode, so it was most likely a bug in older Xcode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With