ios - 头文件和plist文件在框架中的作用是什么?

标签 ios swift xcode

当我创建一个新框架时,Xcode 会自动创建两个文件:一个头文件和一个 plist 文件。例如:

enter image description here

我知道什么是 header 和 plist。但是,当我的框架是 CocoaPod/Carthage/SPM 的 Swift pod 时,这些文件很重要吗?这个文件什么时候重要?

最佳答案

框架包剖析

框架束结构

Framework bundles use a bundle structure different from the bundle structure used by applications. The structure for frameworks is based on an earlier bundle format, and allows for multiple versions of the framework code and header files to be stored inside the bundle. This type of bundle is known as a versioned bundle. Supporting multiple versions of a framework allows older applications to continue running even as the framework binary continues to evolve.

The system identifies a framework by the .framework extension on its directory name and by the Resources directory at the top level of the framework bundle. Inside the Resources directory is the Info.plist file that contains the bundle’s identifying information. The actual Resources directory does not have to reside physically at the top-level of the bundle. In fact, the system frameworks that come with OS X have a symbolic link to the framework’s Resources directory in this location. The link points to the most current version of the Resources directory, buried somewhere inside the bundle.

The contents of the Resources directory are similar to those for application bundles. (See “Anatomy of a Modern Bundle” in Bundle Programming Guide for more information.) Localized resources are put in language-specific subdirectories that end with the .lproj extension. These subdirectories hold strings, images, sounds, and interface definitions localized to the language and region represented by the directory. Nonlocalized resources reside at the top level of the Resources directory.

标题

Contains any public headers you want to make available to external developers.

enter image description here

更多信息Apple Documentation页面。

椰子类动物

如果您将使用 cocoapods 发布您的框架例如,从 cocoapods's lib create guide 开始可能更好而不是使用 XCode 的场景。

您可以使用此命令启动(如指南所述):

pod lib create MyLibrary

当您使用芬兰语框架创建向导时,您将拥有如下目录树:

enter image description here

关于ios - 头文件和plist文件在框架中的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45726352/

相关文章:

javascript - UIWebView 下载它的图片内容

ios - 如何在 Apple Watch OS 2 上使用 iPhone 的核心数据?

iOS Firebase 身份验证错误

ios - 如何安装更新的 swift-tools-version?

ios - 如何在tableview中设置UITableViewCellSeparatorStyleNone?

ios - UIButton 奇怪的阴影行为

ios - RxCocoa 数据绑定(bind)导致 Collection View 滚动到顶部

ios - 如何快速关闭消息应用程序?

iphone - 斯坦福iphone开发教程失败。为什么我的代码会崩溃?

ios - 如何将新设备添加到临时分发配置文件?