1、Homebrew + Ruby + Cocoapods

按顺序安装:

Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Ruby

brew install ruby

Cocoapods

如果是协同开发,注意统一版本号
  • :查看当前镜像 gem source -l ,如果是 https://rubygems.org/,可以进行换源操作(如果配了梯子,可以使用默认源):
gem sources --remove https://rubygems.org/ 
gem sources --add https://gems.ruby-china.com/
  • 安装
sudo gem install cocoapods  
或 sudo gem install -n /usr/local/bin cocoapods —pre
  • 配置:安装完成之后执行pod setup配置cocoapods。

  • 问题1:网速慢导致的失败
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
[!] /usr/bin/git clone https://github.com/CocoaPods/... master —progress

先将本地仓库删掉,执行pod repo remove master,之后尝试用以下方式解决:

  1. 手动clone:

    cd ~/.cocoapods/repos   #前往repos目录
    git clone https://github.com/CocoaPods/Specs.git  
    # 完成后将 specs 改名为 master 即可
  2. 配置梯子后使用默认源:

把源换回 https://rubygems.org/ 尝试用默认源进行pod setup

  1. 尝试使用其他源:

https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/
https://gitclub.cn/CocoaPods/Specs
使用这种方法需要在自己工程的podfile第一行加上:
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'


  • 问题2:pod search查询出错
[!] Unable to find a pod with name, author, summary ...

pod setup成功后会生成~/Library/Caches/CocoaPods/search_index.json文件。
终端输入rm ~/Library/Caches/CocoaPods/search_index.json,删除成功后再执行pod search

参考:《Cocoapods: pod search无法搜索到类库的解决办法》


  • 问题3:升级mac系统带来的missing xcrun问题

在终端输入xcode-select —install安装完成即可解决


  • 问题4:删除cocoapods

查看rubygems的本地程序包:gem list,删除所有跟cocoapods有关的。
以删除cocoapods为例:sudo gem uninstal cocoapods


2、生成ssh

ssh-keygen -t rsa -C "xxxxx@xxx.com"

接下来的指令可以连点三下空格,如果机器之前生成过ssh,那么需要在提示Overwrite(y/n)?的时候填y。接下来查看公钥:

cat ~/.ssh/id_rsa.pub

3、获取代码

将公钥添加到公司账号中去,以gitlab为例:

公司给予域账号,登录gitlib,在设置中找到SSH Keys,将上一步获取到的公钥添加至账号中。

之后将代码仓库clone至本地,可选择在sourcetree上拉代码。


4、加入开发组

将自己的apple id发给项目经理。如果公司没有测试机,可以把自己的手机的udid(可在iTunes中查看)发给项目经理,让其帮忙加入测试设备。


5、代码块的导入

为了工作更顺手,可以事先准备好代码块(默认存储在~/Library/Developer/Xcode/UserData/CodeSnippets),直接拷贝到新机器的该目录下。


6、其它

(1)梯子

(2)显示隐藏文件

# 显示所有隐藏文件夹 
defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder
# 恢复隐藏 
defaults write com.apple.finder AppleShowAllFiles -bool false; killall Finder

(3)开启安装权限

"app已损坏,打不开。你应该将它移到废纸篓。"

并非你安装的软件已损坏,而是Mac系统的安全设置问题,因为这些应用都是破解或者汉化的,那么解决方法就是临时改变Mac系统安全设置。出现这个问题的解决方法:
修改系统配置:系统偏好设置... -> 安全性与隐私。修改为任何来源
如果没有这个选项的话 (macOS Sierra 10.12) ,打开终端,执行下述命令即可。

sudo spctl --master-disable

一粒咸瓜子
1 声望0 粉丝

趁时间没发觉,让我带着你离开。