美文网首页
CocoaPods的使用

CocoaPods的使用

作者: 丢了理想000 | 来源:发表于2018-03-31 17:45 被阅读0次

指定源

CocoaPods支持私有 Spec 仓库的,我们可以建立自己的源,也可以使用非官方的源,只要是符合规定的都可以指定。

[js]view plaincopy

source 'https://github.com/artsy/Specs.git'

source 'https://github.com/CocoaPods/Specs.git'

抑制警告

inhibit_warnings参数能够有效的抑制CocoaPods引入的第三方代码库产生的warning。

可以全部指定。

[js]view plaincopy

inhibit_all_warnings!

也可以针对指定。

[js]view plaincopy

pod'ReactiveCocoa','~> 2.4', :inhibit_warnings =>true

使用git的HEAD指向的分支

[js]view plaincopy

pod'ISO8601DateFormatter', :head

使用 master 分支

[js]view plaincopy

pod'ARAnalytics/Mixpanel', :git =>'https://github.com/orta/ARAnalytics.git'

指定branch

[js]view plaincopy

pod'Reachability', :git =>'https://github.com/ashfurrow/Reachability.git', :branch =>'frameworks'

指定tag

[js]view plaincopy

pod'AFNetworking', :git =>'https://github.com/gowalla/AFNetworking.git', :tag =>'0.7.0'

指定commit

[js]view plaincopy

pod'ARTiledImageView', :git =>'https://github.com/dblockARTiledImageView', :commit =>'1a31b864d1d56b1aaed0816c10bb55cf2e078bb8'

使用子库

可以这样

[js]view plaincopy

pod'QueryKit/Attribute'

也可以这样指定多个子库

[js]view plaincopy

pod'QueryKit', :subspecs => ['Attribute','QuerySet']

使用本地代码

通过:path可以指定本地代码,不过需要确保目录包含podspec文件。

[js]view plaincopy

pod'AFNetworking', :path =>'~/Documents/AFNetworking'

指定target的依赖库

[js]view plaincopy

target :ZipAppdo

pod'SSZipArchive'

end

排除taget

[js]view plaincopy

target'Artsy Tests', :exclusive =>truedo

pod'FBSnapshotTestCase','1.4'

end

指定xcodeproj

默认会使用Podfile文件同级目录下第一个xcodeproj,但也可以指定

[js]view plaincopy

xcodeproj'MyProject'

target :testdo

# This Pods library linkswitha targetinanother project.

xcodeproj'TestProject'

end

指定连接的target

如果不显式指定连接的target,Pods会默认连接project的第一个target。如果需要,可以使用link_with指定连接一个或多个target

[js]view plaincopy

link_with'MyApp','MyOtherApp'

指定依赖库的配置文件

[js]view plaincopy

pod'PonyDebugger', :configuration => ['Release']

指定target的配置文件

[js]view plaincopy

xcodeproj'TestProject','Mac App Store'=> :release,'Test'=> :debug

使用Dynamic Frameworks代替Static Libraries

通过标志use_frameworks!就可知开启这个功能。如果需要使用Swift的库,就必须加上这个标志了。

加快pod install/update 速度

使用CocoaPods来添加第三方类库,无论是执行pod install还是pod updat很多时候都卡在了Analyzing dependencies不动,这是更新本地的pod spec所以文件导致的。通过--no-repo-update标志可以不更新本地pod spec索引。当然首次install不应该添加这个标志,后续修改Podfile的时候可以适当使用,加快pod速度。

[js]view plaincopy

pod install --no-repo-update

pod update --no-repo-update

输出详细日志

[js]view plaincopy

pod update --verbose

platform :ios, '8.0'

iOS 8.0以上版本才能用

加速//未测试

git config --global http.https://github.com.proxy socks5://127.0.0.1:1086

移除加速

git config --global --unset http.https://github.com.proxy

相关文章

网友评论

      本文标题:CocoaPods的使用

      本文链接:https://www.haomeiwen.com/subject/vuggjxtx.html