James Allen
James Allen

Reputation: 7169

"... is only available in iOS 13.0 or newer" in a project targeting iOS 15.0

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

Upvotes: 10

Views: 15891

Answers (3)

Felipe Silva Vieira
Felipe Silva Vieira

Reputation: 311

I had the same issue. For me updating package worked! enter image description here

Upvotes: 0

Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42796

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.

Upvotes: 8

matt
matt

Reputation: 535890

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.

Upvotes: 1

Related Questions