2012-04-19 26 views
9

與Eclipse或其他IDE不同的是,只要發現項目中的文件或組被添加,重命名或刪除,Xcode就會修改.xcodeproj文件。當有多個開發人員在項目中工作時,這非常不方便。如何避免修改經常由團隊工作的Xcode的項目文件(.xcodeproj)?

一旦我的SCM工具抱怨.xcodeproj文件發生衝突,我所能做的就是檢出整個項目的另一個副本,併合並我對它所做的所有更改,並祈禱沒有人比我更快。

是否有解決方法來更改Xcode的默認策略?

回答

0

這不是你唯一的辦法。 .xcodeproj文件是文本。格式不太難理解。解決衝突的通常方法是採取兩套補充(當然,除了例外)。

1

據我所知,.xcodeproj實際上是幾個文件的包裝,包括.pbxuser和.pbxproj。不知道你使用的是什麼SCM,但是對於使用git的人來說,here涉及到這個話題,並且似乎認爲.pbxuser文件以及許多其他文件不應該包含在版本控制之下。

0
  1. 退出xcode
  2. 打開終端。
  3. 導航到/.xcodeproj/project.xcworkspace
  4. 類型:MV contents.xcworkspacedata contents.xcworkspacedata.bak
  5. 重新啓動的Xcode
0

我們做團隊,以避免對本文件衝突是什麼,是提交除項目文件以外的所有文件。在這種情況下,一切都是安全的 如果您只想要自己的項目文件,或者將其包含在.gitignore文件中,以免被自動忽略,則可以避免更新。

######################### 
# .gitignore file for Xcode4/OS X Source projects 
# 
# Version 2.0 
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects 
# 
# 2013 updates: 
# - fixed the broken "save personal Schemes" 
# 
# NB: if you are storing "built" products, this WILL NOT WORK, 
# and you should use a different .gitignore (or none at all) 
# This file is for SOURCE projects, where there are many extra 
# files that we want to exclude 
# 
######################### 

##### 
# OS X temporary files that should never be committed 

.DS_Store 
*.swp 
*.lock 
profile 


#### 
# Xcode temporary files that should never be committed 
# 
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this... 

*~.nib 


#### 
# Xcode build files - 
# 
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData" 

DerivedData/ 

# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build" 

build/ 


##### 
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) 
# 
# This is complicated: 
# 
# SOMETIMES you need to put this file in version control. 
# Apple designed it poorly - if you use "custom executables", they are 
# saved in this file. 
# 99% of projects do NOT use those, so they do NOT want to version control this file. 
# ..but if you're in the 1%, comment out the line "*.pbxuser" 

*.pbxuser 
*.mode1v3 
*.mode2v3 
*.perspectivev3 
# NB: also, whitelist the default ones, some projects need to use these 
!default.pbxuser 
!default.mode1v3 
!default.mode2v3 
!default.perspectivev3 


#### 
# Xcode 4 - semi-personal settings 
# 
# 
# OPTION 1: --------------------------------- 
# throw away ALL personal settings (including custom schemes! 
# - unless they are "shared") 
# 
# NB: this is exclusive with OPTION 2 below 
xcuserdata 

# OPTION 2: --------------------------------- 
# get rid of ALL personal settings, but KEEP SOME OF THEM 
# - NB: you must manually uncomment the bits you want to keep 
# 
# NB: this is exclusive with OPTION 1 above 
# 
#xcuserdata/**/* 

# (requires option 2 above): Personal Schemes 
# 
#!xcuserdata/**/xcschemes/* 

#### 
# XCode 4 workspaces - more detailed 
# 
# Workspaces are important! They are a core feature of Xcode - don't exclude them :) 
# 
# Workspace layout is quite spammy. For reference: 
# 
# /(root)/ 
# /(project-name).xcodeproj/ 
# project.pbxproj 
# /project.xcworkspace/ 
# contents.xcworkspacedata 
# /xcuserdata/ 
# /(your name)/xcuserdatad/ 
# UserInterfaceState.xcuserstate 
# /xcsshareddata/ 
# /xcschemes/ 
# (shared scheme name).xcscheme 
# /xcuserdata/ 
# /(your name)/xcuserdatad/ 
# (private scheme).xcscheme 
# xcschememanagement.plist 
# 
# 

#### 
# Xcode 4 - Deprecated classes 
# 
# Allegedly, if you manually "deprecate" your classes, they get moved here. 
# 
# We're using source-control, so this is a "feature" that we do not want! 

*.moved-aside 


#### 
# UNKNOWN: recommended by others, but I can't discover what these files are 
# 
# ...none. Everything is now explained. 
2

與Eclipse或其他IDE時,Xcode將修改.xcodeproj文件隨時發現,在項目中的文件或組被添加,重命名或刪除。

與Eclipse和一些其他的IDE,Xcode中保持的哪些文件是在項目組結構項目「文件」的一部分列表(.xcodeproj文件實際上是目錄)。這些組不必在物理上作爲目錄存在,並且這些文件實際上可以存在於各種地方,並且不必像Xcode中出現的那樣命名。

如果有人向項目中添加新文件,或者從項目中刪除文件,或者更改文件或組的名稱,這需要反映在您的SCM中,因爲其他人檢出工作副本或克隆如果項目與磁盤上的內容保持同步,那麼您的存儲庫或任何更喜歡它的內容都會更好。例如,如果有人刪除了一個文件,但是這個變化沒有反映在其他人的Xcode項目文件中,那麼他們在更新/同步/拉動或其他任何東西之後會得到編譯錯誤。

話雖如此,項目文件還包含一些不重要的用戶設置負載。在Xcode 4中。X我設置了以下目錄由我SCM忽視:

foo.xcodeproj/project.xcworkspace/xcuserdata 
foo.xcodeproj/xcuserdata 

在早期版本的項目文件我用來設置以下被忽略:

foo.xcodeproj/*.pbxuser 
foo.xcodeproj/*.mode1v3 

這似乎過濾掉不必要的廢話作爲就SCM而言。

0

作爲一種避免合併的策略衝突:如果兩個用戶在同一位置更改文件,您將得到需要痛苦的手動合併的衝突。例如,如果兩個用戶在一個組的最後添加一個文件,則會發生這種情況,因爲這兩個更改都在同一個位置。如果每個人都在不同的地方添加新文件(例如按字母順序),則不會合並衝突。或者至少更少。

相關問題