簡(jiǎn)介
spec描述了一個(gè)pod庫的版本。它包括有關(guān)應(yīng)從何處獲取源、使用什么文件、要應(yīng)用的構(gòu)建設(shè)置以及其他一般元數(shù)據(jù)(如其名稱、版本和描述)的詳細(xì)信息。
官方文檔:https://guides.cocoapods.org/syntax/podspec.html
詳情
- 到達(dá)目標(biāo)根目錄,通過指令
pod spec create XXX創(chuàng)建一個(gè)XXX.podspec,里面的內(nèi)容很全,可以根據(jù)訴求去選擇。這里增加中文備注,方便大家閱讀
#
# Be sure to run `pod spec lint XXFramework.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#
Pod::Spec.new do |spec|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#
# 庫名稱
spec.name = "XXFramework"
# 庫版本
spec.version = "0.0.1"
# 庫描述
spec.summary = "A short description of XXFramework."
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
# 庫詳細(xì)介紹
spec.description = <<-DESC
DESC
# 主頁,這里要填寫可以訪問到的地址,不然驗(yàn)證不通過
spec.homepage = "http://EXAMPLE/XXFramework"
# 截圖
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See https://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#
# 開源協(xié)議,一般選擇MIT
spec.license = "MIT (example)"
# spec.license = { :type => "MIT", :file => "FILE_LICENSE" }
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#
# 作者信息
spec.author = { "gurisxie" => "279483595@qq.com" }
# Or just: spec.author = "gurisxie"
# spec.authors = { "gurisxie" => "279483595@qq.com" }
# spec.social_media_url = "https://twitter.com/gurisxie"
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#
# 平臺(tái)描述
# spec.platform = :ios
# spec.platform = :ios, "5.0"
# When using multiple platforms
# spec.ios.deployment_target = "5.0"
# spec.osx.deployment_target = "10.7"
# spec.watchos.deployment_target = "2.0"
# spec.tvos.deployment_target = "9.0"
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#
# 項(xiàng)目地址,不支持ssh的地址,驗(yàn)證不通過,只支持HTTP和HTTPS,最好使用HTTPS
spec.source = { :git => "http://EXAMPLE/XXFramework.git", :tag => "#{spec.version}" }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#
# 代碼源文件地址,**/*表示Classes目錄及其子目錄下所有文件
# 如果有多個(gè)目錄下則用逗號(hào)分開,如果需要在項(xiàng)目中分組顯示,這里也要做相應(yīng)的設(shè)置
spec.source_files = "Classes", "Classes/**/*.{h,m}"
# 可設(shè)置不包含的文件
spec.exclude_files = "Classes/Exclude"
# 公開頭文件地
# spec.public_header_files = "Classes/**/*.h"
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#
# 源文件地址
# spec.resource = "icon.png"
# spec.resources = "Resources/*.png"
# spec.preserve_paths = "FilesToSave", "MoreFilesToSave"
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#
# 該pod依賴的系統(tǒng)framework,多個(gè)用逗號(hào)隔開
# spec.framework = "SomeFramework"
# spec.frameworks = "SomeFramework", "AnotherFramework"
# 該pod依賴的系統(tǒng)library,多個(gè)用逗號(hào)隔開
# spec.library = "iconv"
# spec.libraries = "iconv", "xml2"
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.
# 是否使用ARC,如果指定具體文件,則具體的文件使用ARC
# spec.requires_arc = true
# buildsetting相關(guān)設(shè)置
# spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# 依賴關(guān)系,該項(xiàng)目所依賴的其他庫,如果有多個(gè)需要填寫多個(gè)s.dependency
# spec.dependency "JSONKit", "~> 1.4"
# 定義子庫例子
spec.subspec 'XXChildFramework' do |ss|
#引入XXChildFramework中所有資源文件
ss.source_files = 'XXChildFramework/Classes/**/*'
#公開XXChildFramework模塊中的頭文件
ss.public_header_files = 'XXChildFramework/Classes/publicHeader/*.h'
end
end
###以下是上面代碼的功能注解
s.name:
名稱
pod search 搜索的關(guān)鍵詞,一定要和.podspec的名稱一樣,否則報(bào)錯(cuò)
s.version:
版本號(hào)
s.ios.deployment_target:
支持的pod最低版本
s.summary:
簡(jiǎn)介
s.homepage:
項(xiàng)目主頁地址
s.license:
開源協(xié)議(創(chuàng)建github庫的時(shí)候選擇的)
s.author:
作者信息(這里隨便謝謝也可以通過)
s.social_media_url:
社交網(wǎng)址
s.source:
項(xiàng)目的地址
s.source_files:
需要包含的源文件
s.resource:
資源文件,單個(gè)
s.resources:
資源文件(含bundle)
s.vendored_frameworks:
包含的framework,也就是我們自己制作的pod
s.requires_arc:
是否支持ARC
s.dependency:
依賴庫,不能依賴未發(fā)布的庫.如AFNetWorking
s.description:
描述,字?jǐn)?shù)要比s.summary長(zhǎng)
s.screenshots:
截圖
s.exclude_files:
隱藏的文件
s.public_header_files:
公開的頭文件
s.framework:
所需的framework,單個(gè)
s.frameworks:
所需的framework,多個(gè)用逗號(hào)隔開
s.library
引用的靜態(tài)庫
s.libraries
引用的靜態(tài)庫,多個(gè)用逗號(hào)隔開
s.vendored_libraries:
引用自己生成的.a
s.vendored_frameworks:
引用自己生成的.framework,多個(gè)用逗號(hào)隔開
s.dependency:
依賴的庫
s.ios.deployment_target
iOS部署版本