环境
背景
我有一个基于NSView(或UIView取决于所需目标的IBDesignable控件)。我已经使用程序包管理器对其进行了打包,如下所示:
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyControl",
platforms: [
.macOS(.v10_13),
.iOS(.v10)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "MyControl",
targets: ["MyControl"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "MyControl",
dependencies: []),
.testTarget(
name: "MyControl Tests",
dependencies: ["MyControl"]),
]
)
作为“ MyControl”的一部分,我有以下基于所需目标Target的类型别名:>
#if os(macOS) import AppKit public typealias QJViewController = NSViewController public typealias QJColor = NSColor public typealias QJFont = NSFont public typealias QJView = NSView #elseif os(iOS) || os(tvOS) import UIKit public typealias QJViewController = UIViewController public typealias QJColor = UIColor public typealias QJFont = UIFont public typealias QJView = UIView #endif
程序包编译成功;控件正确导入到我的目标项目中;一切都会在目标项目中按预期进行编译和运行。
问题
当我在InterfaceBuilder中设置控件时,它无法呈现并出现以下错误:
重申:我的目标是不是
appleTV,它是macOS。无论我做什么,IB都希望使用AppleTV作为目标来渲染此程序包,并因此实现我的控制权。给定我上面使用的类型别名,该控件将无法正确呈现,因为(显然)macOS对UIColor,UIFont,UIView,UIViewController一无所知。问题
在呈现控件时是否有一种方法可以强制IB使用特定的目标?如果没有,我的项目设置中会缺少什么吗?就像我说的那样,控件可以按预期工作;我只想在IB中渲染它。
环境macOS:10.15.3 Xcode:11.3.1 Swift:5.1应用程序目标:macOS背景我有一个基于NSView(或UIView取决于所需目标)的IBDesignable控件。我有...
`提供的材料不足以测试问题,仅是建议-请尝试以下条件映射