I made a custom Swift framework to reuse the same code across different projects. However, when I import the framework in other projects, the classes are not available for use.
我制作了一个自定义的Swift框架,以便在不同的项目中重用相同的代码。但是,当我在其他项目中导入框架时,这些类无法使用。
Things I already did
我已经做过的事情
-
To create the framework, I picked a Cocoa Touch Framework project. The structure of the project: framework project structure
为了创建框架,我选择了一个Cocoa Touch Framework项目。项目结构:框架项目结构
-
I marked the classes
public class AVSManager {}
and theinit()
functions as public.我将类公共类AVSManager {}和init()函数标记为public。
-
Copied the .framework file to the root of the other projects
将.framework文件复制到其他项目的根目录
-
In the projects, I added the framework as embedded binary
在项目中,我将框架添加为嵌入式二进制文件
-
Imported the framework in the
ViewController.swift
class of a project:import AVSCMDI
在项目的ViewController.swift类中导入框架:import AVSCMDI
When I then try to call AVSManager()
it produces the following error: AVSManager is unavailable: cannot find Swift declaration for this class
当我然后尝试调用AVSManager()时,它会产生以下错误:AVSManager不可用:找不到此类的Swift声明
Does anybody have an idea what i'm missing here?
有没有人知道我在这里缺少什么?
Thanks in advance!
提前致谢!
1 个解决方案
#1
6
I found the solution to my problem!
我找到了解决问题的方法!
It turned out that I needed to build my framework with a real device as target.
事实证明,我需要使用真实设备构建我的框架作为目标。
#1
6
I found the solution to my problem!
我找到了解决问题的方法!
It turned out that I needed to build my framework with a real device as target.
事实证明,我需要使用真实设备构建我的框架作为目标。