Maintained by @bryanluby
A repository of useful Swift and Objective-C Xcode snippets.
- Clone this repo.
- Run the install script at the top-level of this repo:
./install.sh
- This will copy all of the snippets into the user-level Xcode snippets directory.
- Restart Xcode if it is currently open to use the snippets.
If you have any other Snippets that you would like to share make a Pull Request!
- Follow the directions here for adding a snippet to Xcode.
- Then navigate to
~/Library/Developer/Xcode/UserData/CodeSnippets/
and find the.codesnippet
file that was just created (sorting by Date Modified or Date Created helps). - Drag that snippet file into the top-level of this repo folder and rename the file with either the
swift_
orobjc_
naming scheme similar to the other snippets.
swift_mark
:MARK: -
convenience snippetswift_private_set_var
:private(set) var ...
convenience snippetswift_static_date_formatter
: Static date formatter snippetswift_tableview_data_source
: Bare bones requiredUITableViewDataSource
methodsswift_collectionview_data_source
: Bare bones requiredUICollectionViewDataSource
methodsswift_swiftlint_disable_enable
: Disable/enable a SwiftLint rule for a block of code.swift_swiftlint_disable_this
: Disable a SwiftLint rule for the current line of code.swift_swiftlint_disable_next
: Disable a SwiftLint rule for the next line of code.swift_swiftlint_disable_previous
: Disable a SwiftLint rule for the previous line of code.swift_source_code_tag
: Add a tag to link to source code via thex-source-tag
URL scheme.swift_source_code_link
: Create a link to source code via thex-source-tag
URL scheme.
objc_pragma_mark
:#pragma mark - ...
snippetobjc_weakself
:weakSelf
snippetobjc_strongSelf
:strongSelf
snippetobjc_static_object_creation
:static TYPE *const ...
snippetobjc_global_variable_interface
:FOUNDATION_EXPORT TYPE *const ...
snippet for.h
filesobjc_global_variable_implementation
:TYPE *const ...
snippet for.m
filesobjc_struct_types_interface
: Struct type for grouping constants for.h
filesobjc_struct_types_implementation
: Struct type for grouping constants for.m
files