Xcode-Sourcetree-忽略CocoaPods文件

Xcode-Sourcetree-忽略CocoaPods文件

目的

CocoaPods的第三方库,都在git上存有的,也就是说,它们在网上都已经有自己的空间了。如果我们把他们都push到自己的服务器,那么就是创建了另外的空间存放着他们的备份,那么,如果是几十个项目都用到同一个库呢?那么冗余度会很高。

简介

.gitignore的作用:使用这样一个文件,指定了上传的黑名单,使我们push的时候把符合该规则的路径都忽略掉。

配置

  1. 创建.gitignore文件:
    1. 打开终端;
    2. 输入指令:cd '项目目录'
    3. 输入指令:vim .gitignore
    4. .gitignore文件的配置内容,复制到终端;内容见下面.gitignore文件的配置内容;
    5. esc键,再输入指令::wq,然后按return回车键;
    6. 输入指令sudo ls,查看目录下是否存在.gitignore文件,有则表示成功;
  2. 如果之前没有提交过第三方到远端,则按照正常情况,commit一下,再push到远端就完成了;
  3. 如果之前提交过得话,则输入指令git rm -r Pods,然后再comit,再push

检验

  1. 重新clone一份这个项目到本地,你会发现这个项目中没有了Pods这个文件夹,运行项目也会报错。
  2. 打开终端,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

已有GitLibObjective-C模板的.gitignore内容,可直接新增以下内容:


## GitLib初始化没有 - Start
.DS_Store
profile
.idea/
*.xcworkspace
!default.xcworkspace
#CocoaPods
Pods
# 不忽略Podfile
#Podfile
# 最好忽略Podfile.lock
Podfile.lock
## GitLib初始化没有 - End

GitLibObjective-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/


你可能感兴趣的:(Xcode-Sourcetree-忽略CocoaPods文件)