Podfile、Podfile.lock、Manifest.lock、Podspec
Podfile
開(kāi)發(fā)編寫(xiě)的文件,包含了關(guān)于工程的targets、Pods的信息,比如依賴的第三方庫(kù)的版本、資源的加載路徑等。主要用于描述一個(gè)或多個(gè) Xcode Project 中各個(gè) Targets 之間的依賴關(guān)系。
if (repo = ENV['COCOAPODS_SPEC_REPO'])source "#{repo}" end### Implicit target definition :-/ project "AFNetworking Mac Example.xcodeproj" ####workspace 'Examples.xcworkspace'target "AFNetworking Example" doplatform :osx, '10.8'project "AFNetworking Mac Example.xcodeproj"pod "AFNetworking", "1.3.3" endtarget "AFNetworking iOS Example" doplatform :ios, '8.0'project "AFNetworking iOS Example.xcodeproj"pod "AFNetworking", "1.3.3" endPodfile.lock
該文件記錄工程安裝了哪些Pod以及對(duì)應(yīng)的版本,是pod install的產(chǎn)物
#PODS:記錄所有Pod庫(kù)的具體安裝的版本號(hào) PODS:- AFNetworking (1.3.3) #DEPENDENCIES:記錄各Pod庫(kù)之間的相互依賴關(guān)系, DEPENDENCIES:- AFNetworking (= 1.3.3) #SPEC REPOS:倉(cāng)庫(kù)信息,即安裝了哪些三方庫(kù),他們來(lái)自于哪個(gè)倉(cāng)庫(kù) SPEC REPOS:trunk:- AFNetworking #SPEC CHECKSUMS:記錄當(dāng)前各 Pod 庫(kù)的 Podspec 文件 Hash 值,其實(shí)就是文件的 md5 SPEC CHECKSUMS:AFNetworking: 127629aef6e631d57291c25154defc678c8a7337 #PODFILE CHECKSUM:記錄 Podfile 文件的 Hash 值,同樣是 md5,確認(rèn)是否有變更 PODFILE CHECKSUM: 6f295323460330fe2653455f8ed3f15e71283613 #記錄上次所使用的 CocoaPods 版本 COCOAPODS: 1.11.3Manifest.lock
Manifest.lock其實(shí)是Podfile.lock 文件的副本,每次運(yùn)行 pod install 命令時(shí)都會(huì)更新;通常Pods文件不放到版本管理里面、Podfile.lock放到版本管理里面,這樣在本地拉取代碼之后是否需要更新pod,就可以通過(guò)對(duì)比本地的Manifest.lock和遠(yuǎn)程Podfile.lock是否相同即可
如果遇見(jiàn)The sandbox is not in sync with the Podfile.lock報(bào)錯(cuò)
原因是沙盒文件與 Podfile.lock 文件不同步,根本原因是 Manifest.lock 文件和 Podfile.lock 文件不一致所引起。
PODS:- AFNetworking (1.3.3)DEPENDENCIES:- AFNetworking (= 1.3.3)SPEC REPOS:trunk:- AFNetworkingSPEC CHECKSUMS:AFNetworking: 127629aef6e631d57291c25154defc678c8a7337PODFILE CHECKSUM: 6f295323460330fe2653455f8ed3f15e71283613COCOAPODS: 1.11.3Podspec
描述了一個(gè)庫(kù)是怎樣被添加到工程中的。它支持的功能有:列出源文件、framework、編譯選項(xiàng)和某個(gè)庫(kù)所需要的依賴等。
Pod::Spec.new do |s|s.name = 'Alamofire's.version = '4.6.0's.license = 'MIT's.summary = 'Elegant HTTP Networking in Swift's.homepage = 'https://github.com/Alamofire/Alamofire's.social_media_url = 'http://twitter.com/AlamofireSF's.authors = { 'Alamofire Software Foundation' => 'info@alamofire.org' }s.source = { :git => 'https://github.com/Alamofire/Alamofire.git', :tag => s.version }s.ios.deployment_target = '8.0's.osx.deployment_target = '10.10's.tvos.deployment_target = '9.0's.watchos.deployment_target = '2.0's.source_files = 'Source/*.swift' end我們簡(jiǎn)單介紹一下podspec文件內(nèi)容
第一部分是簡(jiǎn)單的內(nèi)容,我們不展開(kāi)介紹,大家從屬性名字即可知道屬性的作用
s.name = 'Alamofire's.version = '4.6.0's.license = 'MIT's.summary = 'Elegant HTTP Networking in Swift's.homepage = 'https://github.com/Alamofire/Alamofire's.social_media_url = 'http://twitter.com/AlamofireSF's.authors = { 'Alamofire Software Foundation' => 'info@alamofire.org' }s.source = { :git => 'https://github.com/Alamofire/Alamofire.git', :tag => s.version }第二部分介紹一下不常用的或者需要解釋一下
(1)配置三方庫(kù)的源文件
Source_files:配置三方庫(kù)的源文件,一般是.h.m.c等后綴的文件
s.source_files = [“Class/**/*.{h,m,c}”,"ClassA.{h,m}", "Bridge.h”](2)配置工程的系統(tǒng)框架
— frameworks:配置依賴的系統(tǒng)框架
s.frameworks = 'AVFoundation','QuartzCore', ‘CoreLocation'— vendored_frameworks:配置需要引用的非系統(tǒng)框架
vendored_frameworks = 'Frameworks/MyFramework.framework'(3)配置工程的的系統(tǒng)庫(kù)
— vendored_libraries:配置需要引用的非系統(tǒng)靜態(tài)庫(kù)(要注意,這里的.a靜態(tài)庫(kù)名字必須要帶lib前綴,如果引用的靜態(tài)庫(kù)名字沒(méi)lib前綴會(huì)導(dǎo)致編譯報(bào)錯(cuò),只需要重命名加上即可)
vendored_libraries = 'Class/libXXX.a’— Libraries:配置依賴的系統(tǒng)庫(kù)(要注意,這里的寫(xiě)法需要忽略lib前綴)
libraries = 'c++', 'sqlite3', 'stdc++.6.0.9', 'z'(4)配置工程的資源文件
— resources:配置工程需要的資源文件,一般包括.bundle.png等文件,資源文件會(huì)放在mainBundle中,需要避免命名沖突
s.resources = ['Resources/*.bundle’]— resource_bundles來(lái)指定bundle的資源文件,不使用mainBundle中的資源文件
resource_bundles = {'UIKitBundle' => ['Resources/MyUIKit.bundle'], }(5)public_header_files:配置公有的頭文件(.h文件)
寫(xiě)法: source_files = 'Classes/UIKit.h' // 直接指定文件名 或: source_files = 'Classes/*.h' // Classes文件夾下的所有匹配文件 source_files = 'Classes/**/*.h' // Classes所有路徑下的所有匹配文件s.wb_public_header_files('PublicHeaders’)
(6)dependency:依賴的三方庫(kù),pod庫(kù)或者可以是自身的subspec
dependency 'AFNetworking'(7)requires_arc:用來(lái)配置哪些源文件使用ARC,
s.requires_arc = false #沒(méi)有文件使用ARC s.requires_arc = 'Classes/Arc's.wb_resources_hook(s)
(8)deployment_target: 配置工程支持的的平臺(tái)的target的最小值
s.ios.deployment_target = 9.0https://guides.cocoapods.org/syntax/podspec.html
總結(jié)
以上是生活随笔為你收集整理的Podfile、Podfile.lock、Manifest.lock、Podspec的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ASCII码判断大小
- 下一篇: Unity3D灯光与渲染学习之(二):全