当我创建一个新框架时,Xcode 会自动创建两个文件:一个头文件和一个 plist 文件。例如:
我知道什么是 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.
更多信息Apple Documentation页面。
椰子类动物
如果您将使用 cocoapods 发布您的框架例如,从 cocoapods's lib create guide 开始可能更好而不是使用 XCode 的场景。
您可以使用此命令启动(如指南所述):
pod lib create MyLibrary
当您使用芬兰语框架创建向导时,您将拥有如下目录树:
关于ios - 头文件和plist文件在框架中的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45726352/