在搜索CocoaPads的教程裏,在一個技術blog裏看到一句話:如今還不用CocoaPads,我只能說你太low了!所以爲了方便第三方庫的使用,開始使用CocoaPads;css
Google上一搜,很感謝那些無私奉獻的大牛們,不管什麼樣的技術都會有各類的教程以及各類技術筆記供使用者參考;ios
我搜的第一篇是唐巧的技術blog使用CocoaPods來作iOS程序的包依賴管理,寫的很好,不過對於我這種菜鳥仍是有不少問題;git
因而繼續搜索更適合菜鳥的博客,搜到菜鳥安裝 CocoaPods,按照來用,打開Terminal,github
(PS:如下粉色的字是我輸入的命令)json
以下步驟:api
MichaeldeMac-mini:~ md004$ sudo gem install cocoapods WARNING: Improper use of the sudo command could lead to data loss or the deletion of important system files. Please double-check your typing when using sudo. Type "man sudo" for more information. To proceed, enter your password, or type Ctrl-C to abort. Password: Building native extensions. This could take a while... Building native extensions. This could take a while... [!] You are using the prebuilt binary version of the xcodeproj gem. CHANGELOG: ## 0.28.0 [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.27.1...0.28.0)
• [CocoaPods-core](https://github.com/CocoaPods/Core/compare/0.27.1...0.28.0)
• [CLAide](https://github.com/CocoaPods/CLAide/compare/0.3.2...0.4.0)
###### Enhancements * CLAide now supports gem plugins. An example CocoaPods plugin can be found at [open\_pod\_bay](https://github.com/leshill/open_pod_bay).
\ As of yet there are no promises made yet on the APIs, so try to fail as gracefully as possible in case a CocoaPods update breaks your usage. In these cases, also please let us know what you would need, so we can take this into account when we do finalize APIs. [Les Hill](https://github.com/leshill)
[CLAide#1](https://github.com/CocoaPods/CLAide/pull/1)
\ [#959](https://github.com/CocoaPods/CocoaPods/issues/959)
###### Bug Fixes * Compiling `xcassets` with `actool` now uses `UNLOCALIZED_RESOURCES_FOLDER_PATH` \ instead of `PRODUCT_NAME.WRAPPER_EXTENSION` as output directory as it is more \ accurate and allows the project to overwrite `WRAPPER_NAME`. [Marc Knaup](https://github.com/fluidsonic)
\ [#1556](https://github.com/CocoaPods/CocoaPods/pull/1556)
* Added a condition to avoid compiling xcassets when `WRAPPER_EXTENSION` is undefined, as it would be in the case of static libraries. This prevents trying to copy the compiled files to a directory that does not exist. [Noah McCann](https://github.com/nmccann)
\ [#1521](https://github.com/CocoaPods/CocoaPods/pull/1521)
* Added additional condition to check if `actool` is available when compiling `xcassets`. This prevents build failures of Xcode 5 projects on Travis CI (or lower Xcode versions). \ [Michal Konturek](https://github.com/michalkonturek)
[#1511](https://github.com/CocoaPods/CocoaPods/pull/1511)
* Added a condition to properly handle universal or mac apps when compiling xcassets. This prevents build errors in the xcassets compilation stage particularly when using xctool to build. [Ryan Marsh](https://github.com/ryanwmarsh)
[#1594](https://github.com/CocoaPods/CocoaPods/pull/1594)
* Vendored Libraries now correctly affect whether a podspec is considered empty. \ [Joshua Kalpin](https://github.com/Kapin)
[Core#38](https://github.com/CocoaPods/Core/pull/38)
* Vendored Libraries and Vendored Frameworks now have their paths validated correctly. \ [Joshua Kalpin](https://github.com/Kapin)
[#1567](https://github.com/CocoaPods/CocoaPods/pull/1567)
* Gists are now correctly accepted with https. [Joshua Kalpin](https://github.com/Kapin)
\ [Core#38](https://github.com/CocoaPods/Core/pull/38)
* The `pod push` command is now more specific about the branch it pushes to. [orta](http://orta.github.io)
\ [#1561](https://github.com/CocoaPods/CocoaPods/pull/1561)
* Dtrace files are now properly left unflagged when installing, regardless of configuration. [Swizzlr](https://github.com/swizzlr)
\ [#1560](https://github.com/CocoaPods/CocoaPods/pull/1560)
* Users are now warned if their terminal encoding is not UTF-8. This fixes an issue with a small percentage of pod names that are incompatible with ASCII. [Joshua Kalpin](https://github.com/Kapin)
\ [#1570](https://github.com/CocoaPods/CocoaPods/pull/1570)
Successfully installed i18n-0.6.9 Successfully installed multi_json-1.8.2 Successfully installed activesupport-3.2.16 Successfully installed nap-0.6.0 Successfully installed json-1.8.1 Successfully installed fuzzy_match-2.0.4 Successfully installed cocoapods-core-0.28.0 Successfully installed claide-0.4.0 Successfully installed cocoapods-downloader-0.2.0 Successfully installed rake-10.1.0 Successfully installed colored-1.2 Successfully installed xcodeproj-0.14.1 Successfully installed escape-0.0.4 Successfully installed json_pure-1.8.1 Successfully installed open4-1.3.0 Successfully installed cocoapods-0.28.0
16 gems installed Installing ri documentation for i18n-0.6.9... Installing ri documentation for multi_json-1.8.2... Installing ri documentation for activesupport-3.2.16... unrecognized option `--encoding' For help on options, try 'rdoc --help'
MichaeldeMac-mini:~ md004$ pod setup Setting up CocoaPods master repo /Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/executable.rb:55: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/executable.rb:55: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/executable.rb:55: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777 Setup completed (read-only access)
完成了CocoaPods的安裝,而後我嘗試去搜索一個JSONKit第三方庫,以下:xcode
MichaeldeMac-mini:~ md004$ pod search JSONKit -> JSONKit (1.5pre) /Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/user_interface.rb:277: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777 A Very High Performance Objective-C JSON Library. /Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/user_interface.rb:277: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777 pod 'JSONKit', '~> 1.5pre'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/user_interface.rb:277: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777
- Homepage: https://github.com/johnezang/JSONKit
/Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/user_interface.rb:277: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777
- Source: https://github.com/johnezang/JSONKit.git
/Library/Ruby/Gems/1.8/gems/cocoapods-0.28.0/lib/cocoapods/user_interface.rb:277: warning: Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777
- Versions: 1.5pre, 1.4 [master repo]
看到了不少警告,很不爽,不知道爲何,悲劇了一會,用中文搜索沒搜到結果,果斷上Google吧,在Google裏直接輸入warning: Insecure world writable dirpromise
而後就搜到了StackOverFlow,app
接着輸入命令:less
MichaeldeMac-mini:~ md004$ sudo chmod go-w /Users/md004/Desktop MichaeldeMac-mini:~ md004$ pod search JSONKit -> JSONKit (1.5pre) A Very High Performance Objective-C JSON Library. pod 'JSONKit', '~> 1.5pre'
- Homepage: https://github.com/johnezang/JSONKit
- Source: https://github.com/johnezang/JSONKit.git
- Versions: 1.5pre, 1.4 [master repo] MichaeldeMac-mini:~ md004$
這樣就正常了,這裏要記住警告Insecure world writable dir /Users/md004/Desktop in PATH, mode 040777,在你要改變權限的時候sudo chmod go-w /Users/md004/Desktop,必定要跟警告處的目錄是同樣的。
祝您愉快開心 ^_^