博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Getting Started with CocoaPods
阅读量:5992 次
发布时间:2019-06-20

本文共 2380 字,大约阅读时间需要 7 分钟。

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  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 installAnalyzing dependenciesDownloading dependenciesInstalling SVProgressHUD (0.9)Generating Pods projectIntegrating 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  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

你可能感兴趣的文章
EXT.NET GridPanel绑定XML里的数据
查看>>
我的友情链接
查看>>
【思科防火墙】思科ASA防火墙企业网实例
查看>>
iOS开发之数据存储之SQLite3(包括FMDB)
查看>>
我的友情链接
查看>>
AppCan:打造成云生态的移动PaaS平台
查看>>
安装 percona-xtrabackup
查看>>
我的友情链接
查看>>
通过docker部署hadoop集群
查看>>
Python-day3作业-haproxy配置文件管理脚本
查看>>
一天一点T-SQL:获取表&索引在数据库中存储位置
查看>>
我的友情链接
查看>>
(一)MVC模型、django框架、创建app项目
查看>>
TOMCAT-SSL双向认证-配置实例
查看>>
iOS动画
查看>>
【更新】Project 读写管理控件Aspose.Tasks V17.5发布 | 附下载
查看>>
rpmdb: unable to join the environment
查看>>
三星Galaxy Book设备即将来袭
查看>>
centos 6.5 nagios 4.0.8安装
查看>>
极速理解设计模式系列:6.适配器模式(Adapter Pattern)
查看>>