Xcode 15 UIKit 预览版 FailedToLaunchAppError:无法启动错误

问题描述 投票:0回答:1

我尝试在 Xcode 15 中使用 #Preview 宏预览 UIKit 视图,但收到此错误

== PREVIEW UPDATE ERROR:

    FailedToLaunchAppError: Failed to launch
    
    ==================================
    
    |  RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed)
    |  
    |  BSTransactionError (1):
    |  ==error-reason: process launch failed
    |  ==transaction: <FBApplicationProcessLaunchTransaction: 0x600003b287e0>
    |  ==precipitating-error: Error Domain=FBProcessExit Code=64 "The process failed to launch." UserInfo={NSLocalizedFailureReason=The process failed to launch., BSErrorCodeDescription=launch-failed, NSUnderlyingError=0x600000c1ad90 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600000c1aee0 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}
    |  ==error-description: Process failed to launch.
    |  ==NSLocalizedFailureReason: Transaction failed. Process failed to launch. (process launch failed)

我正在尝试在 iPhone 15 上预览代码

import UIKit

final class SomeViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .red
    }
}

@available(iOS 17, *)
#Preview {
    SomeViewController()
}
ios swift uikit preview xcode15
1个回答
0
投票

我们的项目最初无法使用Apple Silicon中的模拟器进行调试,因此无法预览。

将arm64架构从各个目标中排除后: 模拟器可以工作,但

#Preview
仍然无法工作,并给出与您的问题相同的错误消息:无法启动(我很确定我们得到了完全相同的错误)。

尝试各种方法后:

  • 删除didFinishLaunch中的所有代码
  • 删除预览缓存
  • 删除模拟器缓存
  • 删除派生数据
  • 重新启动 Xcode
  • 重新启动Mac

全部失败了,直到我们想起如何使用Rosetta模拟器构建App:

使用Rosetta模拟器作为构建目标并将预览设置为同一设备,奇迹发生了:

对我们来说重要的是: 我们关闭了自动刷新画布以使预览最终正常工作。

希望有帮助🙈

© www.soinside.com 2019 - 2024. All rights reserved.