Xcode cannot generate Swift UI preview - build aborted due to an internal error: planningFailed
Xcode cannot generate Swift UI preview - build aborted due to an internal error: planningFailed
我正在使用 Xcode 12 beta 2。我将我的库打包在 Swift 包中。出现在错误消息中的 DataModel
就是其中之一,我当前的包 WeatherView
取决于它。
我可以很好地构建包,但是 Swift UI 预览失败
build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
----------------------------------------
SchemeBuildError: Failed to build the scheme "WeatherView"
unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
Build system information:
error: unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
我发现使产品库“动态”(而不是静态)使我的预览在包的目标内部工作。
let package = Package(
name: "Modules",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "Modules",
type: .dynamic,
targets: ["App"]
),
],
dependencies: [],
targets: [
.target(
name: "App",
dependencies: []
),
.testTarget(
name: "AppTests",
dependencies: ["App"]
),
]
)
还必须声明包的平台。
我在尝试预览我的 SwiftUI canvas 视图时遇到了同样的错误。我在 Xcode 中打开了多个选项卡。我关闭了所有其他选项卡,但我的视图和我的 canvas 预览又开始工作了。
我正在使用 Xcode 12 beta 2。我将我的库打包在 Swift 包中。出现在错误消息中的 DataModel
就是其中之一,我当前的包 WeatherView
取决于它。
我可以很好地构建包,但是 Swift UI 预览失败
build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
----------------------------------------
SchemeBuildError: Failed to build the scheme "WeatherView"
unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
Build system information:
error: unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
我发现使产品库“动态”(而不是静态)使我的预览在包的目标内部工作。
let package = Package(
name: "Modules",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "Modules",
type: .dynamic,
targets: ["App"]
),
],
dependencies: [],
targets: [
.target(
name: "App",
dependencies: []
),
.testTarget(
name: "AppTests",
dependencies: ["App"]
),
]
)
还必须声明包的平台。
我在尝试预览我的 SwiftUI canvas 视图时遇到了同样的错误。我在 Xcode 中打开了多个选项卡。我关闭了所有其他选项卡,但我的视图和我的 canvas 预览又开始工作了。