[英]How to create Cocoa Touch Framework using Swift language and use it in other Swift projects?
I've just started to develop iOS app using Swift language, but I noticed we can create a Cocoa Touch Framework to be able reuse in other projects. 我刚刚开始使用Swift语言开发iOS应用,但是我注意到我们可以创建一个Cocoa Touch Framework以便能够在其他项目中重用。 I've already finished my own framework but I got problem when I was trying to use it in my current project.
我已经完成了自己的框架,但是当我尝试在当前项目中使用它时遇到了问题。 It seems my project didn't recognize classes in framework although I called
import MyCustomFramework
in files which is using features of framework. 尽管我在使用框架功能的文件中调用
import MyCustomFramework
,但我的项目似乎无法识别框架中的类。
Here is my sample framework structure: 这是我的示例框架结构:
MyCustomFramework |--MyCustomFramework.h (I didn't modify this file, it only contains default code same as when creating) |--TestClass.swift (Define class with public keyword)
Has anyone got same problem? 有人遇到过同样的问题吗?
When we create frameworks the most important thing is the Access specifiers private, internal and public . 当我们创建框架时 ,最重要的是Access说明符 private,internal和public 。 So we need to declare the functions and properties as public if we want to access it outside the frameworks!
因此,如果要在框架之外访问它们,则需要将函数和属性声明为公共 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.