# WatchOS Preview fails to compile when Swift Packages are added for iOS

**URL:** <https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598>\
**Category:** Using Swift\
**Tags:** packagemanager, swiftui, watchos\
**Created:** [April 21, 2021, 7:49pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598 "2021-04-21T19:49:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobbyRohweder](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bobbyrohweder/32/11033_2.png) [@BobbyRohweder](https://forums.swift.org/u/BobbyRohweder)\
**Post date:** [April 21, 2021, 7:49pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/1 "2021-04-21T19:49:37Z")

</div>

When attempting to load a SwiftUI canvas for my watchOS app, it fails to load because Xcode attempts to compile the Swift Packages that are meant for iOS against the watchOS sdk.

Error examples:  
"While building for watchOS Simulator, no library for this platform was found in 'ABC.xcframework'" for a framework

"Cannot find type 'UITableViewController' in scope" for packages that are all swift source code (UITableViewController is not available in watchOS)

Related Firebase sdk thread: [SwiftUI previews breaks when adding a watchOS target · Issue #7610 · firebase/firebase-ios-sdk · GitHub](https://github.com/firebase/firebase-ios-sdk/issues/7610)

Is there a workaround for this issue?

---

<div class="post-metadata">

**Author:** ![mazefest](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mazefest/32/22905_2.png) [@mazefest](https://forums.swift.org/u/mazefest)\
**Post date:** [November 2, 2022, 10:27pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/2 "2022-11-02T22:27:02Z")

</div>

Did you ever find a solution for this?

---

<div class="post-metadata">

**Author:** ![rlisle](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rlisle/32/28830_2.png) [@rlisle](https://forums.swift.org/u/rlisle)\
**Post date:** [February 20, 2023, 12:35pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/3 "2023-02-20T12:35:03Z")

</div>

I've run into this same (or similar) issue:  
I have an iOS app with watchOS app and a single Swift Package (SwiftMQTT). All Previews fail with a message stating that a file in the SP (getStreamsToHost) is unavailable in watchOS. The SP is not referenced from any watch app file though.  
The Firebase thread referenced above stated that the problem was fixed in Xcode 13, but I am running on Xcode 14.2. Has the problem been regressed?

---

<div class="post-metadata">

**Author:** ![kylebshr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kylebshr/32/21066_2.png) [@kylebshr](https://forums.swift.org/u/kylebshr)\
**Post date:** [June 29, 2023, 4:13pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/4 "2023-06-29T16:13:15Z")

</div>

I'm running into this too on Xcode 15, did anyone find anything?

---

<div class="post-metadata">

**Author:** ![bryan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bryan/32/508_2.png) [@bryan](https://forums.swift.org/u/bryan)\
**Post date:** [January 10, 2024, 9:42pm UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/5 "2024-01-10T21:42:11Z")

</div>

Running Xcode 15.2. Same problem with visionOS

---

<div class="post-metadata">

**Author:** ![gestrich](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gestrich/32/18000_2.png) [@gestrich](https://forums.swift.org/u/gestrich)\
**Post date:** [January 11, 2024, 1:20am UTC](https://forums.swift.org/t/watchos-preview-fails-to-compile-when-swift-packages-are-added-for-ios/47598/6 "2024-01-11T01:20:38Z")

</div>

You can try removing your ios target from the watch scheme in Xcode. This seems to allow previews to build but I am not sure what other consequences that may have yet. I recently posted this question and filed an apple issue [here](https://developer.apple.com/forums/thread/743957)
