Git d'ignorer des fichiers pour des projets Xcode

quels fichiers dois-je inclure dans .gitignore en utilisant Git en conjonction avec Xcode ?

824
demandé sur Binarian 2008-09-08 15:07:49

20 réponses

"151930920 des" Mods": Merci de ne pas approuver les modifications à la présente réponse. Jusqu'à présent, chaque édition a été incorrecte et provoque la perte de données. Laissez cette réponse tranquille!


si vous voulez modifier cette réponse ... ne le fais pas. Lisez le tout d'abord - il ya un moyen facile pour vous de faire votre propre fourchette, et si ce n'est pas assez, puis commenter.


j'étais auparavant en utilisant la réponse la plus votée, mais il a besoin d'un peu de nettoyage, donc ici il est fait pour Xcode 4, avec quelques améliorations.

j'ai recherché chaque fichier dans cette liste, mais plusieurs d'entre eux n'existent pas dans les docs officiels Xcode D'Apple, donc j'ai dû aller sur les listes de diffusion D'Apple.

Apple continue à ajouter des fichiers non documentés, corrompant potentiellement nos projets en direct. Cet IMHO est inacceptable, et j'ai maintenant commencé à Logger les bogues contre chaque fois qu'ils le faire. Je sais qu'ils s'en fichent, mais peut-être que ça fera honte à l'un d'eux de traiter les développeurs plus équitablement.


si vous avez besoin de personnaliser, voici un gist vous pouvez bifurquer: https://gist.github.com/3786883


#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
#    15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: /q/git-ignore-file-for-xcode-projects-42637/"xccheckout" line - thanks to @lyck for pointing it out!
# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out
# - Finally added "xccheckout" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.
# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)
# 2014 updates:
# - appended non-standard items DISABLED by default (uncomment if you use those tools)
# - removed the edit that an SO.com moderator made without bothering to ask me
# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# 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
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.DS_Store

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.Trashes

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

*.swp

#
# *.lock - this is used and abused by many editors for many different things.
#    For the main ones I use (e.g. Eclipse), it should be excluded 
#    from source-control, but YMMV.
#   (lock files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock


#
# profile - REMOVED temporarily (on double-checking, I can't find it in OS X docs?)
#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: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html

*.pbxuser

# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode1v3

# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode2v3

# .perspectivev3: /q/xcode-projects-what-is-a-perspectivev3-file-63889/"don't ignore it"
#     FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode
# Up to you, but ... current advice: ignore it.
*.xccheckout

#
#
# OPTION 1: ---------------------------------
#     throw away ALL personal settings (including custom schemes!
#     - unless they are "shared")
# As per build/ and DerivedData/, this ought to have a trailing slash
#
# 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 *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
#    or manually install git over the top of the OS X version
# 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
#     /xcshareddata/
#       /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

####
# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development
#
# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow
#     modular gitignore: you have to put EVERYTHING in one file.
#
# COCOAPODS:
#
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
#!Podfile.lock
#
# RUBY:
#
# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
#
#!Gemfile.lock
#
# IDEA:
#
# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml
# 
#.idea/workspace.xml
#
# TEXTMATE:
#
# -- UNVERIFIED: c.f. http://stackoverflow.com/a/50283/153422
#
#tm_build_errors

####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
648
répondu Adam 2018-04-27 01:57:39

Basé sur de ce guide pour Mercurial mon .gitignore comprend:

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

j'ai aussi choisi d'inclure:

*.mode1v3
*.mode2v3

qui, selon ce post de la liste de diffusion D'Apple , sont des"paramètres de projet spécifiques à l'utilisateur".

et pour Xcode 4:

xcuserdata
273
répondu Hagelin 2011-02-16 12:00:24

concernant l'exclusion du répertoire 'build' -

Si vous placez vos fichiers dans un autre répertoire de votre source, comme je le fais, vous n'avez pas le dossier dans l'arborescence de s'inquiéter.

cela rend également la vie plus simple pour partager votre code, prévenir les sauvegardes gonflées, et même si vous avez des dépendances à d'autres projets Xcode (tout en exigeant que les constructions soient dans le même répertoire que l'autre)

vous pouvez attraper une copie à jour du GitHub gist https://gist.github.com/708713

mon courant .le fichier de gitignore est

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib
61
répondu Abizern 2012-03-19 18:30:21

pour Xcode 4 j'ajoute aussi:

YourProjectName.xcodeproj/xcuserdata/*
YourProjectName.xcodeproj/project.xcworkspace/xcuserdata/*
55
répondu Vladimir Mitrovic 2010-10-13 14:09:21

j'ai inclus ces suggestions dans un Gist que j'ai créé sur Github: http://gist.github.com/137348

n'hésitez pas à la fourcher et à la rendre meilleure.

24
répondu program247365 2009-06-28 20:04:44

les habitants de GitHub sont exhaustifs et documentés .fichiers gitignore pour les projets Xcode:

Swift: https://github.com/github/gitignore/blob/master/Swift.gitignore

objectif-C: https://github.com/github/gitignore/blob/master/Objective-C.gitignore

13
répondu Eric 2015-06-22 10:41:26

J'utilise à la fois AppCode et XCode. Donc .idea/ devrait être ignoré.

ajoutez ceci au .gitignore "151940920 D'Adam"

####
# AppCode
.idea/
12
répondu Wanbok Choi 2013-07-29 17:41:55

you should checkout gitignore.io pour L'Objectif C et Swift

voici le fichier .gitignore que j'utilise

# 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
11
répondu onmyway133 2015-11-17 13:49:02

Mine est une .bzrignore, mais la même idée :)

.DS_Store
*.mode1v3
*.pbxuser
*.perspectivev3
*.tm_build_errors

le tm_build_errors est pour quand J'utilise TextMate pour construire mon projet. Pas aussi complet que Hagelin mais j'ai pensé qu'il valait la peine de poster pour la ligne tm_build_errors.

10
répondu Dave Verwer 2008-09-08 17:51:38

est un script que j'ai fait pour créer votre auto.gitignore et .gitattributes des fichiers en utilisant Xcode... J'ai piraté avec quelques autres trucs. Amusez-vous!

Xcode-Git-User-Script

aucune garantie... Je suce à la plupart de ce - de sorte que vous les utilisez à vos risques et périls

10
répondu tbarbe 2013-06-18 04:59:08

ajouter .dossier gitignore pour

MAC OS X + XCode + Swift

C'est ainsi, Ai-je ajouté .gitignore fichier dans mon Swift projet

  1. Sélectionnez votre projet dans XCode et clic droit -- > nouveau groupe -- > nommez-le " Git "
  2. sélectionnez Dossier Git et clic droit -- > Ajouter nouveau fichier
  3. à l'Intérieur iOS onglet -->sélectionner Autres --> fichier vide

enter image description here

  1. donnez le nom du fichier ici " .gitignore "

enter image description here

  1. confirmer le nom du fichier et le type

enter image description here

Voici la structure du résultat

enter image description here

  1. ouvrir le fichier et passer le code ci-dessous

# file

#########################################################################
#                                                                       #
#       Title         - .gitignore file                                 #
#       For           - MAC OSX , Xcode7 and Swift Source projects      #
#       Updated by    - Ramdhan Choudhary                               #
#       Updated on    - 13 - November - 2015                            #
#                                                                       #
#########################################################################

########### Xcode ###########
# Xcode temporary files that should never be committed

## Build generated
build/
DerivedData

# NB: NIB/XIB files still exist even on Storyboard projects, so we want this
*~.nib
*.swp

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

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
*.xcscheme

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

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

########## Obj-C/Swift specific ##########
*.hmap
*.ipa

# 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

fastlane/report.xml
fastlane/screenshots

bien merci à Adam , sa réponse m'a beaucoup aidé mais j'ai quand même dû ajouter peu d'entrées comme je voulais .gitignore pour

MAC OS X + XCode + Swift

, les Références : ce et ce

8
répondu swiftBoy 2017-05-23 10:31:31

pour XCode 5 j'ajoute:

####
# Xcode 5 - VCS metadata
#
*.xccheckout

à Partir de Berik la Réponse de

6
répondu Wanbok Choi 2017-05-23 12:26:32

j'ai ajouté:

xcuserstate
xcsettings

et placé mon.gitignore fichier à la racine de mon projet.

après avoir commis et poussé. J'ai alors couru:

git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings

enterré avec le dossier ci-dessous:

<my_project_name>/<my_project_name>.xcodeproj/project.xcworkspace/xcuserdata/<my_user_name>.xcuserdatad/

j'ai ensuite couru git commit et d'appuyer de nouveau sur

4
répondu user1524957 2012-09-25 21:38:58

j'utilise ce qui suit .fichier gitignore généré dans gitignore.io:

### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate


### Objective-C ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
Pods/
4
répondu joserock85 2015-11-19 19:36:55

voici le .gitignore que GitHub utilise par défaut pour les nouveaux dépôts Xcode:

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

il est probable qu'il soit raisonnablement correct à un moment donné.

2
répondu funroll 2014-10-28 17:45:25

le meilleur de tous,

gitignore.io

allez et choisissez votre langue, puis il vous donnera le fichier.

1
répondu alicanbatur 2017-02-06 07:45:02

nous avons trouvé que même si vous ajoutez le .gitignore et la .gitattribte l' *.le fichier pbxproj peut être corrompu. Donc nous avons un plan simple.

toute personne qui code dans le bureau se contente de rejeter les changements apportés à ce dossier. Dans la propagation on mentionne simplement les fichiers qui sont ajoutés dans la source. Et puis le pousser vers le serveur. Notre gestionnaire d'intégration TIRE et voit les détails de propagation et ajoute les fichiers dans les ressources.

une fois il mises à jour de la télécommande tout le monde aura toujours une copie de travail. Au cas où quelque chose manque, nous lui demandons de l'ajouter et de tirer à nouveau.

Cela a fonctionné pour nous, sans aucun problème.

0
répondu Basil Abbas 2013-09-04 08:03:12

je recommande d'utiliser joe pour générer un fichier .gitignore .

pour un projet iOS exécutez la commande suivante:

$ joe g osx,xcode > .gitignore

il générera ce .gitignore :

.DS_Store
.AppleDouble
.LSOverride

Icon
._*

.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

build/
DerivedData

*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

*.xccheckout
*.moved-aside
*.xcuserstate
0
répondu damianesteban 2018-01-15 17:48:07

utiliser https://www.gitignore.io/ pour générer, et ajouter les fichiers mac, cocoaPods comme bellow:

## Mac
.DS_Store

## cocoaPods
Pod

## Build generated
build/
DerivedData/

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

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
-1
répondu aircraft 2018-01-24 05:06:21

Une Structure standard .gitignore fichier pour le projet Xcode >

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
-1
répondu Rahul Singha Roy 2018-07-02 10:24:11