Skip to content

Commit 48a5f44

Browse files
authored
Merge pull request #40 from square/feature/5.0
Release v5.0.0
2 parents 8d8e330 + 95d0e87 commit 48a5f44

43 files changed

Lines changed: 865 additions & 479 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
platform:
1818
- iOS
1919
- tvOS
20-
#- watchOS
20+
- watchOS
2121
- macOS
22-
runs-on: macos-latest
22+
runs-on: macos-12
2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v2
@@ -34,13 +34,15 @@ jobs:
3434
#uses: codecov/codecov-action@v2
3535
run: bash <(curl -s https://codecov.io/bash);
3636
validate:
37-
runs-on: macos-latest
37+
runs-on: macos-12
3838
needs: build
3939
steps:
4040
- name: Checkout
4141
uses: actions/checkout@v2
4242
- name: Swift Lint
4343
run: swiftlint --strict
44+
- name: Swift Format
45+
run: swiftformat --lint .
4446
- name: Pod Lint
4547
run: pod lib lint --quick --fail-fast --verbose --skip-tests
4648
- name: Example Project

.swiftformat

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
--swiftversion 5.5
1+
--swiftversion 5.7
22

33
--exclude Pods
44

5+
--rules andOperator
56
--rules anyObjectProtocol
67

8+
--rules blankLineAfterImports
79
--rules braces
8-
910
--rules duplicateImports
1011
--rules elseOnSameLine
11-
12-
--rules strongifiedSelf
13-
--rules andOperator
12+
--rules genericExtensions
1413

1514
--rules indent
1615
--indent 4
@@ -21,24 +20,28 @@
2120
--rules leadingDelimiters
2221
--rules linebreakAtEndOfFile
2322

23+
--rules redundantFileprivate
2424
--rules redundantGet
2525
--rules redundantInit
26+
--rules redundantOptionalBinding
2627
--rules redundantParens
2728
--rules redundantVoidReturnType
2829
--rules semicolons
30+
2931
--rules spaceAroundBraces
3032
--rules spaceAroundBrackets
3133
--rules spaceAroundGenerics
32-
3334
--rules spaceAroundOperators
3435
--rules spaceAroundParens
36+
3537
--rules spaceInsideBraces
3638
--rules spaceInsideBrackets
3739
--rules spaceInsideComments
3840
--rules spaceInsideGenerics
3941
--rules spaceInsideParens
40-
--rules todos
4142

43+
--rules strongifiedSelf
44+
--rules todos
4245
--rules trailingCommas
4346
--rules trailingSpace
4447
--rules typeSugar

.swiftlint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ opt_in_rules:
5454
- reduce_into
5555
- redundant_nil_coalescing
5656
- redundant_objc_attribute
57+
- self_binding
5758
- sorted_first_last
5859
- static_operator
5960
- strong_iboutlet
@@ -69,6 +70,7 @@ opt_in_rules:
6970
- xct_specific_matcher
7071
excluded:
7172
- Pods
73+
- .build
7274

7375
type_name:
7476
excluded:
@@ -92,7 +94,7 @@ large_tuple:
9294
warning: 3
9395
error: 4
9496
deployment_target:
95-
iOS_deployment_target: 10
96-
tvOS_deployment_target: 10
97-
watchOS_deployment_target: 3
98-
macOS_deployment_target: 10.13
97+
iOS_deployment_target: 13
98+
tvOS_deployment_target: 13
99+
watchOS_deployment_target: 6
100+
macOS_deployment_target: 10.15

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
All notable changes to this project will be documented in this file.
33
`FetchRequests` adheres to [Semantic Versioning](https://semver.org/).
44

5+
## [5.0](https://github.com/square/FetchRequests/releases/tag/5.0.0)
6+
Released on 2022-10-25
7+
8+
* Requires Swift 5.7
9+
* Protocols define their primary associated types
10+
* JSON literal arrays and dictionaries now must be strongly typed via the `JSONConvertible` protocol
11+
* Annotate many methods as @MainActor
12+
* All delegate methods
13+
* All code with assert(Thread.isMainThread)
14+
* Faulting an association when you're off the main thread will have different characteristics
15+
* If the association already exists, nothing will change
16+
* If the association does not already exist, it will always return nil and hit the main thread to batch fetch the associations
17+
* More eventing supports occurring off of the main thread
18+
* If needed, it will async bounce to the main thread to actually perform the change
19+
* Newly allowed Events:
20+
* Associated Value creation events
21+
* Entity creation events
22+
* Data reset events
23+
* Note any changes to your model still must occur on the main thread
24+
* data
25+
* isDeleted
26+
* NSSortDescriptor keyPaths
27+
* Association keyPaths
28+
529
## [4.0.4](https://github.com/square/FetchRequests/releases/tag/4.0.4)
630
Released on 2022-08-30
731

Example/iOS-Example/Model+Persistence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension Model {
4747
return UserDefaults.standard.dictionary(forKey: key) ?? [:]
4848
}
4949

50-
fileprivate class func updateStorage(_ block: (inout [String: Any]) throws -> Void) rethrows {
50+
private class func updateStorage(_ block: (inout [String: Any]) throws -> Void) rethrows {
5151
assert(Thread.isMainThread)
5252

5353
let defaults = UserDefaults.standard

Example/iOS-Example/Model.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ extension Model {
109109
// MARK: - FetchableObjectProtocol
110110

111111
extension Model: FetchableObjectProtocol {
112-
func observeDataChanges(_ handler: @escaping () -> Void) -> InvalidatableToken {
113-
return _data.observeChanges { change in handler() }
112+
func observeDataChanges(_ handler: @escaping @MainActor () -> Void) -> InvalidatableToken {
113+
return _data.observeChanges { change in
114+
handler()
115+
}
114116
}
115117

116-
func observeIsDeletedChanges(_ handler: @escaping () -> Void) -> InvalidatableToken {
117-
return self.observe(\.isDeleted, options: [.old, .new]) { object, change in
118+
func observeIsDeletedChanges(_ handler: @escaping @MainActor () -> Void) -> InvalidatableToken {
119+
return self.observe(\.isDeleted, options: [.old, .new]) { @MainActor(unsafe) object, change in
118120
guard let old = change.oldValue, let new = change.newValue, old != new else {
119121
return
120122
}

Example/iOS-Example/Observable.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ struct Change<Value> {
1717

1818
@propertyWrapper
1919
class Observable<Value> {
20-
fileprivate var observers: Atomic<[UUID: (Change<Value>) -> Void]> = Atomic(wrappedValue: [:])
20+
typealias Handler = @MainActor (Change<Value>) -> Void
21+
22+
fileprivate var observers: Atomic<[UUID: Handler]> = Atomic(wrappedValue: [:])
2123

2224
var wrappedValue: Value {
25+
@MainActor(unsafe)
2326
didSet {
2427
assert(Thread.isMainThread)
2528

@@ -34,7 +37,7 @@ class Observable<Value> {
3437
self.wrappedValue = wrappedValue
3538
}
3639

37-
func observe(handler: @escaping (Change<Value>) -> Void) -> InvalidatableToken {
40+
func observe(handler: @escaping Handler) -> InvalidatableToken {
3841
let token = Token(parent: self)
3942
observers.mutate { value in
4043
value[token.uuid] = handler
@@ -44,7 +47,7 @@ class Observable<Value> {
4447
}
4548

4649
extension Observable where Value: Equatable {
47-
func observeChanges(handler: @escaping (Change<Value>) -> Void) -> InvalidatableToken {
50+
func observeChanges(handler: @escaping Handler) -> InvalidatableToken {
4851
return observe { change in
4952
guard change.oldValue != change.newValue else {
5053
return

Example/iOS-Example/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extension ViewController {
105105
style: .destructive,
106106
title: NSLocalizedString("Delete", comment: "Delete")
107107
) { [weak self] action, view, completion in
108-
guard let self = self else {
108+
guard let self else {
109109
return
110110
}
111111
let model = self.controller.object(at: indexPath)

FetchRequests.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FetchRequests'
3-
s.version = '4.0.4'
3+
s.version = '5.0.0'
44
s.license = 'MIT'
55
s.summary = 'NSFetchedResultsController inspired eventing'
66
s.homepage = 'https://github.com/square/FetchRequests'
@@ -9,13 +9,13 @@ Pod::Spec.new do |s|
99

1010
ios_deployment_target = '13.0'
1111
tvos_deployment_target = '13.0'
12-
macos_deployment_target = '10.15'
1312
watchos_deployment_target = '6.0'
13+
macos_deployment_target = '10.15'
1414

1515
s.ios.deployment_target = ios_deployment_target
1616
s.tvos.deployment_target = tvos_deployment_target
17-
s.macos.deployment_target = macos_deployment_target
1817
s.watchos.deployment_target = watchos_deployment_target
18+
s.macos.deployment_target = macos_deployment_target
1919

2020
s.swift_version = '5.0'
2121

@@ -28,8 +28,8 @@ Pod::Spec.new do |s|
2828
test_spec.source_files = 'FetchRequests/Tests/**/*.swift'
2929

3030
test_spec.ios.deployment_target = ios_deployment_target
31-
test_spec.watchos.deployment_target = watchos_deployment_target
3231
test_spec.tvos.deployment_target = tvos_deployment_target
32+
test_spec.watchos.deployment_target = watchos_deployment_target
3333
test_spec.macos.deployment_target = macos_deployment_target
3434
end
3535

FetchRequests.xcodeproj/project.pbxproj

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@
488488
isa = PBXNativeTarget;
489489
buildConfigurationList = 471C508022C6D0DC007F73E9 /* Build configuration list for PBXNativeTarget "FetchRequests-iOS" */;
490490
buildPhases = (
491-
4736ABDC22CC3A1500253EB6 /* SwiftLint */,
492491
471C506722C6D0DB007F73E9 /* Headers */,
493492
471C506822C6D0DB007F73E9 /* Sources */,
494493
471C506922C6D0DB007F73E9 /* Frameworks */,
@@ -649,7 +648,7 @@
649648
attributes = {
650649
CLASSPREFIX = "";
651650
LastSwiftUpdateCheck = 1100;
652-
LastUpgradeCheck = 1100;
651+
LastUpgradeCheck = 1400;
653652
ORGANIZATIONNAME = "Speramus Inc.";
654653
TargetAttributes = {
655654
471C506B22C6D0DB007F73E9 = {
@@ -747,27 +746,6 @@
747746
};
748747
/* End PBXResourcesBuildPhase section */
749748

750-
/* Begin PBXShellScriptBuildPhase section */
751-
4736ABDC22CC3A1500253EB6 /* SwiftLint */ = {
752-
isa = PBXShellScriptBuildPhase;
753-
buildActionMask = 2147483647;
754-
files = (
755-
);
756-
inputFileListPaths = (
757-
);
758-
inputPaths = (
759-
);
760-
name = SwiftLint;
761-
outputFileListPaths = (
762-
);
763-
outputPaths = (
764-
);
765-
runOnlyForDeploymentPostprocessing = 0;
766-
shellPath = /bin/sh;
767-
shellScript = "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:/opt/brew/bin\n\nif which swiftlint >/dev/null; then\n swiftlint --strict\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
768-
};
769-
/* End PBXShellScriptBuildPhase section */
770-
771749
/* Begin PBXSourcesBuildPhase section */
772750
471C506822C6D0DB007F73E9 /* Sources */ = {
773751
isa = PBXSourcesBuildPhase;
@@ -1039,7 +1017,7 @@
10391017
INFOPLIST_FILE = FetchRequests/Info.plist;
10401018
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
10411019
MACOSX_DEPLOYMENT_TARGET = 10.15;
1042-
MARKETING_VERSION = 4.0;
1020+
MARKETING_VERSION = 5.0;
10431021
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
10441022
MTL_FAST_MATH = YES;
10451023
ONLY_ACTIVE_ARCH = YES;
@@ -1049,6 +1027,7 @@
10491027
SKIP_INSTALL = YES;
10501028
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
10511029
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1030+
SWIFT_STRICT_CONCURRENCY = targeted;
10521031
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
10531032
SWIFT_VERSION = 5.0;
10541033
TARGETED_DEVICE_FAMILY = "";
@@ -1113,7 +1092,7 @@
11131092
INFOPLIST_FILE = FetchRequests/Info.plist;
11141093
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
11151094
MACOSX_DEPLOYMENT_TARGET = 10.15;
1116-
MARKETING_VERSION = 4.0;
1095+
MARKETING_VERSION = 5.0;
11171096
MTL_ENABLE_DEBUG_INFO = NO;
11181097
MTL_FAST_MATH = YES;
11191098
PRODUCT_BUNDLE_IDENTIFIER = com.crewapp.FetchRequests;
@@ -1122,6 +1101,7 @@
11221101
SKIP_INSTALL = YES;
11231102
SWIFT_COMPILATION_MODE = wholemodule;
11241103
SWIFT_OPTIMIZATION_LEVEL = "-O";
1104+
SWIFT_STRICT_CONCURRENCY = targeted;
11251105
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
11261106
SWIFT_VERSION = 5.0;
11271107
TARGETED_DEVICE_FAMILY = "";
@@ -1290,6 +1270,7 @@
12901270
47A6ED4422CA90A20034A854 /* Debug */ = {
12911271
isa = XCBuildConfiguration;
12921272
buildSettings = {
1273+
DEAD_CODE_STRIPPING = YES;
12931274
DYLIB_INSTALL_NAME_BASE = "@rpath";
12941275
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
12951276
LD_RUNPATH_SEARCH_PATHS = (
@@ -1304,6 +1285,7 @@
13041285
47A6ED4522CA90A20034A854 /* Release */ = {
13051286
isa = XCBuildConfiguration;
13061287
buildSettings = {
1288+
DEAD_CODE_STRIPPING = YES;
13071289
DYLIB_INSTALL_NAME_BASE = "@rpath";
13081290
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
13091291
LD_RUNPATH_SEARCH_PATHS = (
@@ -1319,6 +1301,7 @@
13191301
isa = XCBuildConfiguration;
13201302
buildSettings = {
13211303
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
1304+
DEAD_CODE_STRIPPING = YES;
13221305
INFOPLIST_FILE = FetchRequests/TestsInfo.plist;
13231306
LD_RUNPATH_SEARCH_PATHS = (
13241307
"$(inherited)",
@@ -1335,6 +1318,7 @@
13351318
isa = XCBuildConfiguration;
13361319
buildSettings = {
13371320
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
1321+
DEAD_CODE_STRIPPING = YES;
13381322
INFOPLIST_FILE = FetchRequests/TestsInfo.plist;
13391323
LD_RUNPATH_SEARCH_PATHS = (
13401324
"$(inherited)",

0 commit comments

Comments
 (0)