Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
roycms
IosCodeSpecification
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
IosCodeSpecification
/
cocoasPod-basic.md
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
48 lines (42 loc) · 2.38 KB
master
Breadcrumbs
IosCodeSpecification
/
cocoasPod-basic.md
Copy path
Top
File metadata and controls
Code
Blame
48 lines (42 loc) · 2.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## CocoasPod
### CocoaPods 安装前准备
* 移除Ruby默认源
* gem sources --remove https://rubygems.org/
* 使用新的源
* gem sources -a https://ruby.taobao.org/
* 验证新源是否替换成功
* gem sources -l
* 替换成功后
* *** CURRENT SOURCES * * *
* https://ruby.taobao.org/
### CocoaPods 安装
* sudo gem install cocoapods
* **注意:苹果系统升级 OS X EL Capitan 后改为:
sudo gem install -n /usr/local/bin cocoapods (v1.0.0)**
* pod setup(//将 CocoaPods Specs repository复制到你电脑上~/.cocoapods目录下)
* sudo gem update --system
### CocoaPods 的使用
* 如果你计划增加外部依赖(比如,第三方库)在你的项目中,CocoaPods 提供了一个快捷的途径.
* 新建工程,并在终端中cd到工程文件夹内,在你的 iOS 项目目录下运行:
```
pod init
```
* 它会创建一个 Podfile, 会管理你所有的依赖,在 Podfile 中加入你的依赖
* 编辑文件:platform:ios, '6.0'
pod 'AFNetworking', '~> 2.3.1' <-------第三方
* 执行下面命令安装
```
pod install
```
* 来安装第三方库并且将它们作为 workspace 的一部分,你的 workspace 也会包含你自己的项目。
* 一般推荐提交你自己的项目的依赖,而不是每个开发者在一个 checkout之后运行 pod install 。
* 注意在之后,你需要打开 .xcworkspace 而不是 .xcproject,否则你的代码就不能被编译了,命令:
```
pod update
```
会升级所有的 pod 到最新版本,你可以用大量 符号 来定义你期望的版本需求。
关于 Podfile.lock
当你执行pod install之后,除了 Podfile 外,CocoaPods 还会生成一个名为Podfile.lock的文件,Podfile.lock 应该加入到版本控制里面,不应该把这个文件加入到.gitignore中。因为Podfile.lock会锁定当前各依赖库的版本,之后如果多次执行pod install 不会更改版本,要pod update才会改Podfile.lock了。这样多人协作的时候,可以防止第三方库升级时造成大家各自的第三方库版本不一致。
## 将代码提交到CocoaPods
*如果你在github共享了一段代码,你想把代码提交到CocoaPods,希望其他用户search 你的项目的名称就可以找到你,并且 pod install 集成你的代码到项目内,你就需要学会怎样将自己的代码先提交给 CocoaPods servers.
>http://www.cnblogs.com/wengzilin/p/4742530.html
You can’t perform that action at this time.