My Swift Package fails to compile when selecting the watchOS target.
The error message is Failed to load module 'XCTest'
and build error details is:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator6.0.sdk/usr/lib/swift/XCTest.swiftmodule/i386.swiftinterface:6:19: XCTest is not available when building for watchOS Simulator. Consider using
#if targetEnvironment(macCatalyst)to conditionally import this framework when building for Mac Catalyst.
There is no XCTest in watchOS so do I get my Swift Package to compile for watchOS?
It's a total hack but one way I've been getting round this during development is to temporarily comment out the .testTarget(name:dependencies:)
type method in the Package.swift file. After that, clean the build folder, then build and run for watchOS.
I also leave a #warning
for myself to make sure I uncomment before making any commits to my Swift Package.
(It's worth adding that this is in addition to wrapping all test code in #if !os(watchOS)
conditionals.)
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