Very Strange Errors From IB During Build With Swift Package, Using IBDesignable
Asked Answered
A

1

1

I have developed this shared package. It works fine.

In the package test harnesses (3 iOS apps), it works great, and also, the IB storyboard renders the control (It's an IBDesignable).

However, when I include it as a package in another app (I can't share the source), I get these really weird render failure messages:

Error: 'UIPickerView' is unavailable in tvOS

And so on. There's a bunch of "not available in tvOS" errors.

Here's what the log looks like:

Image of build errors in the log

The build happens, and the app runs fine. However, I'm wondering if this could cause problems in the App Store release process.

Well...DUH. It's an iOS package and utility, and leverages a lot of things like haptics.

The package explicitly states that it is iOS(12), and I can't see any indication of why my storyboard is insisting on trying to render as tvOS.

What am I missing? I think that I must be missing something from the Package.swift file, but it's pretty straightforward:

import PackageDescription

let package = Package(
    name: "RVS_Spinner",
    platforms: [
        .iOS(.v12)
    ],
    products: [
        .library(
            name: "RVS-Spinner",
            targets: ["RVS_Spinner"])
    ],
    targets: [
        .target(name: "RVS_Spinner")
    ]
)
Antepenult answered 23/9, 2020 at 23:44 Comment(1)
Exact same issue here... haven't found a solution yet.Octavla
G
1

You need to wrap each of these problematic files in

#if os(iOS)

#endif

so that they don't get compiled for other platforms, as things you are referring are only available on iOS.

As far as i know, you can't stop a package from building on all platforms, but you can select which file to be compiled on which platform with the #if os() trick

I think you got confused by the platforms parameter in the Package.swift file. It is not saying where this package is available, it is saying the minimum version required for each platform.

Take a look at Apple's doc for the platforms parameter:

platforms - The list of minimum deployment targets per platform.

Apple docs

Guarnerius answered 23/2, 2021 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.