热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

GettingStartedwithCocoaPods

2019独角兽企业重金招聘Python工程师标准CocoaPodsisanopensourcelibrarymanagementtoolforObjective-C(both

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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

Screen Shot 2013-09-10 at 4.17.53 PM.png

Cool.

Now we need to import the SVProgressHUD.h header. Since it's in another Xcode project, make sure to use angle brackets.

#import 

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


推荐阅读
author-avatar
Aqingking_577
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有