Iphone 如何避免修改团队经常处理的Xcode的项目文件(.xcodeproj)?

Iphone 如何避免修改团队经常处理的Xcode的项目文件(.xcodeproj)?,iphone,ios,xcode,macos,Iphone,Ios,Xcode,Macos,与Eclipse或其他IDE不同,Xcode将在发现项目中的文件或组被添加、重命名或删除时修改.xcodeproj文件。当有多个开发人员在项目中工作时,这是非常不方便的 一旦我的SCM工具抱怨.xcodeproj文件存在冲突,我所能做的就是签出整个项目的另一个副本,将我所做的所有更改合并到其中,并祈祷没有人比我“更快” 有没有办法改变Xcode的默认策略?这不是你唯一的办法。xcodeproj文件是文本。格式不太难理解。解决冲突的通常方法是采用两组添加项(当然也有例外)。据我所知,.xcodep

与Eclipse或其他IDE不同,Xcode将在发现项目中的文件或组被添加、重命名或删除时修改.xcodeproj文件。当有多个开发人员在项目中工作时,这是非常不方便的

一旦我的SCM工具抱怨.xcodeproj文件存在冲突,我所能做的就是签出整个项目的另一个副本,将我所做的所有更改合并到其中,并祈祷没有人比我“更快”


有没有办法改变Xcode的默认策略?

这不是你唯一的办法。xcodeproj文件是文本。格式不太难理解。解决冲突的通常方法是采用两组添加项(当然也有例外)。

据我所知,.xcodeproj实际上是几个文件的包装,包括.pbxuser和.pbxproj。我不知道您使用的是什么SCM,但是这个主题是为那些使用git的人而讨论的,大家一致认为.pbxuser文件以及其他许多文件不应该包含在版本控制中

  • 退出xcode
  • 打开一个终端
  • 导航到/.xcodeproj/project.xcworkspace
  • 类型:mv contents.xcworkspacedata contents.xcworkspacedata.bak
  • 重新启动xcode

  • 我们在团队中要做的是避免此文件上的冲突,即提交除项目文件之外的所有文件。在这种情况下,一切都是安全的。 若您只想要自己的项目文件,或者甚至将其包含在文件中以便自动忽略,则可以避免更新

    #########################
    # .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.
    
    与Eclipse或其他IDE不同,Xcode将在发现项目中的文件或组被添加、重命名或删除时修改.xcodeproj文件

    与Eclipse和其他一些IDE不同,Xcode维护项目中的文件列表和组结构,作为项目“文件”的一部分(
    .xcodeproj
    文件实际上是一个目录)。这些组不必以目录的形式存在,文件实际上可以放在各种各样的地方,也不必按照Xcode中显示的名称命名

    如果有人向项目中添加新文件,或从项目中删除文件,或更改文件或组的名称,这需要反映在您的SCM中,因为如果项目与磁盘上的内容同步,其他人会签出工作副本或克隆存储库或其他更喜欢它的内容。例如,如果有人删除了一个文件,但该更改没有反映在其他人的Xcode项目文件中,那么他们在更新/sync/pull或其他任何内容后将出现编译错误

    话虽如此,项目文件还包含大量不重要的用户设置。在Xcode 4.x中,我将以下目录设置为SCM忽略:

    foo.xcodeproj/project.xcworkspace/xcuserdata
    foo.xcodeproj/xcuserdata
    
    在早期版本的项目文件中,我曾将以下内容设置为忽略:

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

    就SCM而言,这似乎过滤掉了不必要的废话。

    作为一种避免合并冲突的策略:如果两个用户在同一位置更改文件,将出现需要痛苦手动合并的冲突。例如,如果两个用户在一个组的末尾添加一个文件,就会发生这种情况,因为两个更改都在同一个位置。如果每个人都在不同的位置添加新文件(例如按字母顺序),则不会出现合并冲突。或者至少更少