Xcode-Sourcetree-忽略CocoaPods文件
目的
CocoaPods
的第三方库,都在git
上存有的,也就是说,它们在网上都已经有自己的空间了。如果我们把他们都push
到自己的服务器,那么就是创建了另外的空间存放着他们的备份,那么,如果是几十个项目都用到同一个库呢?那么冗余度会很高。
简介
.gitignore
的作用:使用这样一个文件,指定了上传的黑名单,使我们push
的时候把符合该规则的路径都忽略掉。
配置
- 创建
.gitignore
文件:- 打开终端;
- 输入指令:
cd '项目目录'
; - 输入指令:
vim .gitignore
; - 把
.gitignore
文件的配置内容,复制到终端;内容见下面.gitignore
文件的配置内容; - 按
esc
键,再输入指令::wq
,然后按return
回车键; - 输入指令
sudo ls
,查看目录下是否存在.gitignore
文件,有则表示成功;
- 如果之前没有提交过第三方到远端,则按照正常情况,
commit
一下,再push
到远端就完成了; - 如果之前提交过得话,则输入指令
git rm -r Pods
,然后再comit
,再push
;
检验
- 重新
clone
一份这个项目到本地,你会发现这个项目中没有了Pods
这个文件夹,运行项目也会报错。 - 打开终端,
cd '项目目录'
,执行pod install
,即可正常运行项目;
.gitignore
文件的配置内容
可直接复制以下内容到.gitignore
使用:
# Xcode
.DS_Store
/build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace
#CocoaPods
Pods
!Podfile
# 最好也忽略Podfile.lock
# !Podfile.lock
已有GitLib
上Objective-C
模板的.gitignore
内容,可直接新增以下内容:
## GitLib初始化没有 - Start
.DS_Store
profile
.idea/
*.xcworkspace
!default.xcworkspace
#CocoaPods
Pods
# 不忽略Podfile
#Podfile
# 最好忽略Podfile.lock
Podfile.lock
## GitLib初始化没有 - End
GitLib
上Objective-C
模板的.gitignore
内容:
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# 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
# 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/