Git ignore file for Xcode projects

后端 未结 20 1214
栀梦
栀梦 2020-11-22 03:03

Which files should I include in .gitignore when using Git in conjunction with Xcode?

相关标签:
20条回答
  • 2020-11-22 03:33

    A Structure of a standerd .gitignore file for Xcode project >

    .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/
    
    0 讨论(0)
  • 2020-11-22 03:34

    Most of the answers are from the Xcode 4-5 era. I recommend an ignore file in a modern style.

    # Xcode Project
    **/*.xcodeproj/xcuserdata/
    **/*.xcworkspace/xcuserdata/
    **/*.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
    **/*.xcworkspace/xcshareddata/*.xccheckout
    **/*.xcworkspace/xcshareddata/*.xcscmblueprint
    **/*.playground/**/timeline.xctimeline
    .idea/
    
    # Build
    build/
    DerivedData/
    *.ipa
    
    # CocoaPods
    Pods/
    
    # fastlane
    fastlane/report.xml
    fastlane/Preview.html
    fastlane/screenshots
    fastlane/test_output
    fastlane/sign&cert
    
    # CSV
    *.orig
    .svn
    
    # Other
    *~
    .DS_Store
    *.swp
    *.save
    ._*
    *.bak
    

    Keep it updated from: https://github.com/BB9z/iOS-Project-Template/blob/master/.gitignore

    0 讨论(0)
  • 2020-11-22 03:35

    Regarding the 'build' directory exclusion -

    If you place your build files in a different directory from your source, as I do, you don't have the folder in the tree to worry about.

    This also makes life simpler for sharing your code, preventing bloated backups, and even when you have dependencies to other Xcode projects (while require the builds to be in the same directory as each other)

    You can grab an up-to-date copy from the Github gist https://gist.github.com/708713

    My current .gitignore file is

    # 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
    
    0 讨论(0)
  • 2020-11-22 03:40

    You should checkout gitignore.io for Objective-C and Swift.

    Here is the .gitignore file I'm using:

    # 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
    
    0 讨论(0)
  • 2020-11-22 03:40

    I'm using both AppCode and XCode. So .idea/ should be ignored.

    append this to Adam's .gitignore

    ####
    # AppCode
    .idea/
    
    0 讨论(0)
  • 2020-11-22 03:40

    Adding a .gitignore file for

    Mac OS X + Xcode + Swift

    This is how I have added a .gitignore file into my Swift project:

    1. Select you project in Xcode and right click → New Group → name it "Git"
    2. Select the Git folder and right click → Add new file
    3. Within the iOS tab → select Otherempty file

    1. Give the file name here ".gitignore"

    1. Confirm the file name and type

    Here is the result structure:

    1. Open the file and past the below code

    # file
    
    #########################################################################
    #                                                                       #
    #       Title         - .gitignore file                                 #
    #       For           - Mac OS X, Xcode 7 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
    
    ########### Mac OS X ###########
    # Mac 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
    
    ########## Objective-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 repository. Instead, use fastlane to re-generate the
    
    fastlane/report.xml
    fastlane/screenshots
    

    Well, thanks to Adam. His answer helped me a lot, but still I had to add a few more entries as I wanted a .gitignore file for:

    Mac OS X + Xcode + Swift

    References: this and this

    0 讨论(0)
提交回复
热议问题