Getting Started with CocoaPods
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
CocoaPods is an open source library management tool for Objective-C (both iOS and OS X). This article is going to briefly take you through how to get started. This is meant t0 be a quick-fire demo – check out the?Getting Started?guide for more details.
A CocoaPod (singular) is a specification for a library, usually open source. CocoaPods (plural) is the tool for managing these specs.
First, you'll need to install CocoaPods. That's pretty easy since CocoaPods is a Ruby Gem, and all Macs ship with Ruby. Open a terminal and type the following (it'll ask you for your password):
sudo?gem?install?cocoapodsThat'll install CocoaPods on your machine.
Next, you'll need an Xcode project that you want to integrate. Use?cd?to navigate to the working directory of your app.
cd?~/Desktop/DemoNext, type the following command:
pod?initThis command creates an empty Podfile for you. Open it in a text editor. It'll look like the following.
#?Uncomment?this?line?to?define?a?global?platform?for?your?project #?platform?:ios,?"6.0"target?"Demo"?doendtarget?"DemoTests"?doendUncomment the second line to specify the platform (iOS) and the version (6). For your target (the first target), enter?pod "SVProgressHUD", "0.9".
platform?:ios,?"6.0"target?"Demo"?dopod?"SVProgressHUD",?"0.9"endtarget?"DemoTests"?doendSave the file and return to the text editor. Enter the following command.
pod?installThis will produce the following output.
>?pod?install Analyzing?dependencies Downloading?dependencies Installing?SVProgressHUD?(0.9) Generating?Pods?project Integrating?client?project[!]?From?now?on?use?`Demo.xcworkspace`.Follow the last line's instruction and close your Xcode project and open the Xcode Workspace file that's been created for you. An Xcode workspace is like a folder for Xcode projects. Your Pods project contains all of the libraries (pods).
Cool.
Now we need to import the?SVProgressHUD.h?header. Since it's in another Xcode project, make sure to use angle brackets.
#import?<SVProgressHUD.h>That's it! We can now use our library. We've successfully integrated CocoaPods into our project. For each library you want to use, write?pod "POD_NAME", "POD_VERSION"?in your Podfile and re-run?pod install.
There's an?Xcode plugin?for CocoaPods if you're not into the command line.
I gave a talk this morning on effectively using open source software. The slides are below.
轉(zhuǎn)載于:https://my.oschina.net/w11h22j33/blog/204456
總結(jié)
以上是生活随笔為你收集整理的Getting Started with CocoaPods的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux shell编程学习笔记(9)
- 下一篇: oracle基础之工具系列(持续更新中,