Podfile、Podfile.lock、Manifest.lock、Podspec
Podfile
開發編寫的文件,包含了關于工程的targets、Pods的信息,比如依賴的第三方庫的版本、資源的加載路徑等。主要用于描述一個或多個 Xcode Project 中各個 Targets 之間的依賴關系。
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以及對應的版本,是pod install的產物
#PODS:記錄所有Pod庫的具體安裝的版本號 PODS:- AFNetworking (1.3.3) #DEPENDENCIES:記錄各Pod庫之間的相互依賴關系, DEPENDENCIES:- AFNetworking (= 1.3.3) #SPEC REPOS:倉庫信息,即安裝了哪些三方庫,他們來自于哪個倉庫 SPEC REPOS:trunk:- AFNetworking #SPEC CHECKSUMS:記錄當前各 Pod 庫的 Podspec 文件 Hash 值,其實就是文件的 md5 SPEC CHECKSUMS:AFNetworking: 127629aef6e631d57291c25154defc678c8a7337 #PODFILE CHECKSUM:記錄 Podfile 文件的 Hash 值,同樣是 md5,確認是否有變更 PODFILE CHECKSUM: 6f295323460330fe2653455f8ed3f15e71283613 #記錄上次所使用的 CocoaPods 版本 COCOAPODS: 1.11.3Manifest.lock
Manifest.lock其實是Podfile.lock 文件的副本,每次運行 pod install 命令時都會更新;通常Pods文件不放到版本管理里面、Podfile.lock放到版本管理里面,這樣在本地拉取代碼之后是否需要更新pod,就可以通過對比本地的Manifest.lock和遠程Podfile.lock是否相同即可
如果遇見The sandbox is not in sync with the Podfile.lock報錯
原因是沙盒文件與 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
描述了一個庫是怎樣被添加到工程中的。它支持的功能有:列出源文件、framework、編譯選項和某個庫所需要的依賴等。
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我們簡單介紹一下podspec文件內容
第一部分是簡單的內容,我們不展開介紹,大家從屬性名字即可知道屬性的作用
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)配置三方庫的源文件
Source_files:配置三方庫的源文件,一般是.h.m.c等后綴的文件
s.source_files = [“Class/**/*.{h,m,c}”,"ClassA.{h,m}", "Bridge.h”](2)配置工程的系統框架
— frameworks:配置依賴的系統框架
s.frameworks = 'AVFoundation','QuartzCore', ‘CoreLocation'— vendored_frameworks:配置需要引用的非系統框架
vendored_frameworks = 'Frameworks/MyFramework.framework'(3)配置工程的的系統庫
— vendored_libraries:配置需要引用的非系統靜態庫(要注意,這里的.a靜態庫名字必須要帶lib前綴,如果引用的靜態庫名字沒lib前綴會導致編譯報錯,只需要重命名加上即可)
vendored_libraries = 'Class/libXXX.a’— Libraries:配置依賴的系統庫(要注意,這里的寫法需要忽略lib前綴)
libraries = 'c++', 'sqlite3', 'stdc++.6.0.9', 'z'(4)配置工程的資源文件
— resources:配置工程需要的資源文件,一般包括.bundle.png等文件,資源文件會放在mainBundle中,需要避免命名沖突
s.resources = ['Resources/*.bundle’]— resource_bundles來指定bundle的資源文件,不使用mainBundle中的資源文件
resource_bundles = {'UIKitBundle' => ['Resources/MyUIKit.bundle'], }(5)public_header_files:配置公有的頭文件(.h文件)
寫法: source_files = 'Classes/UIKit.h' // 直接指定文件名 或: source_files = 'Classes/*.h' // Classes文件夾下的所有匹配文件 source_files = 'Classes/**/*.h' // Classes所有路徑下的所有匹配文件s.wb_public_header_files('PublicHeaders’)
(6)dependency:依賴的三方庫,pod庫或者可以是自身的subspec
dependency 'AFNetworking'(7)requires_arc:用來配置哪些源文件使用ARC,
s.requires_arc = false #沒有文件使用ARC s.requires_arc = 'Classes/Arc's.wb_resources_hook(s)
(8)deployment_target: 配置工程支持的的平臺的target的最小值
s.ios.deployment_target = 9.0https://guides.cocoapods.org/syntax/podspec.html
總結
以上是生活随笔為你收集整理的Podfile、Podfile.lock、Manifest.lock、Podspec的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASCII码判断大小
- 下一篇: Unity3D灯光与渲染学习之(二):全