创建与发布 iOS frameworks

原文:https://www.raywenderlich.com/126365/ios-frameworks-tutorial

frameworks 的三个主要作用

  • 代码封闭
  • 代码模块化
  • 代码复用

开始

下载 starter project

创建 Framework

  1. Xcode -> new -> Project -> iOS Framework & Library-> Cocoa Touch Framework.
  2. 填写相应的 Product Name, Organization Name等。
  3. 拖入相关的Code及资源文件。


  4. 添加到工程项目中(可选)
  5. 添加frameworks 到 Embedded Binaries中


Access Control(访问控制)

Swift有三种访问控制:

  • Public: for code called by the app or other frameworks, e.g., a custom view.
  • Internal: for code used between functions and classes within the framework, e.g., custom layers in that view.
  • Private: for code used within a single file, e.g., a helper function that computer layout height.

Update the Storyboard

In the Identity Inspector, under Custom Class, change the Module to ThreeRingControl.


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容