Cocoapods升级后的变化
之前一直使用版本0.39,直到今天,在新创建工程,需要用 pod 来安装三方库时,提示
[!] The `master` repo requires CocoaPods 1.0.0 - (currently using 0.39.0)
Update CocoaPods, or checkout the appropriate tag in the repo.
新版本的配置文件有了一点小变化.具体写法如下:
platform :ios, '7.0'
def pods
pod 'AFNetworking', '~> 3.1.0'
end
target 'YourTargetName' do
pods
end
Tips: 你应该使用Cocoapods提供的命令 pod init 来创建一个Podfile. 生成的Podfile如下:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'iPrivate' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for iPrivate
end
升级Cocoapods
1: 先自己更新下ruby和gem先,若你已更新,那跳过吧
sudo gem update
2: 删除本地旧的master,不然可能会在更新的时候一直卡住
rm -rf ~/.cocoapods/repos/master
当然,你不用命令行也可以,直接在Finder里删除也可以
3: 直接重新安装
sudo gem install cocoapods
4: 最后的步骤(可能需要等一会,网速慢的话)
pod setup
使用pod命令更新工程
先进入你工程的根目录,根据前面所说的配置方法,生成 Podfile 文件.
pod update
可能出现的问题
Update all pods
Updating local specs repositories
CocoaPods 1.2.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0.beta.1
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
[!] The `JxCommonTestProject [Debug]` target overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting defined in `Pods/Target Support Files/Pods-JxCommonTestProject/Pods-JxCommonTestProject.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `JxCommonTestProject [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-JxCommonTestProject/Pods-JxCommonTestProject.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `JxCommonTestProject [Release]` target overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting defined in `Pods/Target Support Files/Pods-JxCommonTestProject/Pods-JxCommonTestProject.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `JxCommonTestProject [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-JxCommonTestProject/Pods-JxCommonTestProject.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
解决方法
修改下你工程的Target,在以下两处添加 $(inherited)
//修复: OTHER_LDFLAGS
Build Settings -> Other linker flags
//修复: GCC_PREPROCESSOR_DEFINITIONS
Build Settings -> Preprocessor Macros