Swift:使用私有框架 [英] Swift: using private framework
问题描述
我已经使用Xcode构建了一个iOS Swift框架。
编写代码后,我构建了项目并将.framework文件放在Products文件夹中进行测试。
测试框架已打开一个新的应用程序并拖放以前构建的.framework文件,并将其添加到我的应用程序项目的嵌入式二进制文件列表中。 / p>
要将它导入我的ViewController.swift类,我写道:
import frameworkName
在此之前没问题,这意味着项目会看到框架。
当我尝试在框架内使用公共类时:
var x:className?
我收到以下错误:
'className'不可用:找不到此类的Swift声明
这是什么意思?有什么问题?
当您从工作区引用products目录中的框架时,请确保该位置是Built Products和文件名只是框架名称,没有任何其他路径组件。
如果您引用的是不在工作区中的框架,我建议使用 Carthage ,而不是直接将其复制到您的存储库中。这将使版本控制变得更加容易,并确保它可以为模拟器和设备正确构建。
I have built an iOS Swift framework with Xcode.
After writing the code I have build the project and took the .framework file inside the Products folder to test it.
To test the framework have open a new application and drag and drop the .framework file previously built and I added it into the embedded binaries list of my application project.
To import it into my ViewController.swift class I wrote:
import frameworkName
No problem until here, this means that the project sees the framework. When I try to use a public class inside the framework with:
var x : className?
I get the following error:
'className' is unavailable: cannot find Swift declaration for this class
What does it mean? What is the problem?
When you're referencing a framework in the products directory from your workspace, ensure that the location is "Built Products" and the filename is just the framework name, without any additional path components.
If you're referencing a framework that isn't in your workspace, I would recommend using Carthage instead of copying it directly into your repository. This will make versioning much easier, and will ensure that it is built correctly for both simulator and device.
这篇关于Swift:使用私有框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!