Git ignore file for Xcode projects

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

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

20条回答
  •  死守一世寂寞
    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

提交回复
热议问题