美文网首页iOS DeveloperiOS开发
CocoaPods学习01-Podfile

CocoaPods学习01-Podfile

作者: 水木共美 | 来源:发表于2017-12-21 15:12 被阅读0次

CocoaPods学习02-PodSpec
CocoaPods学习03-pod install vs pod update
CocoaPods学习04-制作自己的pod库

命令语法

  • install! 设置安装方法和参数 方法现在仅支持'cocoapods',它的参数文档未做说明,具体待查
    install! 'cocoapods'

  • pod指出依赖关系

    • pod 'AFNetworking', ~>3.0.0版本号依赖不做过多解释,* 版本号

      • pod 'ABC' 始终使用最新版本
      • pod 'ABC', '0.9' 只使用0.9这个版本
      • 版本号支持>,>=,<,<=符号
        <= 0.9任何小于0.9版本
      • ~> 1.2.3大于等于1.2.3但是小于'1.3',倒数第一个数字可变但是要大于等于它,一般开发使用这种方式,这样可以避免pod库进行了大改动,我们需要适配代码
    • build configurations 编译配置设置
      pod 'ZJJDebugger', :configuration => 'Debug'只在debug环境下配置

    • subspecs 子模块依赖
      pod 'QueryKit', :subspecs => ['Attribute', 'QuerySet'],只引入该库下的后两个模块

    • 指定本地文件库依赖
      pod 'ABC', :path => '~/Documents/ABC'

    • 指定引入的分支,tag,提交号

      • 默认mater pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
      • 引入其他分支 pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'
      • 引入某个tag处 pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1'
      • 引入某次提交处 `pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :commit => 'ssfsdf23123'
    • 如果某个lib在它的仓库外面没有podspec,也可以从其他位置引入该podspec
      pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'

  • target 需要指向Xcode target
    abstract_target 抽象基类target,不能指向具体的Xcode target
    inherit! 继承target

     # Note: 定义一个抽象基类target
     abstract_target 'Shows' do
     pod 'ShowsKit'
    
    #  ShowsiOS 继承'ShowsKit'和自己的'ShowWebAuth'
     target 'ShowsiOS' do
      pod 'ShowWebAuth'
     end
    
    # ShowsTw 继承'ShowsKit'和自己的'ShowTVAuth'
     target 'ShowsTV' do
       pod 'ShowTVAuth'
     end
    
    # ShowsTests 继承’search_paths‘跟默认一样全部继承 ’none‘是不继承
     target 'ShowsTests' do
       inherit! :search_paths
       pod 'Specta'
       pod 'Expecta'
     end
    end
    
  • inhibit_all_warnings!屏蔽所有警告
    inhibit_warnings => true 指定屏蔽或者不屏蔽具体库的警告
    pod 'SSZipArchive', :inhibit_warnings => false

  • source 默认是官方source,但是当你使用自己的source源后,也得把官方的source显示添加进去

    source 'https://github.com/artsy/Specs.git'
    source 'https://github.com/CocoaPods/Specs.git'
    
  • plugin 安装插件
    plugin 'slather'
    pre_install 下载完安装前指定操作
    post_install 安装完写入磁盘前指定操作

    post_install do |installer|
     installer.pods_project.targets.each do |target|
       target.build_configurations.each do |config|
         config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
       end
     end
    end
    

示例

platform :ios, '9.0'
inhibit_all_warnings!

target 'MyApp' do
 pod 'ObjectiveSugar', '~> 0.5'

 target "MyAppTests" do
   inherit! :search_paths
   pod 'OCMock', '~> 2.0.1'
 end
end

post_install do |installer|
 installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
     config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
   end
 end
end

参考地址
cocoapods guides

相关文章

  • CocoaPods学习01-Podfile

    CocoaPods学习02-PodSpecCocoaPods学习03-pod install vs pod upd...

  • CocoaPods 学习

    [TOC] 项目组成 CocoaPods is composed of the following project...

  • CocoaPods学习

    网上有很多介绍CocoaPods的文章,最近感觉因为只是会简单的使用,有点不符合我们程序员的性格,所以准备仔细了解...

  • cocoapods学习

    cocoapods学习 为什么使用cocoapods? pods库依赖的其他动态,静态库全自动导入 编译参数自动设...

  • 学习cocoapods

    请原谅我还不怎么会用markdown语法。。。cocoapods是ruby写的,还好Mac自带Ruby环境。让我们...

  • cocoapods学习

    https://blog.csdn.net/u014600626/article/details/10292256...

  • CocoaPods学习03-pod install vs pod

    CocoaPods学习01-PodfileCocoaPods学习02-PodSpecCocoaPods学习04-制...

  • CocoaPods学习04-制作自己的pod库

    CocoaPods学习01-PodfileCocoaPods学习02-PodSpecCocoaPods学习03-p...

  • cocoapod学习

    学习CocoaPods [TOC] 1. 概述 此片文章主要介绍Cocoapods的一些基本命令、Podfile文...

  • CocoaPods学习02-PodSpec

    CocoaPods学习01-PodfileCocoaPods学习03-pod install vs pod upd...

网友评论

    本文标题:CocoaPods学习01-Podfile

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