iOScocoapods升级及问题
安装
1. 安装Ruby
CocoaPods基于Ruby语⾔开发⽽成,因此安装CocoaPods前需要安装Ruby环境。幸运的是Mac系统默认⾃带Ruby环境,如果没有请⾃⾏查安装。检测是否安装Ruby:
$ gem -v2.0.14
1. 更换gem源
因为国内⽹络的问题导致gem源间歇性中断,原因你懂的。因此我们需要更换gem源,使⽤淘宝的gem源
[/.](/%E3%80%82)
第⼀步:移除默认的源
gem sources --remove /
1. 安装CocoaPods
改成淘宝源后执⾏以下命令进⾏安装:
sudo gem install cocoapods
如果换成国内镜像使⽤ gem install cocoapods 报错:
ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: cocoapods requires cocoapods-core (= 1.1.1), cocoapods-downloader (< 2.0, >= 1.1.2), cocoapods-trunk (< 2.0, >= 1.1.1), xcodeproj (< 2.0, >= 1.3.3)
执⾏:
sudo gem update --system && sudo gem install cocoapods
报错:
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
执⾏:
sudo gem install -n /usr/local/bin cocoapods
安装完成,输⼊以下命令检测是否安装成功:
$ pod --version 1.1.1
cd到⾃⼰的项⽬⽬录下
创建Podfile
vim Podfile
如果没有创建Podfile
⽂件将⽆法安装, CocoaPods都不知道改安装说明, 怎么去安装呢, 对吧.
[!] No `Podfile' found in the project directory.
输⼊以下代码(配置⽂件,需要添加的第三⽅):
source 'github/CocoaPods/Specs.git'
platform :ios, '8.0'
inhibit_all_warnings!
target '⼯程名' do
pod 'AFNetworking', '~> 2.6.0'
end
然后保存退出
esc
:wq
执⾏
pod update OR pod install。
如果报错:
[!] Unable to add a source with url `github/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
执⾏:女子银行存5万被要求出具收入证明
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer(xcode⽬录)
红⾊部分是我的Xcode的路径,注意上⾯的代码中的"--"和"select"之间有⼀个空格。
解决⽅法可以使⽤⼀下代码:
⼜产⽣的问题:⼀般这个时候会输出--unalbe to get active developer directory
要求配置低的网游defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE;killall Finder
这样的话就可以了,然后⽤你的Xcode的路径代替上⾯的红⾊的部分就可以了。
问题描述
1:[!] The 'master' repo requires CocoaPods 1.0.0 - (currently using 0.39.0) Update CocoaPods, or checkout the appropriate tag in the repo.
问题原因:没有更新到最新cocoapods版本
sudo gem install -n /usr/local/bin cocoapods –pre
如果报错或其他问题
sudo gem update --system && sudo gem install cocoapods
出现报错信息:
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
执⾏:
sudo gem install -n /usr/local/bin cocoapods
输⼊以下命令检测是否成功:
pod --version 1.1.1
2:[!] The dependency `AFNetworking (~> 2.6.0)` is not used in any concrete target.等
问题原因:podfile升级到最新版本,pod⾥的内容必须明确指出所⽤第三⽅库的target
可以修改Podfile⽂件的配置⽂件,让它兼容不指定固定版本;且⼜不报错
platform :ios, '8.0'
inhibit_all_warnings!
target '⼯程名' do
pod 'AFNetworking', '~> 2.6.0'
end
3:Updating local specs repositories
遇到pod install或者pod update长时间卡在Updating local specs repositories
常见的解决⽅式是跳过更新cocoapods的spec仓库
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
最好的办法是
初二语文教学计划pod repo remove master
pod setup
pod install
4:[!]Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
不要使⽤⽂本编辑去编辑Podfile,使⽤Xcode编辑,或者使⽤终端敲命令去编辑。或者输⼊格式错误,没输⼊运⾏版本:$platform:ios, ‘8.0‘
5:使⽤cocoapods导⼊第三⽅类库后头⽂件没有代码提⽰?
选择Target -> Build Settings 菜单,到\”User Header Search Paths\”设置项,新增⼀个值"${SRCROOT}",并且选择\”Recursive\”
6:[!]Unable to find a target named ' ';
Podfile的⼯程⽂件和建⽴⼯程名不⼀致。名字改为⼀致即可
7:syntax error ,unexpected end-of-input,expecting keyword_end
podfile写法有问题,使⽤标准的podfile的写法
platform :ios, '8.0'
inhibit_all_warnings!
target '⼯程名' do
pod 'AFNetworking', '~> 2.6.0'
end
8: Analyzing dependencies
[!]Could not automatically select an Xcode project . Specify one in your Podfile like 50 : xcodeproj ' path / to / Project . xcodeproj
英文空间名字 ⾃⼰建⽴了⼀个空⽂件夹,没有建⽴⼯程
处理⽅法:删除这个空⼯程,重新建⽴⼀个⼯程,再按照上⾯知识点讲解⼀步步来即可。
9:pod 导⼊后出现"_OBJC_CLASS_$_xxx"
target->build phases->link binary with libraries添加xxx.a
如果不是pod导⼊的类库,出现这种问题
原因:在创建类的时候没有勾选"add to targets"
target->build phases->compile sources 添加.h,.m⽂件fpx战队是哪个国家的
或(建议⽤上⾯)
在Build Setting 中的Other Linker Flags选项中加⼊$(OTHER_LDFLAGS)
10:Xcode - ld: library not found for -lPods
当新增加⼀个Target,并且pod install后,由于创建项⽬是默认创建的Target的Build Phases中引⽤了
旧的.a,例如libPods.a,当新增加Targget后,libPods.a已经变成了libPods-Test.a,⽽新增加的Target名字为Second,依赖的.a为libPods-Second.a。所以libPods.a此时已经不再被引⽤,并且不会被⽣成,如果任何地⽅引⽤了就会报错,解决办法是出现问题的Target的Build Phases中删除⽆⽤的.a引⽤,例如libPods.a
target->build phases->link binary with libraries
11:pod 导⼊库,不到头⽂件
在TARGETS -> Search Paths -> User Header Search Paths 中写⼊ ${SRCROOT}再将后⾯参数改为recursive:
12:如果要移除Cocoapods,则可以:
a. 删除⼯程⽂件夹下的Podfile、Podfile.lock及Pods⽂件夹
b. 删除xcworkspace⽂件
c. 使⽤xcodeproj⽂件打开⼯程,删除Frameworks组下的fig及libPods.a引⽤
d. 在⼯程设置中的Build Phases下删除Check Pods Manifest.lock及Copy Pods Resources
不⼩⼼删除fig,出现diff: /../Podfile.lock: No such file or directory
sudo pod install⼀下就好了
如果编译的时候出现权限问题,对⼯程⽂件夹$sudo chmod 777 path-to-project-folder/*
$sudo chown 777 path-to-project-folder/*
13:出现/Library/Ruby/Gems/2.0.0/gems/claide-0.8.1/lib/claide/command.rb:417:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
重新打开⼀个终端,然后pod install,不要sudo pod install。
14:删除CocoaPods版本,并安装指定版本
⽐如我本来安装完CocoaPods 1.0.0版,但发现它实现跟先前还是差别满⼤的,决定降回0.39这个⽐较稳定版本;就可以⽤命令先删除本地的CocoaPods版本,再指定安装特定版本;
a 卸载 cocoapods(它会提⽰你要删除本地哪个版也可以全删)
sudo gem uninstall cocoapods
b 安装 0.39版本
sudo gem install -n /usr/local/bin cocoapods -v 0.39
15:更新 CocoaPods 或者以前⼿动添加过第三⽅SDK改⽤Cocopods,可能会出现以下的错误
错误1:
[!] The `Paopao [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/fig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Paopao [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/fig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
-
Remove the build settings from the target.
[!] The `Paopao [Release]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/fig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Paopao [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/fig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or
- Remove the build settings from the target.
产⽣此警告的原因是项⽬ Target 中的⼀些设置,CocoaPods 也做了默认的设置,如果两个设置结果不⼀致,就会造成问题。
我想要使⽤ CocoaPods 中的设置,分别在我的项⽬中定义PODS_ROOT和Other Linker Flags的地⽅,把他们的值⽤$(inherited)替换掉,进⼊终端,执⾏
文员岗位职责pod update
警告没了
⼀种简单粗暴的⽅法:
点击项⽬⽂件 deproj,右键显⽰包内容,⽤⽂本编辑器打开project.pbxproj,删除OTHER_LDFLAGS的地⽅,保存,pod update,警告没了。。。。
16:
17:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论