美文网首页
[iOS]从配环境到项目Running

[iOS]从配环境到项目Running

作者: Aloesshine | 来源:发表于2017-10-23 13:06 被阅读0次

安装 Xcode

两种选择:

1.AppStore 直接下载 最新正式版(省心省力)

2.Apple Develop 平台下载 Xcode9Beta 版

  • 慎选,坑坑坑坑坑,不作死就不会死,好奇心害死猫

    • 一打开工程就会闪退,Xcode9 的 bug,且不仅 Xcode9 会 crash,其他正式版的 Xcode 也会 crash!!!简直崩到没脾气。。。而且暂时只有 Xcode9 的解决方案,意味着在官方修复这个bug之前,要不回退 OS X 到 10.12,要不,就凑乎凑乎用 beta 版吧(哭哭)
    • PS:此bug已在Xcode9正式版中被修复

    解决方案:

    1. Exit Xcode
    2. In the terminal : defaults write com.apple.dt.XCode IDEIndexDisable 1
    3. Setup Workspace (File->Workspace Settings..)
      Shared Workspace Settings : Build System: Standard Build System (Default)
      Pre-User Workspace Settings : Build System: New Build System (Preview)
      Derived Data : Workspace-relative Location
    4. Enable IDE Index : defaults write com.apple.dt.XCode IDEIndexDisable 0
    5. Open Xcode
    6. Enjoy It!
  • 虽然坑,但是一些新特性还是挺好用的haha~

    • 多模拟器同时开 :项目只能真机调试,这个还没体验到
    • 无线调试 :需要 iOS11,同时在多台真机上调试,不需要再用数据线插来插去的,hin好用~
    • error 提示信息更友好,一键fix
    • command + click 更多选项
    image.png
    • Extra Method/ Extra Function :一键生成新方法

      image.png image.png
  • git 加强 :菜单栏 commit,pull,push等,左侧任务栏查看分支,合并方便了很多(然而还是需要命令行辅助)
  • command + - 缩放代码 :这个功能终于有了,眼瞎星人的福音

升级 Ruby

Mac 自带 Ruby 环境,只需要升级就好啦~

1.查看 ruby 版本 :

ruby --version

2.升级 ruby 环境,安装 rvm

curl -L https://get.rvm.io | bash -s stable

source ~/.rvm/scripts/rvm // 载入 rvm 环境

3.查看 rvm 版本

rvm --version

4.列出ruby可安装的版本信息

rvm list known

5.安装一个ruby版本 (2.2.0)

rvm install <版本号>

6.设置默认版本

rvm use <版本号> --default
  • 令:如果要回退ruby版本,重复4,5,6
rvm list // 查询已经安装的 ruby
rvm remove <版本号> //卸载一个已安装的版本

安装 CocoaPods

1.安装 (1.2.1)

sudo gem install -n /usr/local/bin cocoapods (-v <版本号> )

sudo gem install cocoapods (-v <版本号>) 

2.安装本地库

pod setup

3.下载完看看能不能用吖~

pod search AFNetworking

4.查看 pod 版本

pod --version
  • 令:删除指定版本 CocoaPods
sudo gem uninstall cocoapods -v <版本号>

回退过 ruby 版本后记得重新装一下 CocoaPods 哦~

git : 生成配置 SSH Key

1.检查 SSH Key 设置

cd ~/.ssh

如果提示:No such file or directory,说明第一次使用 git 或者没有配置过

2.生成新的 SSH Key

ssh-keygen -t rsa -C "邮件地址@youremail.com"

3.添加 Key 到 gitHub

cat ~/.ssh/id_rsa.pub

把输出的一大串字符复制到 github 上:

Settings —-> SSH Public keys —-> add another public keys

git : 把代码拉到本地

1.把代码 clone 到本地

git clone <项目ssh>

也可以用 Xcode9 添加 git 账号,一键 clone 所需项目

2.切换到相应的分支

git branch  // 查看分支
git branch -a // 所有分支
git checkout <目标分支>

3.pod install

如果报错:

/usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'cocoapods' (>= 0.a) among 32 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/chenrongshan/.gem/ruby/2.3.0:/usr/local/lib/ruby/gems/2.3.0:/usr/local/Cellar/ruby/2.3.1/lib/ruby/gems/2.3.0', execute `gem env` for more information
 from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
 from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
 from /usr/local/bin/pod:22:in `<main>'

更新 gem 版本,重新安装 CocoaPods

 sudo gem update --system
 sudo gem install cocoapods (-v <版本号>)

运行项目

1.在 Xcode 中添加 Apple ID :Xcode -> preferences -> Accounts

2.打开 .xcworkspace 文件 ,连接真机

3.选择项目中相应的 target

4.Edit scheme... -> Run -> Build Configuration ,选择相应的版本

5.command + R 运行

--

小尾巴 : 为什么要升 Xcode9 呢?大概是因为作吧。

相关文章

网友评论

      本文标题:[iOS]从配环境到项目Running

      本文链接:https://www.haomeiwen.com/subject/smtauxtx.html