Skip to content

Commit 54b44d1

Browse files
committed
Initial commit with the three first snippets
0 parents  commit 54b44d1

9 files changed

Lines changed: 249 additions & 0 deletions

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
### macOS ###
2+
# General
3+
.DS_Store
4+
.AppleDouble
5+
.LSOverride
6+
7+
# Icon must end with two \r
8+
Icon
9+
10+
11+
# Thumbnails
12+
._*
13+
14+
# Files that might appear in the root of a volume
15+
.DocumentRevisions-V100
16+
.fseventsd
17+
.Spotlight-V100
18+
.TemporaryItems
19+
.Trashes
20+
.VolumeIcon.icns
21+
.com.apple.timemachine.donotpresent
22+
23+
# Directories potentially created on remote AFP share
24+
.AppleDB
25+
.AppleDesktop
26+
Network Trash Folder
27+
Temporary Items
28+
.apdisk
29+
30+
### Xcode ###
31+
# Xcode
32+
#
33+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
34+
35+
## User settings
36+
xcuserdata/
37+
38+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
39+
*.xcscmblueprint
40+
*.xccheckout
41+
42+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
43+
build/
44+
DerivedData/
45+
*.moved-aside
46+
*.pbxuser
47+
!default.pbxuser
48+
*.mode1v3
49+
!default.mode1v3
50+
*.mode2v3
51+
!default.mode2v3
52+
*.perspectivev3
53+
!default.perspectivev3
54+
55+
## Gcc Patch
56+
/*.gcno
57+
58+
### Xcode Patch ###
59+
*.xcodeproj/*
60+
!*.xcodeproj/project.pbxproj
61+
!*.xcodeproj/xcshareddata/
62+
!*.xcworkspace/contents.xcworkspacedata
63+
**/xcshareddata/WorkspaceSettings.xcsettings

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All the snippets with a small description will be listed on this file according to its version release.
4+
5+
## 1.0.0
6+
7+
* **File from Bundle** (*bunfile*): Get the path from a file in the bundle
8+
* **JSON Decoder for Path** (*decodepath*): Lets you decode a file from an specific path and convert it to your `Codable` model.
9+
* **Programmatic Root Scene** (*pgmroot*): Add this snippet to your `SceneDelegate` when you don't want to use `Storyboards`. (iOS 13+).
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDECodeSnippetCompletionPrefix</key>
6+
<string>pgmroot</string>
7+
<key>IDECodeSnippetCompletionScopes</key>
8+
<array>
9+
<string>CodeBlock</string>
10+
</array>
11+
<key>IDECodeSnippetContents</key>
12+
<string>guard let windowScene = (scene as? UIWindowScene) else { return }
13+
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
14+
window?.windowScene = windowScene
15+
window?.rootViewController = &lt;#ViewController#&gt;
16+
window?.makeKeyAndVisible()</string>
17+
<key>IDECodeSnippetIdentifier</key>
18+
<string>52340A95-B638-471D-B14A-4CBCAA8A988D</string>
19+
<key>IDECodeSnippetLanguage</key>
20+
<string>Xcode.SourceCodeLanguage.Swift</string>
21+
<key>IDECodeSnippetPlatformFamily</key>
22+
<string>iphoneos</string>
23+
<key>IDECodeSnippetSummary</key>
24+
<string>Create you programmatic scene from SceneDelegate</string>
25+
<key>IDECodeSnippetTitle</key>
26+
<string>Programmatic Root Scene</string>
27+
<key>IDECodeSnippetUserSnippet</key>
28+
<true/>
29+
<key>IDECodeSnippetVersion</key>
30+
<integer>2</integer>
31+
</dict>
32+
</plist>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDECodeSnippetCompletionPrefix</key>
6+
<string>decodepath</string>
7+
<key>IDECodeSnippetCompletionScopes</key>
8+
<array>
9+
<string>CodeBlock</string>
10+
</array>
11+
<key>IDECodeSnippetContents</key>
12+
<string>do {
13+
let jsonData = try Data(contentsOf: URL(fileURLWithPath: &lt;#path#&gt;), options: .mappedIfSafe)
14+
let jsonDecoder = JSONDecoder()
15+
let &lt;#decodedObject#&gt; = try jsonDecoder.decode(&lt;#object#&gt;.self, from: jsonData)
16+
} catch {
17+
// handle error in case the data or the decoder fails.
18+
return
19+
}</string>
20+
<key>IDECodeSnippetIdentifier</key>
21+
<string>F5D3243F-4471-4C56-AE45-12B7AA55DCDE</string>
22+
<key>IDECodeSnippetLanguage</key>
23+
<string>Xcode.SourceCodeLanguage.Swift</string>
24+
<key>IDECodeSnippetPlatformFamily</key>
25+
<string>iphoneos</string>
26+
<key>IDECodeSnippetSummary</key>
27+
<string>Decode the JSON data on a Codable model</string>
28+
<key>IDECodeSnippetTitle</key>
29+
<string>JSON Decoder for Path</string>
30+
<key>IDECodeSnippetUserSnippet</key>
31+
<true/>
32+
<key>IDECodeSnippetVersion</key>
33+
<integer>2</integer>
34+
</dict>
35+
</plist>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDECodeSnippetCompletionPrefix</key>
6+
<string>bunfile</string>
7+
<key>IDECodeSnippetCompletionScopes</key>
8+
<array>
9+
<string>CodeBlock</string>
10+
</array>
11+
<key>IDECodeSnippetContents</key>
12+
<string>guard let path = Bundle.main.path(forResource: "&lt;#name#&gt;", ofType: "&lt;#extension#&gt;") else {
13+
// handle error when there is no file
14+
return
15+
}</string>
16+
<key>IDECodeSnippetIdentifier</key>
17+
<string>FAB1958D-6860-4962-A03D-5EF2C8B6CF39</string>
18+
<key>IDECodeSnippetLanguage</key>
19+
<string>Xcode.SourceCodeLanguage.Swift</string>
20+
<key>IDECodeSnippetPlatformFamily</key>
21+
<string>iphoneos</string>
22+
<key>IDECodeSnippetSummary</key>
23+
<string>Get the path from a file in the Bundle</string>
24+
<key>IDECodeSnippetTitle</key>
25+
<string>File from Bundle</string>
26+
<key>IDECodeSnippetUserSnippet</key>
27+
<true/>
28+
<key>IDECodeSnippetVersion</key>
29+
<integer>2</integer>
30+
</dict>
31+
</plist>

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Swifty Journey by Juan Dorado
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
XCODE_USER_SNIPPETS_DIR=~/Library/Developer/Xcode/UserData/CodeSnippets
2+
SNIPPETS_DIR=Code\ Snippets
3+
4+
install_snippets:
5+
mkdir -p $(XCODE_USER_SNIPPETS_DIR)
6+
rm -fR $(XCODE_USER_SNIPPETS_DIR)
7+
cp -R $(SNIPPETS_DIR)/ $(XCODE_USER_SNIPPETS_DIR)
8+
9+
uninstall_snippets:
10+
rm -fR $(XCODE_USER_SNIPPETS_DIR)

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# CodeSnippets for Xcode
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
[![IDE: Xcode](https://img.shields.io/badge/IDE-Xcode%2012-blue.svg)](https://developer.apple.com/xcode/)
5+
[![Language: Swift](https://img.shields.io/badge/Language-Swift-red.svg)](https://swift.org/blog/)
6+
7+
## Description
8+
9+
The **Snippets** are an amazing way to be more productive at the development time, they are bunch of code ready for an specific task.
10+
11+
Xcode already has some snippets for different purposes, also you can create your own.
12+
13+
The main idea in here is to create some snippets that could be helpful for me, and I hope to they be useful to you too.
14+
15+
## Installation
16+
17+
### Install snippets
18+
19+
To make an easy installation, you just need to run a command.
20+
21+
```bash
22+
make install_snippets
23+
```
24+
25+
> Note: To run this command you need to be on the root folder where the `Makefile` is located.
26+
27+
### Uninstall snippets
28+
29+
To delete the snippets just like the installation is an easy task, you just need to run the following command
30+
31+
```bash
32+
make uninstall_snippets
33+
```
34+
35+
> **WARNING**: This command will delete all the User Snippets folder, so in case you have one, BE CAREFUL, because with this command you are going to delete it too.
36+
37+
## Snippets
38+
39+
* **File from Bundle** (*bunfile*): Get the path from a file in the bundle
40+
* **JSON Decoder for Path** (*decodepath*): Lets you decode a file from an specific path and convert it to your `Codable` model.
41+
* **Programmatic Root Scene** (*pgmroot*): Add this snippet to your `SceneDelegate` when you don't want to use `Storyboards`. (iOS 13+)
42+
43+
---
44+
45+
## Contribution
46+
47+
In case you want to contribute to this Repo, feel free to create a Pull Request.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)