Skip to content

Commit f5d6633

Browse files
committed
[5.0.0] release prep
1 parent 01dc39b commit f5d6633

9 files changed

+129
-93
lines changed

Foil.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Foil'
3-
s.version = '4.0.1'
3+
s.version = '5.0.0'
44
s.license = 'MIT'
55

66
s.summary = 'A lightweight property wrapper for UserDefaults'

README.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ Foil, as in "let me quickly and easily **wrap** and **store** this leftover food
1919
2020
## Usage
2121

22-
You can use `@WrappedDefault` for non-optional values and `@WrappedDefaultOptional` for optional ones.
22+
You can use `@FoilDefaultStorage` for non-optional values and `@FoilDefaultStorageOptional` for optional ones.
2323
You may wish to store all your user defaults in one place, however, that is not necessary. **Any** property on **any type** can use this wrapper.
2424

2525
```swift
2626
final class AppSettings {
2727
static let shared = AppSettings()
2828

29-
@WrappedDefault(key: "flagEnabled")
29+
@FoilDefaultStorage(key: "flagEnabled")
3030
var flagEnabled = true
3131

32-
@WrappedDefault(key: "totalCount")
32+
@FoilDefaultStorage(key: "totalCount")
3333
var totalCount = 0
3434

35-
@WrappedDefaultOptional(key: "timestamp")
35+
@FoilDefaultStorageOptional(key: "timestamp")
3636
var timestamp: Date?
3737
}
3838

@@ -56,13 +56,13 @@ enum AppSettingsKey: String, CaseIterable {
5656
case timestamp
5757
}
5858

59-
extension WrappedDefault {
59+
extension FoilDefaultStorage {
6060
init(wrappedValue: T, _ key: AppSettingsKey) {
6161
self.init(wrappedValue: wrappedValue, key: key.rawValue)
6262
}
6363
}
6464

65-
extension WrappedDefaultOptional {
65+
extension FoilDefaultStorageOptional {
6666
init(_ key: AppSettingsKey) {
6767
self.init(key: key.rawValue)
6868
}
@@ -77,10 +77,10 @@ There are [many ways to observe property changes](https://www.jessesquires.com/b
7777
final class AppSettings: NSObject {
7878
static let shared = AppSettings()
7979

80-
@WrappedDefaultOptional(key: "userId")
80+
@FoilDefaultStorageOptional(key: "userId")
8181
@objc dynamic var userId: String?
8282

83-
@WrappedDefaultOptional(key: "average")
83+
@FoilDefaultStorageOptional(key: "average")
8484
var average: Double?
8585
}
8686
```
@@ -122,9 +122,9 @@ AppSettings.shared
122122

123123
### Supported types
124124

125-
The following types are supported by default for use with `@WrappedDefault`.
125+
The following types are supported by default for use with `@FoilDefaultStorage`.
126126

127-
> [!IMPORTANT]
127+
> [!IMPORTANT]
128128
> Adding support for custom types is possible by conforming to `UserDefaultsSerializable`. However, **this is highly discouraged** as all `plist` types are supported by default. `UserDefaults` is not intended for storing complex data structures and object graphs. You should probably be using a proper database (or serializing to disk via `Codable`) instead.
129129
>
130130
> While `Foil` supports storing `Codable` types by default, you should **use this sparingly** and _only_ for small objects with few properties.
@@ -144,8 +144,8 @@ The following types are supported by default for use with `@WrappedDefault`.
144144
- `RawRepresentable` types
145145
- `Codable` types
146146

147-
> [!WARNING]
148-
> If you are storing custom `Codable` types and using the default implementation of `UserDefaultsSerializable` provided by `Foil`, then **you must use the optional variant of the property wrapper**, `@WrappedDefaultOptional`. This will allow you to make breaking changes to your `Codable` type (e.g., adding or removing a property). Alternatively, you can provide a custom implementation of `Codable` that supports migration, or provide a custom implementation of `UserDefaultsSerializable` that handles encoding/decoding failures. See the example below.
147+
> [!WARNING]
148+
> If you are storing custom `Codable` types and using the default implementation of `UserDefaultsSerializable` provided by `Foil`, then **you must use the optional variant of the property wrapper**, `@FoilDefaultStorageOptional`. This will allow you to make breaking changes to your `Codable` type (e.g., adding or removing a property). Alternatively, you can provide a custom implementation of `Codable` that supports migration, or provide a custom implementation of `UserDefaultsSerializable` that handles encoding/decoding failures. See the example below.
149149
150150
**Codable Example:**
151151
```swift
@@ -156,12 +156,12 @@ struct User: Codable, UserDefaultsSerializable {
156156
}
157157

158158
// Yes, do this
159-
@WrappedDefaultOptional(key: "user")
159+
@FoilDefaultStorageOptional(key: "user")
160160
var user: User?
161161

162162
// NO, do NOT this
163163
// This will crash if you change User by adding/removing properties
164-
@WrappedDefault(key: "user")
164+
@FoilDefaultStorage(key: "user")
165165
var user = User()
166166
```
167167

@@ -190,14 +190,14 @@ var user = User()
190190
### [CocoaPods](http://cocoapods.org)
191191

192192
````ruby
193-
pod 'Foil', '~> 4.0.0'
193+
pod 'Foil', '~> 5.0.0'
194194
````
195195

196196
### [Swift Package Manager](https://swift.org/package-manager/)
197197

198198
```swift
199199
dependencies: [
200-
.package(url: "https://github.com/jessesquires/Foil.git", from: "4.0.0")
200+
.package(url: "https://github.com/jessesquires/Foil.git", from: "5.0.0")
201201
]
202202
```
203203

docs/Protocols.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<a title="Protocols Reference"></a>
1818
<header>
1919
<div class="content-wrapper">
20-
<p><a href="index.html">Foil 4.0.1 Docs</a> (100% documented)</p>
20+
<p><a href="index.html">Foil 5.0.0 Docs</a> (100% documented)</p>
2121
<p class="header-right"><a href="https://github.com/jessesquires/Foil"><img src="img/gh.png" alt="GitHub"/>View on GitHub</a></p>
2222
<div class="header-right">
2323
<form role="search" action="search.json">
@@ -48,10 +48,10 @@
4848
<a href="Structs.html">Structures</a>
4949
<ul class="nav-group-tasks">
5050
<li class="nav-group-task">
51-
<a href="Structs/WrappedDefault.html">WrappedDefault</a>
51+
<a href="Structs/FoilDefaultStorage.html">FoilDefaultStorage</a>
5252
</li>
5353
<li class="nav-group-task">
54-
<a href="Structs/WrappedDefaultOptional.html">WrappedDefaultOptional</a>
54+
<a href="Structs/FoilDefaultStorageOptional.html">FoilDefaultStorageOptional</a>
5555
</li>
5656
</ul>
5757
</li>
@@ -98,6 +98,7 @@ <h1>Protocols</h1>
9898
<li><code>Set</code></li>
9999
<li><code>Dictionary</code></li>
100100
<li><code>RawRepresentable</code> types</li>
101+
<li><code>Codable</code> types</li>
101102
</ul>
102103

103104
<a href="Protocols/UserDefaultsSerializable.html" class="slightly-smaller">See more</a>
@@ -118,7 +119,7 @@ <h4>Declaration</h4>
118119
</section>
119120
</section>
120121
<section id="footer">
121-
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-09)</p>
122+
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-11)</p>
122123
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
123124
</section>
124125
</article>

docs/Protocols/UserDefaultsSerializable.html

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<a title="UserDefaultsSerializable Protocol Reference"></a>
1818
<header>
1919
<div class="content-wrapper">
20-
<p><a href="../index.html">Foil 4.0.1 Docs</a> (100% documented)</p>
20+
<p><a href="../index.html">Foil 5.0.0 Docs</a> (100% documented)</p>
2121
<p class="header-right"><a href="https://github.com/jessesquires/Foil"><img src="../img/gh.png" alt="GitHub"/>View on GitHub</a></p>
2222
<div class="header-right">
2323
<form role="search" action="../search.json">
@@ -48,10 +48,10 @@
4848
<a href="../Structs.html">Structures</a>
4949
<ul class="nav-group-tasks">
5050
<li class="nav-group-task">
51-
<a href="../Structs/WrappedDefault.html">WrappedDefault</a>
51+
<a href="../Structs/FoilDefaultStorage.html">FoilDefaultStorage</a>
5252
</li>
5353
<li class="nav-group-task">
54-
<a href="../Structs/WrappedDefaultOptional.html">WrappedDefaultOptional</a>
54+
<a href="../Structs/FoilDefaultStorageOptional.html">FoilDefaultStorageOptional</a>
5555
</li>
5656
</ul>
5757
</li>
@@ -86,6 +86,7 @@ <h1>UserDefaultsSerializable</h1>
8686
<li><code>Set</code></li>
8787
<li><code>Dictionary</code></li>
8888
<li><code>RawRepresentable</code> types</li>
89+
<li><code>Codable</code> types</li>
8990
</ul>
9091

9192
</section>
@@ -149,24 +150,24 @@ <h4>Declaration</h4>
149150
<li class="item">
150151
<div>
151152
<code>
152-
<a name="/s:4Foil24UserDefaultsSerializableP11storedValuex06StoredF0Qz_tcfc"></a>
153+
<a name="/s:4Foil24UserDefaultsSerializableP11storedValuexSg06StoredF0Qz_tcfc"></a>
153154
<a name="//apple_ref/swift/Method/init(storedValue:)" class="dashAnchor"></a>
154-
<a class="token" href="#/s:4Foil24UserDefaultsSerializableP11storedValuex06StoredF0Qz_tcfc">init(storedValue:<wbr>)</a>
155+
<a class="token" href="#/s:4Foil24UserDefaultsSerializableP11storedValuexSg06StoredF0Qz_tcfc">init(storedValue:<wbr>)</a>
155156
</code>
156157
</div>
157158
<div class="height-container">
158159
<div class="pointer-container"></div>
159160
<section class="section">
160161
<div class="pointer"></div>
161162
<div class="abstract">
162-
<p>Initializes the object using the provided value.</p>
163+
<p>Initializes the object using the provided value, or returns <code>nil</code> if initialization fails.</p>
163164

164165
</div>
165166
<div class="declaration">
166167
<h4>Declaration</h4>
167168
<div class="language">
168169
<p class="aside-title">Swift</p>
169-
<pre class="highlight swift"><code><span class="nf">init</span><span class="p">(</span><span class="nv">storedValue</span><span class="p">:</span> <span class="kt"><a href="../Protocols/UserDefaultsSerializable.html#/s:4Foil24UserDefaultsSerializableP11StoredValueQa">StoredValue</a></span><span class="p">)</span></code></pre>
170+
<pre class="highlight swift"><code><span class="nf">init</span><span class="p">?(</span><span class="nv">storedValue</span><span class="p">:</span> <span class="kt"><a href="../Protocols/UserDefaultsSerializable.html#/s:4Foil24UserDefaultsSerializableP11StoredValueQa">StoredValue</a></span><span class="p">)</span></code></pre>
170171

171172
</div>
172173
</div>
@@ -197,7 +198,7 @@ <h4>Parameters</h4>
197198
</section>
198199
</section>
199200
<section id="footer">
200-
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-09)</p>
201+
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-11)</p>
201202
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
202203
</section>
203204
</article>

docs/Structs.html

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<a title="Structures Reference"></a>
1818
<header>
1919
<div class="content-wrapper">
20-
<p><a href="index.html">Foil 4.0.1 Docs</a> (100% documented)</p>
20+
<p><a href="index.html">Foil 5.0.0 Docs</a> (100% documented)</p>
2121
<p class="header-right"><a href="https://github.com/jessesquires/Foil"><img src="img/gh.png" alt="GitHub"/>View on GitHub</a></p>
2222
<div class="header-right">
2323
<form role="search" action="search.json">
@@ -48,10 +48,10 @@
4848
<a href="Structs.html">Structures</a>
4949
<ul class="nav-group-tasks">
5050
<li class="nav-group-task">
51-
<a href="Structs/WrappedDefault.html">WrappedDefault</a>
51+
<a href="Structs/FoilDefaultStorage.html">FoilDefaultStorage</a>
5252
</li>
5353
<li class="nav-group-task">
54-
<a href="Structs/WrappedDefaultOptional.html">WrappedDefaultOptional</a>
54+
<a href="Structs/FoilDefaultStorageOptional.html">FoilDefaultStorageOptional</a>
5555
</li>
5656
</ul>
5757
</li>
@@ -70,9 +70,9 @@ <h1>Structures</h1>
7070
<li class="item">
7171
<div>
7272
<code>
73-
<a name="/s:4Foil14WrappedDefaultV"></a>
74-
<a name="//apple_ref/swift/Struct/WrappedDefault" class="dashAnchor"></a>
75-
<a class="token" href="#/s:4Foil14WrappedDefaultV">WrappedDefault</a>
73+
<a name="/s:4Foil0A14DefaultStorageV"></a>
74+
<a name="//apple_ref/swift/Struct/FoilDefaultStorage" class="dashAnchor"></a>
75+
<a class="token" href="#/s:4Foil0A14DefaultStorageV">FoilDefaultStorage</a>
7676
</code>
7777
</div>
7878
<div class="height-container">
@@ -83,14 +83,14 @@ <h1>Structures</h1>
8383
<p>A property wrapper that uses <code>UserDefaults</code> as a backing store,
8484
whose <code>wrappedValue</code> is non-optional and registers a <strong>non-optional default value</strong>.</p>
8585

86-
<a href="Structs/WrappedDefault.html" class="slightly-smaller">See more</a>
86+
<a href="Structs/FoilDefaultStorage.html" class="slightly-smaller">See more</a>
8787
</div>
8888
<div class="declaration">
8989
<h4>Declaration</h4>
9090
<div class="language">
9191
<p class="aside-title">Swift</p>
9292
<pre class="highlight swift"><code><span class="kd">@propertyWrapper</span>
93-
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">WrappedDefault</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/UserDefaultsSerializable.html">UserDefaultsSerializable</a></span></code></pre>
93+
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">FoilDefaultStorage</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/UserDefaultsSerializable.html">UserDefaultsSerializable</a></span></code></pre>
9494

9595
</div>
9696
</div>
@@ -100,9 +100,9 @@ <h4>Declaration</h4>
100100
<li class="item">
101101
<div>
102102
<code>
103-
<a name="/s:4Foil22WrappedDefaultOptionalV"></a>
104-
<a name="//apple_ref/swift/Struct/WrappedDefaultOptional" class="dashAnchor"></a>
105-
<a class="token" href="#/s:4Foil22WrappedDefaultOptionalV">WrappedDefaultOptional</a>
103+
<a name="/s:4Foil0A22DefaultStorageOptionalV"></a>
104+
<a name="//apple_ref/swift/Struct/FoilDefaultStorageOptional" class="dashAnchor"></a>
105+
<a class="token" href="#/s:4Foil0A22DefaultStorageOptionalV">FoilDefaultStorageOptional</a>
106106
</code>
107107
</div>
108108
<div class="height-container">
@@ -113,14 +113,14 @@ <h4>Declaration</h4>
113113
<p>A property wrapper that uses <code>UserDefaults</code> as a backing store,
114114
whose <code>wrappedValue</code> is optional and <strong>does not provide default value</strong>.</p>
115115

116-
<a href="Structs/WrappedDefaultOptional.html" class="slightly-smaller">See more</a>
116+
<a href="Structs/FoilDefaultStorageOptional.html" class="slightly-smaller">See more</a>
117117
</div>
118118
<div class="declaration">
119119
<h4>Declaration</h4>
120120
<div class="language">
121121
<p class="aside-title">Swift</p>
122122
<pre class="highlight swift"><code><span class="kd">@propertyWrapper</span>
123-
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">WrappedDefaultOptional</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/UserDefaultsSerializable.html">UserDefaultsSerializable</a></span></code></pre>
123+
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">FoilDefaultStorageOptional</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/UserDefaultsSerializable.html">UserDefaultsSerializable</a></span></code></pre>
124124

125125
</div>
126126
</div>
@@ -132,7 +132,7 @@ <h4>Declaration</h4>
132132
</section>
133133
</section>
134134
<section id="footer">
135-
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-09)</p>
135+
<p>&copy; 2024 <a class="link" href="https://jessesquires.com" target="_blank" rel="external noopener">Jesse Squires</a>. All rights reserved. (Last updated: 2024-01-11)</p>
136136
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
137137
</section>
138138
</article>

0 commit comments

Comments
 (0)