我在 swift
中创建了我的自定义框架,比如说 MyCustomFramework
。
在这个项目中,我添加了一个新的 swift 文件:XYZCustomClass
,如下所示:
public class XYZCustomClass: SKNode {
// variables declaration
public override init() {
super.init()
// make my custom init here
}
...
}
我将我的项目构建为 iOS Generic Device
并获取我的 MyCustomFramework.framework
位置。
然后我在个人项目中导入 MyCustomFramework.framework
并将其导入到好的文件中:
import SpriteKit
import MyCustomFramework
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
let test = XYZCustomClass() // Error
}
}
最后我得到以下错误:
"path"/MyProject/GameScene.swift:44:20: XYZCustomClass' is unavailable: cannot find Swift declaration for this class
作为附加信息,该项目是使用 swift
语言的 SpriteKit
构建的。
提前谢谢你,
最佳答案
检查框架是否包含在“常规”->“链接的框架和库”和/或“构建阶段”->“目标依赖项”下,并在必要时添加它。
关于swift - 使用 Swift 和 SpriteKit 的自定义框架 : can't access custom class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35048969/