开始使用CocoaPods管理第3方库
2015-10-10 10:51
411 查看
Start 3rd-Lib with CocoaPods
Xcode 5, using the iOS 7 SDK.
CocoaPods is distributed as a ruby gem, and is installed by running the following commands in Terminal.app:
注意:如果一直卡在[Setting up CocoaPods master repo],出现Setting up CocoaPods master repo,说明Cocoapods在将它的信息下载到 ~/.cocoapods里,cd 到该目录里,
用du -sh *命令来查看文件大小,每隔几分钟查看一次,我的这个目录最终大小是123M,就是完成了
注意:
如果报错[The dependency
低版本的cocoa pods在编写Podfile文件时这样写就可以了
platform :ios, ‘7.0’
pod ‘AFNetworking’
高版本的cocoa pods在编写Podfile文件必须这样写
platform :ios, ‘7.0’
target “targetName” do
pod ‘AFNetworking’
end
注意:如果报错【CocoaPods did not set the base configuration of your project because because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target BluePlaquesLondonFramework to Pods/Target Support Files/Pods/Pods.debug.xcconfig or include the Pods/Target Support Files/Pods/Pods.debug.xcconfig in your build configuration.】
解决办法:【 what fixed it for me was to change the configuration file setting to None for the two Pods-related targets, then run pod install again.
The configuration file setting is found by selecting the project (not the target) and then the Info tab.】
Depending on your Ruby installation, you may not have to run as
You just created the pod file and opened it using Xcode! Ready to add some content to the empty pod file?
Copy and paste the following lines into the TextEdit window:
You shouldn’t use TextEdit to edit the pod file because TextEdit likes to replace standard quotes with more graphically appealing quotes. This can cause CocoaPods to get confused and display errors, so it’s best to just use Xcode or another programming text editor.
From now on, be sure to always open the generated Xcode workspace (
Xcode 5, using the iOS 7 SDK.
Step 1: Download CocoaPods
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects.CocoaPods is distributed as a ruby gem, and is installed by running the following commands in Terminal.app:
$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/ $ gem sources -l $ sudo gem install cocoapods $ pod setup
注意:如果一直卡在[Setting up CocoaPods master repo],出现Setting up CocoaPods master repo,说明Cocoapods在将它的信息下载到 ~/.cocoapods里,cd 到该目录里,
用du -sh *命令来查看文件大小,每隔几分钟查看一次,我的这个目录最终大小是123M,就是完成了
注意:
如果报错[The dependency
FMDBis not used in any concrete target]
低版本的cocoa pods在编写Podfile文件时这样写就可以了
platform :ios, ‘7.0’
pod ‘AFNetworking’
高版本的cocoa pods在编写Podfile文件必须这样写
platform :ios, ‘7.0’
target “targetName” do
pod ‘AFNetworking’
end
注意:如果报错【CocoaPods did not set the base configuration of your project because because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target BluePlaquesLondonFramework to Pods/Target Support Files/Pods/Pods.debug.xcconfig or include the Pods/Target Support Files/Pods/Pods.debug.xcconfig in your build configuration.】
解决办法:【 what fixed it for me was to change the configuration file setting to None for the two Pods-related targets, then run pod install again.
The configuration file setting is found by selecting the project (not the target) and then the Info tab.】
Depending on your Ruby installation, you may not have to run as
sudoto install the cocoapods gem.
Step 2: Create a Podfile
Project dependencies to be managed by CocoaPods are specified in a file calledPodfile. Create this file in the same directory as your Xcode project (
.xcodeproj) file:
$ touch Podfile $ open -a Xcode Podfile
You just created the pod file and opened it using Xcode! Ready to add some content to the empty pod file?
Copy and paste the following lines into the TextEdit window:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' pod 'AFNetworking', '~> 2.5'
You shouldn’t use TextEdit to edit the pod file because TextEdit likes to replace standard quotes with more graphically appealing quotes. This can cause CocoaPods to get confused and display errors, so it’s best to just use Xcode or another programming text editor.
Step 3: Install Dependencies
Now you can install the dependencies in your project:$ pod install
From now on, be sure to always open the generated Xcode workspace (
.xcworkspace) instead of the project file when building your project:
$ open <YourProjectName>.xcworkspace
Step 4: Dive In!
At this point, everything’s in place for you to start using AFNetworking. Just#importthe headers for the classes you need and get to it!
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- 举例详解iOS开发过程中的沙盒机制与文件
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器
- IOS开发第三方语音-微信语音
- iOS开发之路--微博OAuth授权_取得用户授权的accessToken
- 基于UIControl控件实现ios点赞功能
- iOS开发中实现邮件和短信发送的简单示例