iOS cocoapods升级及问题

时间:2021-07-13 02:54:44

安装

  1. 安装Ruby
    CocoaPods基于Ruby语言开发而成,因此安装CocoaPods前需要安装Ruby环境。幸运的是Mac系统默认自带Ruby环境,如果没有请自行查找安装。检测是否安装Ruby:
    $ gem -v2.0.14

安装则会提示当前Ruby版本。gem介绍:gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/ )源来查找、安装、升级和卸载软件包,非常的便捷。

  1. 更换gem源
    因为国内网络的问题导致gem源间歇性中断,原因你懂的。因此我们需要更换gem源,使用淘宝的gem源
    [https://ruby.taobao.org/.](https://ruby.taobao.org/%E3%80%82)
    第一步:移除默认的源
    gem sources --remove https://rubygems.org/

第二步:指定淘宝的源
gem sources -a https://ruby.taobao.org/

第三步:查看指定的源是不是淘宝源
$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org/

如果是https://ruby.taobao.org/,则更换成功。

  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 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

  inhibit_all_warnings!

  target '工程名' do

  pod 'AFNetworking', '~> 2.6.0'

  end

然后保存退出
esc
:wq
执行
pod updateOR pod install
如果报错:

[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

执行:
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文件

  或(建议用上面)
  在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组下的Pods.xcconfig及libPods.a引用

  d. 在工程设置中的Build Phases下删除Check Pods Manifest.lock及Copy Pods Resources

  不小心删除pods.xcconfig,出现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/Pods.debug.xcconfig'. 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/Pods.debug.xcconfig'. 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/Pods/Pods.release.xcconfig'. 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/Pods/Pods.release.xcconfig'. 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_ROOTOther Linker Flags的地方,把他们的值用$(inherited)替换掉,进入终端,执行

      pod update

  警告没了

  一种简单粗暴的方法:

  点击项目文件 project.xcodeproj,右键显示包内容,用文本编辑器打开project.pbxproj,删除OTHER_LDFLAGS的地方,保存,pod update,警告没了。。。。

16:

17:

 

iOS cocoapods升级及问题的更多相关文章

  1. CocoaPods升级安装三方库报错

    CocoaPods升级后(最新版本1.0.1),安装第三方库的时候会报如下错误: The dependency `AFNetworking (~> 3.1.0)` is not used in ...

  2. iOS&colon;CocoaPods详解

    原文地址:http://blog.csdn.net/wzzvictory/article/details/18737437 一.什么是CocoaPods 1.为什么需要CocoaPods 在进行iOS ...

  3. IOS CocoaPods详细使用方法

    自从有了CocoaPods以后,这些繁杂的工作就不再需要我们亲力亲为了,只需要我们做好少量的配置工作,CocoaPods会为我们做好一切   一.什么是CocoaPods 1.为什么需要CocoaPo ...

  4. IOS CocoaPods的用法

    自从有了CocoaPods以后,这些繁杂的工作就不再需要我们亲力亲为了,只需要我们做好少量的配置工作,CocoaPods会为我们做好一切   一.什么是CocoaPods 1.为什么需要CocoaPo ...

  5. 实验5&colon; IOS的升级与恢复

    实验5:  IOS的升级与恢复 实验目的 通过本实验可以掌握 1)    掌握IOS 正常的情况下升级IOS2)    IOS 丢失的情况下使用TFTP恢复IOS3)    IOS 丢失的情况下使用X ...

  6. iOS -- CocoaPods

    CocoaPods 是什么? CocoaPods 是一个负责管理 iOS 项目中第三方开源库的工具.CocoaPods 的项目源码在 GitHub( https://github.com/CocoaP ...

  7. iOS CocoaPods 版本安装问题

    今天安装salesforce中的pods,这是里面的podfile # Uncomment this line to define a global platform for your project ...

  8. iOS - CocoaPods 第三方开源框架管理

    1.CocoaPods CocoaPods 是一个负责管理 iOS 项目中第三方开源库的工具.CocoaPods 的项目源码在 Github 上管理.该项目开始于 2011 年 8 月 12 日,在这 ...

  9. iOS CocoaPods安装和使用图解

    Cocoapods安装步骤 1.升级Ruby环境 sudo gem update --system 如果Ruby没有安装,请参考 如何在Mac OS X上安装 Ruby运行环境 2.安装CocoaPo ...

随机推荐

  1. smtplib&period;SMTPAuthenticationError&colon; &lpar;535&comma; b&&num;39&semi;Error&colon; authentication failed&&num;39&semi;&rpar;解决办法

    raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'Error: authentica ...

  2. c&num;语句 类

    知识点: 1.string类 2.Math类 3.DateTime  获取时间 for穷举 1.羽毛球拍15元,球3元,水2元.现有200元,每种至少买一个,共有多少种可能.

  3. VBA中自定义类和事件的&lpar;伪&rpar;注册

    想了解一下VBA中自定义类和事件,以及注册事件处理程序的方法. 折腾了大半天,觉得这样的方式实在称不上“注册”,所以加一个“伪”字.纯粹是瞎试,原理也还没有摸透.先留着,有时间再接着摸. 做以下尝试: ...

  4. MySQL数据库InnoDB存储引擎多版本控制&lpar;MVCC&rpar;实现原理分析

    文/何登成 导读:   来自网易研究院的MySQL内核技术研究人何登成,把MySQL数据库InnoDB存储引擎的多版本控制(简称:MVCC)实现原理,做了深入的研究与详细的文字图表分析,方便大家理解I ...

  5. C语言第二节概述

    学前提醒 其实iOS开发就是开发iPhone\iPad上的软件,而要想开发一款软件,首先要学习程序设计语言 iOS开发需要学习的主要程序设计语言有:C语言.C++.Objective-C,其中C++. ...

  6. Android自定义UI的实现和应用

    在Android项目开发中,不可避免的要遇到自定义的UI,用较好的体验去讨好UED妹子和交互设计师手下留情~几个迭代下来,遇到了不少这样的要求,有简单有复杂.最好的实现方案就是讲业务和UI隔离,封装成 ...

  7. OpenGL ES着色器语言之着色概览(官方文档)

    OpenGL ES着色器语言之着色概览(官方文档第二章) 事实上,OpenGL ES着色语言是两种紧密关联的语言.这些语言用来在OpenGL ES处理管线的可编程处理器创建着色器. 在本文档中,除非另 ...

  8. iOS图形手势识别框架SGGestureRecognizer

    简介 苹果官方为我们提供了简单手势的识别器,但对于图形手势,例如五角星.三角形等的识别,就需要自己实现了.通过识别这些手势,可以去执行特定的操作,或是输入公式.释放魔法等,可以为App增光添彩. 下载 ...

  9. 代码雨 html实现

    <!DOCTYPE html> <html>    <head>        <meta charset="utf-8">    ...

  10. Android学习:自定义组件,DrawView

    布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...