I am trying to modularize my iOS project and extract a feature as a module using SPM. This module contains some SwiftUI code that I want to test with Xcode Previews on a real device. The preview works fine when run with the simulator, but when I try to run the code on a real device, I get this strange error:
Failed to launch com.apple.dt.PreviewAgent.iOS
RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed)
|
| BSTransactionError (1):
| ==error-reason: process launch failed
| ==precipitating-error: Error Domain=FBProcessExit Code=64 "The process failed to launch." UserInfo={NSLocalizedFailureReason=The process failed to launch., BSErrorCodeDescription=launch-failed, NSUnderlyingError=0x303985a40 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x3039859e0 {Error Domain=NSPOSIXErrorDomain Code=86 "Bad CPU type in executable" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}
| ==NSLocalizedFailureReason: Transaction failed. Process failed to launch. (process launch failed)
| ==transaction: <FBApplicationProcessLaunchTransaction: 0x300e940e0>
| ==error-description: Process failed to launch.
|
| ==================================
|
| | MessageSendFailure: Message send failure for <ServiceMessage 21: relaunch>
I use the scheme provided by the SPM package. My Package.swift is:
let package = Package(
name: "PackageName",
platforms: [
.iOS(.v16),
],
products: [
.library(
name: "PackageName",
targets: ["PackageName"]),
],
targets: [
dependencies.
.target(
name: "PackageName"),
.testTarget(
name: "PackageNameTests",
dependencies: ["PackageName"]),
]
)
I run the code on a MacBook Pro 2023 with an M2 chip (Xcode 15.4) and test the code on an iPhone 14 Pro (iOS 17.5.1).
I tried changing the Build Settings: Override Architecture and set it to “Use Target Settings,” but this did nothing.
Are previews on real devices supported in SPM packages
P.S.
Cleaning build and removing derived data didn’t help…