Git下Xcode项目之忽略不必要的文件

XCode开发中,经常会提交一些其实跟我们项目无关紧要的文件。对于高度洁癖者来说,这些操作简直是无法忍受的。这里引用举例,避免文件反复提交垃圾信息,冲突等不必要的麻烦。

一、UserInterfaceState.xcuserstate

这个文件主要是用来记录Xcode的工作状态的。比如你打开了xxx.m文件,这个文件就会被modified。所以这个文件是不被需要的。

忽略方法:

Step 1:在.gitignore文件中增加一行,*.xcuserstate即可。

Step 2:从现有的项目中移除已经被添加到版本控制的UserInterfaceState.xcuserstate文件。

git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate

Step 3:Push提交你的文件移除操作

git commit -m "移除UserInterfaceState.xcuserstate文件在git里面的版本控制,并修改.gitignore文件。"

二、Breakpoints_v2.xcbkptlist

这个文件主要是用来记录添加的断点调试。你在文件中增加断点,或者删除已有的断点,都会让这个文件被modified。其实也是项目非必须的。在团队合作中也会引来一些未知的麻烦。

忽略方法与上类似。唯一区别是在.gitignore文件中增加*.xcbkptlist即可。

这里贴一份Github上关于忽略Xcode项目的.gitignore文件(其中有四个库的使用忽略,CocoaPods、Carthage、fastlane、Code Injection,按需取用),可供参考:

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

*.DS_Store

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xcuserstate

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

# 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://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/screenshots

#Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

文章来自 http://skymonkey.cn/

高能广告区

暂无广告哦=^^=。继续看看其它文章吧!