使用CocoaPods For Mac

使用CocoaPods For Mac

· CocoaPods的安装

CocoaPods可以方便地通过Mac自带的RubyGems安装

1.设置ruby的软件源

gem sources  -l #查看当前ruby

gem sources–remove https://rubygems.org/       #移除当前ruby的源

gem sources –a https://ruby.taobao.org/  #设置ruby

 

2.设置gem为最新版本

sudo gem update–system             # 升级成功提示: Latest version currently installed.Aborting


3.执行安装CocoaPods

sudo gem installcocoapods          # 安装成功提示:Setup completed    

du –sh *                # 查看当前目录存储大小

pod setup            # repo 本地库更新


4.安装错误解决

ERROR: Whileexecuting gem … (Errno::EPERM)

Operation notpermitted - /user/bin/xcodeproj

解决1

sudo nvram boot–args=”rootless=0”

sudo reboot

重启后检查

sudo gem installcocoapods –V

解决2

sudo gem install–n /usr/local/bin cocoapods

pod setup


· CocoaPods的使用

1.Podfile文件

source 'URL'                 # 指定镜像仓库的源

platform :ios, '7.0'                   # 指定所支持系统和最低版本

inhibit_all_warnings!        # 屏蔽所有的warning

workspace '项目空间名'      # 指定项目空间名

xcodeproj '工程文件名'      # 工程文件名

use_frameworks!

target 'tag name' do

pod 'MBProgressHUD','~>1.0.1' # 版本符号~>><>=<=

pod '库名', :podspec => 'podspec文件路径'

pod '库名', :git => '源码git地址'

pod '库名', :tag => 'tag'

end


2.使用命令

pod searchAFNetworking             # 查找第三方库

pod install                                                #安装配置CocoaPods.xcworkspace

pod update                                            # 更新

    


 

 

· CocoaPods库配置

1.podspec文件

#例子:

Pod::Spec.new do |s|

s.name             = "NEUtility"

s.version          = "0.0.1"

s.summary          = "Utility for iOSdevelopment"

s.homepage         = "https://github.com/NEIL0814/NEUtility"

s.license          = { :type => 'MIT', :file =>'LICENSE' }

s.author           = { "NEIL" =>"[email protected]" }

s.source           = { :git =>"https://github.com/NEIL0814/NEUtility.git", :tag =>s.version.to_s }


s.platform     = :ios, '7.0'

s.requires_arc = true

s.source_files ='NEUtility/*.{h,m}'

s.public_header_files ='NEUtility/*.h'

s.frameworks = 'Foundation','UIKit'

s.dependency 'MBProgressHUD'

end


pod lib lint     #验证


git add –A && git commit –m “Release 1.0.1”

git push origin master                   # 上传依赖文件到repo

git tag ‘1.0.1’

git push –tags                    # git tag 标注


set the new versionn to 1.0.1    # pod 版本

set the new tag to 1.0.1                                  # pod 标注tag

2.发布

CocoaPods不通过密码来验证用户,而是通过一个session token

pod trunkregister [email protected] NEIL0814' --description='macbook pro' –verbose                               # 注册trunk

pod trunk me                      #查看自己的注册信息

pod trunk push NEUtilit.podspec                  # 上传到 trunk

你可能感兴趣的:(Cocoa,移动,iOS)