

Swift-uicollectionviewdatasource UICollectionViewDataSource snippet for Swift Swift-sortarrayofstrings Swift String Array locale-aware sorting Swift-singleton Singleton pattern for Swift Swift-nslocalizedstring NSLocalizedString function snippet for Swift Swift-message MFMessageComposeViewController snippet for Swift

Swift-mark Divider label for separating code into sections Swift-mail MFMailComposeViewController snippet for Swift Swift-forin for-in loop that casts objects inline Swift-documentdirectory Document directory path snippet for Swift Swift-dispatchmain GCD dispatch_async on main queue snippet for Swift Swift-dispatchasync GCD dispatch_async snippet for Swift Swift-dispatchafter GCD dispatch_after snippet for Swift Swift-didbecomeactive UIApplicationDidBecomeActiveNotification observer snippet for Swift Swift-closuretypealias Closure typealias with arguments and return value snippet for Swift Swift-closureoptionaltypealias Optional closure typealiast with arguments and return value snippet for Swift If you want to add this nice placeholder in rounded blue rect simply put it between and it will be transformed in both editor and final snippet.Ĭurrently existing snippets (I hope they will be updated on a regular basis with your help :) ): Then select a code you would like to treat as a snippet, press and hold a left mouse button for a while and drag whole selection to the right panel (if you drag to early you'll probably only deselect text you can also try dragging from a whitespace instead of the letter). To add code snippet to Xcode expand Utilities right panel and press button ( Show the Code Snippet library) in lower panel. so each time you type swift in code editor you should see all snippets you can use in that place. and set all Completion Shortcuts to swift. I named all of snippets using scheme Swift. It is created by Xcode when user adds his first custom snippet. Note: Create the folder if it doesn't exist already. codesnippet) into this folder, restart Xcode and you should have all of them ready to use. plist files in ~/Library/Developer/Xcode/UserData/CodeSnippets/ #How to import all code snippets to XcodeĪll Xcode code snippets exist as a. I also used that thing in swift and SwiftSingleton as a sample implementations. I was inspired by Matt Thompson's Xcode-Snippets article and GitHub repo but I haven't found anything similar for Swift. I want to present you some convenient code snippets I gathered for Swift.
