问题
- 操作系统统一
- 开发软件版本统一
- 用什么管理ruby 版本
- 用什么管理cocoapods 版本,和 fastlane版本
- gitignore 的下载和使用
- 项目组成员,整么统一项目环境呢?
项目地址
重要提示
以下所有的命令操作,最好都在项目的根目录下面操作
答案
- 操作系统统一
- macOS 系统统一,关闭电脑的自动更新系统,统一所有的macos操作系统
- 开发软件版本统一
- XCode解释 :下载地址使用非appStore 下载,使用官方网站下载
- Xcode下载地址 : https://developer.apple.com/download/more/
- 用什么管理ruby 版本
- 使用Homebrew 和 rbenv 来管理ruby版本(这个过程可能会有点慢,请耐心等待)
# 1.安装Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 2.安装rbenv软件
brew install rbenv ruby-build rbenv-vars
# 3.使用rbenv 查看当前可用的ruby 版本
rbenv install -l
# 4. 使用rbenv安装ruby
rbenv install 3.0.0
# 5. 锁定ruby 版本 (锁定版本的时候会生产一个.ruby-version的文件,里面的内容就只有一个ruby版本)
rbenv local 3.0.0
- 用什么管理cocoapods 版本,和 fastlane版本
- 使用bundler 管理cocoapods 和fastlane 版本
- 安装bundle
gem install bundler
- bundle 初始化 (会生成一个Gemfile文件)
bundle init
- 修改Gemfile 文件也就是在Gemfile 文件中设置我们的cocoapods 和 fastlane 的版本
Gemfile 文件内容如下:
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
# cocoapods 最新版本可以在 https://rubygems.org 网站中搜索查询
gem "cocoapods", "1.10.1"
# fastlane 最新版本可以在 https://rubygems.org 网站中搜索查询
gem "fastlane", "2.180.0"
- 安装cocoapods 和 fastlane 管理软件
bundle install
- 生成profile 文件
bundle exec pod init
- 编辑profile 文件,文件内容如下
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
target 'RbenvAndBundlerTestProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for RbenvAndBundlerTestProject
pod "Alamofire"
end
- 安装安装pod
bundle exec pod install
- gitignore 的下载和使用
- gitignore 文件下载地址
# gitignore 文件下载
https://github.com/github/gitignore
#Swift.gitignore 文件下载地址(我项目使用的是Swift 所以我下载的是Swift.gitignore 文件)
https://github.com/github/gitignore/blob/master/Swift.gitignore
- 修改Swift.gitignore 文件名为.gitignore 文件
- 把.gitignore 文件放入项目文件夹中去
- 修改后的.gitignore 文件内容如下:
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build/
# Accio dependency management
Dependencies/
.accio/
# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
- 项目组成员,整么统一项目环境呢?
- 项目组成员只需要下拉git 项目
- 在项目目录中找到ios_project_path.sh 文件
- 在控制台 项目目录中 执行 ./ios_project_path.sh 就可以配置完成统一的环境了
结束语
到此一个基本的统一项目环境搭建,基本就OK搞定了
网友评论