一直在忙小程序,刚发现更新不了cocoapods,
终端输入cocoapods:
sudo gem update cocoapods
但是遇到如下问题:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
什么?是404 浏览器打开https://gems.ruby-china.org,发现其服务域名更换了:
于是删除gem源:
gem sources --remove https://gems.ruby-china.org/
修改gem源:
gem sources -a https://gems.ruby-china.com
查看gem源是否是最新的:
gem sources -l
升级cocoapods:
sudo gem install -n /usr/local/bin cocoapods --pre
查看升级后的cocoapods版本:
pod --version
使用Cocoapod为工程导入第三方库
1、为主工程生成Podfile
在工程的.xcodeproj目录(必须在此目录)中,执行如下命令,即可得到Podfile。
$ pod init
2、编辑Podfile文件
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'POD_DEMO' do
# ~> 后面的数字是 3.2 版本,可以省略,则安装或升级最新版本
pod 'AFNetworking','~>3.2'
end
3、生成.xcworkspace工程入口
按照上面的步骤,在子工程下面添加完成podspec之后,在主工程的Podfile对应目录下执行如下命令,即可得到对应的 *.xcworkspace工程入口。
$ pod install --no-repo-update
4、运行.xcworkspace启动工程,可以看到工程已经添加了pod
编辑Podfile文件
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
def commonPods #通用pods集
pod 'AFNetworking', '~>3.1.0'
pod 'Masonry'
end
def appOnlyPods #app专用pods集
pod 'MBProgressHUD'
end
def extensionPods #扩展专用pods集
end
source 'https://github.com/CocoaPods/Specs.git'
target 'FYXProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for FYXProject
commonPods
appOnlyPods
target 'FYXProjectTests' do
inherit! :search_paths
# Pods for testing
end
target 'FYXProjectUITests' do
# Pods for testing
end
end
常用的Pod命令:
# 创建 Podfile 文件
pod init
# 下载“Podfile”中定义的所有依赖项,并创建一个pod库
pod install
# 下载“Podfile”中定义的所有依赖项,并创建一个pod库,不更新本地代码库
pod install --no-repo-update
# 更新Podfile中依赖的框架
pod update
# 更新Podfile中依赖的框架,可以安装新框架或者删除不用的框架,但是不会升级项目已经安装的框架
pod update --no-repo-update
# 查看哪些框架有更新版本
pod outdated
# 搜索框架 #空格 下一页 #q 退出
pod search AFNetworking
# 只搜索符合名字的框架
pod search AFNetworking --simple
# 帮助命令
pod --help
#其他命令的用法可以用 命令+ --help的方式查看用法帮助
从工程中删除Cocoapod:
删除工程中的Cocoapod需要删除下列文件:
- 删除工程文件夹下的Podfile、Podfile.lock及Pods文件夹
- 删除xcworkspace文件
- 使用.xcodeproj文件打开工程,删除Frameworks组下的libPods.a引用以及Pods.xcconfig,以及残留的pod文件夹。
- 删除工程pod配置项 TARGET->Build Phases ->
[CP] Check Pods Manifest.lock
[CP] Copy Pods Resources
[CP] Embed Pods Frameworks
问题1.
有时候拷贝的Xcode工程执行时报错:
-bash: ./install.sh: /bin/bash: bad interpreter: Operation not permitted
没有执行权限,chmod 777也不行。了解一下,原来出现这个问题的主要原因是:-rwxrwxrwx@ 文件的属性最后带个@,这个@代表的是更多的一些属性,具体含义不太清楚,但有它就是执行不了
解决:在工程根目录,用这个命令来去除这个属性:
xattr -d -r com.apple.quarantine ./*
这下可以了。
1、卡在
Cloning spec repo `cocoapods` from `git@github.com:CocoaPods/Specs.git`
解决方法:
pod setup
cd ~/.cocoapods/repos
git clone --depth 1 https://github.com/CocoaPods/Specs.git master
2、如果报错:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决方法:
git config --global http.postBuffer 524288000
git config --global --list 查看配置
1.在终端输入。
ssh-keygen -t rsa -C "taoxx" (注:username为你git上的用户名)
如果执行成功。返回
Generating public/private rsa key pair.
Enter file in which to save the key (c/Users/*****/.ssh/id_rsa):
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/*****/.ssh/id_rsa):
首先,说明一下,这里的username是你电脑上的用户名
然后,在这里就是设置存储地址了.我们直接按回车,会出现一下两种情况的一种:
(1)如果正常运行的话,会出现
Enter passphrase (empty for no passphrase):
然后我们直接回车
(2)有的时候我们可能会出现
/Users/your username/.ssh/id_rsa already exists.
Overwrite (y/n)?
这说明你已经设置了存储地址,我们输入“y”覆盖
Overwrite (y/n)? y
回车
上面的任意两种情况之后,会出现
Enter same passphrase again:
再次回车,这时候你会看见:
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
58:42:8b:58:ad:4b:b5:b9:6d:79:bf:8c:f9:e2:2b:ed username
The key's randomart image is:
+--[ RSA 2048]----+
| ... |
| o oo. |
| . .ooo. |
| o o+ |
| . ..oS. |
| . . + . |
| . o . |
| . o+. |
| +E++. |
+-----------------+
这说明SSH key就已经生成了。文件目录就是:/Users/*****/.ssh/id_rsa
我们执行cat命令查看文件的内容:
cat c/User/*****/.ssh/id_rsa.pub ***是电脑用户名
这时候会看见:
ssh-rsa AAAAB3NzaC1yc2。。。。。。。。。
后面的内容我省略了
(说明:ssh-rsa 后面的内容这就是你的SSH keys,复制ssh keys的时候要全部复制下来,否则会生成密钥失败)
把显示出来的SSH keys直接添加到github账户设置里边的SSH keys
最后再执行git clone命令就可以了
强行覆盖git远程版本
git push -f origin master