iOS Development ~cocoapods use detailed instructions
I. Summary
When iOS is developed, many third-party libraries are referenced in the project, and CocoaPods (https://github.com/CocoaPods/CocoaPods) can be used to manage these third-party libraries conveniently and uniformly.
Second, installation
As the online tutorials are basically similar, but the details are not very perfect, so the opportunity will be added here:
Note: To use Cocoapods, download and install it, and download and install cocoapods requires a ruby environment
1. Building Ruby Environment
The current installation environment is Mac mini 10.8.5. The Mac OS itself comes with Ruby, but it's still an update, because the first time I installed it failed without updating Ruby.
A view the current Ruby version: Open the terminal input ruby-v (yes, but with this version the next work fails, so update under Ruby)
[OBJC] View plaincopyprint?
- Ritekimac-mini:podtest lucky$ Ruby-v
- Ruby 1. 8. 7 (201 2-02-08 patchlevel 358) [ Universal-darwin12. 0]
- Ritekimac-mini:podtest lucky$
b Update Ruby
Terminal Enter the following command (point the Ruby image to Taobao, avoid being the wall, you know)
Gem Sources--remove https://rubygems.org/
Gem Sources-a http://ruby.taobao.org/
Gem sources-l (used to check for successful use of alternate mirror locations)
[OBJC] View plaincopyprint?
- ritekimac-mini:~ lucky$ gem sources--remove https://rubygems.org/
- HTTPS://rubygems.org/removed from sources
- ritekimac-mini:~ lucky$ Gem sources-a http://ruby.taobao.org/
- http://ruby.taobao.org/added to sources
- ritekimac-mini:~ lucky$ Gem sources-l
- Current SOURCES * * *
2. Download and install Cocoapods
Terminal input: sudo gem install cocoapods
[HTML] View Plaincopyprint?
- ritekimac-mini:~ lucky$ sudo gem install cocoapods
- CHANGELOG:
- # # 0.32.1
- ##### Bug Fixes
- * Fixed the Podfile ' Default_subspec ' attribute in nested subspecs.
- [Fabio Pelosin] [Irrationalfab]
- \ [#2050] (https://github.com/CocoaPods/CocoaPods/issues/2050)
- Successfully installed cocoapods-0.32.1
- Installing RI documentation for cocoapods-0.32.1
- /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:280:warning:conflicting ChDir during another chdir block
- /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:287:warning:conflicting ChDir during another chdir block
- Done installing documentation for Cocoapods after ten seconds
- 1 Gem installed
This will download and install the Cocoapods
3. Using Cocoapods
A Create a new project, name Podtest
b terminal, CD-to-project directory (note: The head record containing the Podtest folder, Podtest.xcodeproj, Podtesttest)
[OBJC] View plaincopyprint?
- Cd/users/lucky/desktop/podtest
C build podfile (config file)
Then the last step, the terminal input vim Podfile
Keyboard input I, enter edit mode, enter
Platform:ios, ' 7.0 '
Pod ' Mbprogresshud ', ' ~> 0.8 '
Then press ESC and enter the ":" Sign into the VIM command mode and enter WQ after the colon
Note: You can enter WQ after keyboard input: Enter one more Podfile file found in the Podtest project's total directory
Exciting time to go: Determine the terminal CD to the total project directory, then enter the pod install, wait a while, about 3 minutes.
To view the project root directory:
Note: Now open the project is not click Podtest.xodeproj, but click Podtest.xcworkspace
When you open the project, you see the project structure and test it:
Operation Result:
Add:
1, the basic installation and use of cocoapods are described in detail, but there are some additions, when the need to import multiple third-party at the same time what to do?
This needs to modify the Podfile, that is, the file saved in the root directory of the project with VIM, modified the podfile file, you need to re-execute the pod install command.
For example:
Platform:ios
Pod ' Jsonkit ', ' ~> 1.4 '
Pod ' afnetworking ', ' ~> 2.0 '
2, Cocoapods can find the third-party library you want
Terminal input command: Pod search UI
Crazy, how can I find such a popular keyword, a lot of library ~ ~
Then re-edit the Podfile file and follow the previous steps to import more libraries into the project!
This blog stolen from Ford's blog, address: http://blog.csdn.net/lizhongfu2013/article/details/26384029
iOS Development ~cocoapods Use detailed instructions