https://github.com/clayellis/codesnippets
👨🏻💻 Xcode code snippets that I use on a day-to-day basis.
https://github.com/clayellis/codesnippets
xcode
Last synced: 29 days ago
JSON representation
👨🏻💻 Xcode code snippets that I use on a day-to-day basis.
- Host: GitHub
- URL: https://github.com/clayellis/codesnippets
- Owner: clayellis
- Created: 2017-05-30T17:33:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-30T18:03:33.000Z (almost 9 years ago)
- Last Synced: 2025-06-10T01:04:32.924Z (10 months ago)
- Topics: xcode
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 👨🏻💻 CodeSnippets
Xcode code snippets that I use on a day-to-day basis.
## Installation
1. `git clone https://github.com/clayellis/CodeSnippets.git`
2. `cp CodeSnippets/*.codesnippet ~/Library/Developer/Xcode/UserData/CodeSnippets/`
3. Restart Xcode
## Overview
### localizable-strings.codesnippet
When developing iOS apps, I like to put all of my user-facing strings into a `Localizable.strings` file to:
1. Have a centralized location for editing strings
2. Be able to translate the app quickly without having to change any code
To improve the process of adding strings to `Localizable.strings` I wrote a Swift script called [Localize](link) that parses files for `NSLocalizedString(...)` and pulls out the key, value, and comment if provided. I like providing all three by default. But since Xcode only code completes for `NSLocalizedString(_ key: String, comment: String)` it can be cumbersome to always add `value: String`. You could create a global function with those parameters, but I try to avoid adding global functions when possible.
Start typing `NSLocalizableString` add get a nice completion for `NSLocalizedString(_ key: String, value: String, comment: String)` (which is a totally valid flavor of the macro.)