日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Getting Started with CocoaPods

發布時間:2025/4/16 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Getting Started with CocoaPods 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

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?cocoapods

That'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/Demo

Next, type the following command:

pod?init

This 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"?doend

Uncomment 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"?doend

Save the file and return to the text editor. Enter the following command.

pod?install

This 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.


轉載于:https://my.oschina.net/w11h22j33/blog/204456

總結

以上是生活随笔為你收集整理的Getting Started with CocoaPods的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。