skip to Main Content

I’m using Xcode 13.4 and have created a new SwiftUI project using the "iOS app with watch app" project template. The target for the main app is set to iOS 15.5 and the watch target is set to WatchOS 8. Everything was building and running on the simulator fine.

I’ve just added the watch-date-picker Swift package (a package which adds a date picker for WatchOS) to my project using Xcode’s File -> Add packages... menubar option:

enter image description here

and now I can’t build my project – I get tons of errors in the added watch-date-picker package’s code complaining that various things are only available in iOS 13.0 or newer. I haven’t even tried using the library yet – I’ve just added it via File -> Add Packages. Here are the package settings:

// swift-tools-version:5.5
import PackageDescription

let package = Package(
  name: "watch-date-picker",
  defaultLocalization: "en",
  platforms: [
    .watchOS(.v8)
  ],
  products: [
    .library(name: "WatchDatePicker", targets: ["WatchDatePicker"]),
  ],
  targets: [
    .target(name: "WatchDatePicker", dependencies: []),
    //.executable(name: "WatchDatePickerExamples", dependencies: ["WatchDatePicker"]),
  ]
)

I’m confused why I’m getting this error – as far as I can tell, I’m targeting the latest versions of everything – iOS 15.5 and WatchOS 8.5. Can anyone explain why this is and what I can do to resolve it? Am I missing something? Is there something I need to do to tell the package to only build for WatchOS and not iOS? I’ve tried cleaning, deleting derived data, closing Xcode, nothing works. Thanks!

enter image description here

enter image description here

enter image description here

2

Answers


  1. When you add a package, you say what target it belongs to. It sounds like you neglected to make this package part part of the Watch target at the time you added it.

    I would suggest removing the package entirely and starting over.

    Login or Signup to reply.
  2. Modify Package.swift from

    // swift-tools-version:5.5
    import PackageDescription
    
    let package = Package(
      name: "watch-date-picker",
      defaultLocalization: "en",
    

    to

    // swift-tools-version:5.5
    import PackageDescription
    
    let package = Package(
      name: "watch-date-picker",
      platforms: [.iOS(.v15)],
      defaultLocalization: "en",
    

    I do not understand why. But, this is the workaround I am using so far. It works for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search