Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13962] Interface builder ignores SupportedPlatforms value for Swift packages with IBDesignables #4459

Open
swift-ci opened this issue Dec 12, 2020 · 1 comment
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13962
Radar rdar://problem/72302322
Original Reporter nico.elayda (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 12.2 (12B45b) / Xcode 12.3 RC (12C33)

macOS 11.0.1 (20B50)

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 89ea42b3e6423f999fc0b2088b90c040

Issue Description:

When using an IBDesignable component from an SPM package as a custom class in an interface builder document, it is being built for platforms other than the ones specified in the package description to render the designables. This only occurs when the IBDesignable is inside an SPM package.

To reproduce the issue:

1. Create a new swift package with the following package description (note the value for platforms).

// swift-tools-version:5.3

import PackageDescription

let package = Package(
 name: "SPMDesignablePackage",
 platforms: [
 .iOS(.v12)
 ],
 products: [
 .library(
 name: "SPMDesignablePackage",
 targets: ["SPMDesignablePackage"]),
 ],
 targets: [
 .target(name: "SPMDesignablePackage"),
 ]
)

2. Create a single source file SPMDesignableControl.swift in the Sources directory of this package.

import UIKit

@IBDesignable
public class SPMDesignableControl: UIView {
 
 @IBInspectable public var designableColorProperty: UIColor = .blue
 
 public override func prepareForInterfaceBuilder() {
 super.prepareForInterfaceBuilder()
 backgroundColor = designableColorProperty
 }
}

3. Create a new Xcode project and drag this new package to the Project Navigator.
4. Add this package as a dependency in the Frameworks, Libraries, and Embedded Content section of the build target.
5. In Main.storyboard, add a UIView and set this view's Custom Class to SPMDesignableControl in the Identity Inspector.
6. Click on Editor > Refresh All Views to force the designables to render.
7. The Identity Inspector for SPMDesignableControl will show a build error, with a message expecting the existence of a tvOS product/target.

My expectation is since iOS is the only explicitly specified platform in the package description, it should not attempt to build the package sources for tvOS (or other platforms).

I've also seen multiple threads describing a similar issue with no solution:
https://developer.apple.com/forums/thread/652552
https://developer.apple.com/forums/thread/652558
https://developer.apple.com/forums/thread/661391
https://stackoverflow.com/questions/64881772/

A zip archive is attached below containing the SPM package (SPMDesignablePackage) and sample project setup (SPMDesignablePackageUser).

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants