我发现了这个不错的包,它为 watchOS 提供了一个漂亮的日期和时间选择器。我将它添加到我现有的项目中,这是一个带有手表伴侣应用程序的 iOS 应用程序。一旦包被添加到项目中,Xcode 中的预览就会停止工作。
有数百个错误表明某些内容(Binding
、some View
等)仅在 iOS 13.0 或更高版本上可用。我的项目的目标是 iOS 15 和 watchOS 8。该包仅添加到 WatchKit 扩展应用程序中。
该软件包在模拟器或直接在 Apple Watch 上运行时运行良好。如果项目仅包含 watchOS 目标,预览也可以完美运行。
我创建了这个示例存储库,它由一个 iOS 目标和一个 watchOS 目标以及包组成。
许多错误消息之一:
SchemeBuildError: Failed to build the scheme "Package Test watchOS"
'some' return types are only available in iOS 13.0.0 or newer
Compile ButtonStyle+TimePickerView.swift (x86_64):
/Users/raywo/Library/Developer/Xcode/DerivedData/Package_Test_iOS-heeslxxfvaxzergfcrtdrlguftjn/SourcePackages/checkouts/watch-date-picker/Sources/WatchDatePicker/ButtonStyle+TimePickerView.swift:14:50: error: 'some' return types are only available in iOS 13.0.0 or newer
func makeBody(configuration: Configuration) -> some View {
诊断显示预览实际上是在运行 watchOS 8.0 的手表模拟器上尝试的
== SELECTED RUN DESTINATION:
Simulator - iOS 15.0 | iphonesimulator | x86_64 | iPhone 13 | Apple Watch Series 6 - 44mm
Destination Preferences {
platform: iphonesimulator
platformSpecifier: iphonesimulator
deviceName: iPhone 13
deviceSpecifier: com.apple.CoreSimulator.SimDeviceType.iPhone-13
deviceModel: iPhone 13
deviceIdentifier: 15453A84-68A7-4C62-BF92-F3269D9B9CE0
sdkVariant: iphonesimulator
architecture: x86_64
sdkSpecifier: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk
sdkVersion: 15.0
runtimeVersion: 15.0
}
Proxy:
Destination Preferences {
platform: watchsimulator
platformSpecifier: watchsimulator
deviceName: Apple Watch Series 6 - 44mm
deviceSpecifier: 6484338A-3B17-4D28-B88A-2DB5C866DFC9
deviceModel: Apple Watch Series 6 - 44mm
architecture: x86_64
runtimeVersion: 8.0
}
== SESSION GROUP 2953:
workspace identifier: <IDEWorkspace:0x7fddb68dbcf0 path:'/Users/raywo/Dropbox/Projekte/iOS/Package Test iOS/Package Test iOS.xcodeproj/project.xcworkspace'>
providers: [
ContentView_Previews /Users/raywo/Dropbox/Projekte/iOS/Package Test iOS/Package Test watchOS WatchKit Extension/ContentView.swift
]
translation units: [
/Users/raywo/Dropbox/Projekte/iOS/Package Test iOS/Package Test watchOS WatchKit Extension/ContentView.swift
]
attributes: PreviewSettingsRegistry(defaultSettings: PreviewsPipeline.PreviewSettings(isInteractive: false, mirroredDeviceLocations: Set([])), storage: [:])
session: 2954
request sessions: [
Content View Previews | ContentView_Previews: not completed
]
== UPDATE SESSION 2954:
Start Date: Tuesday, 2. November 2021 at 12:58:38 Central European Standard Time
Preview Provider {
Simulator {
platform: watchsimulator
device: 6A6D8E9E-A528-4CD4-A98D-FE855ED7BAC0 Apple Watch Series 6 - 44mm
buildNumber: 19R345
runtimePath: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime
}
}
Build Graph {
target app Package Test iOS.app (#1)
target watchKitApp Package Test watchOS.app (#2)
target watchKitExtension Package Test watchOS WatchKit Extension.appex (#3)
Preview Provider Content View Previews Content View Previews (#4)
translationUnit ContentView.swift (#5)
}
Update Plan {
watchOS [x86_64 iphonesimulator15.0 iphonesimulator w/ proxy] (iPhone 13, 15453A84-68A7-4C62-BF92-F3269D9B9CE0-iphonesimulator15.0-x86_64-iphonesimulator), [], thinning disabled) {
Destination: Apple Watch Series 6 - 44mm 6484338A-3B17-4D28-B88A-2DB5C866DFC9 | default device for watchsimulator [
Run Destination Properties {
platform: watchsimulator
architecture: x86_64
sdk:
SDK {
path: /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator8.0.sdk
version: 8.0
}
runtimeVersion: 8.0
runtimeBuildNumber: 19R345
deviceIdentifier: 6484338A-3B17-4D28-B88A-2DB5C866DFC9
deviceModel: Apple Watch Series 6 - 44mm
deviceSpecifier: com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm
deviceName: Apple Watch Series 6 - 44mm
}
Package_Test_watchOS_WatchKit_Extension watchKitExtension {
execution points [
provider Package_Test_watchOS_WatchKit_Extension.ContentView_Previews
]
translation units [
ContentView.swift (in Package Test watchOS WatchKit Extension.appex)
]
modules [
Package Test watchOS WatchKit Extension.appex
]
}
]
}
}
我不知道为什么 Xcode 甚至试图在 iOS 上运行它。该包仅添加到 WatchKit 扩展中。怎么做才能使预览再次起作用?