Skip to content
Merged

v5.0 #40

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
platform:
- iOS
- tvOS
#- watchOS
- watchOS
- macOS
runs-on: macos-latest
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -34,13 +34,15 @@ jobs:
#uses: codecov/codecov-action@v2
run: bash <(curl -s https://codecov.io/bash);
validate:
runs-on: macos-latest
runs-on: macos-12
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Swift Lint
run: swiftlint --strict
- name: Swift Format
run: swiftformat --lint .
- name: Pod Lint
run: pod lib lint --quick --fail-fast --verbose --skip-tests
- name: Example Project
Expand Down
17 changes: 10 additions & 7 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
--swiftversion 5.5
--swiftversion 5.7

--exclude Pods

--rules andOperator
--rules anyObjectProtocol

--rules blankLineAfterImports
--rules braces

--rules duplicateImports
--rules elseOnSameLine

--rules strongifiedSelf
--rules andOperator
--rules genericExtensions

--rules indent
--indent 4
Expand All @@ -21,24 +20,28 @@
--rules leadingDelimiters
--rules linebreakAtEndOfFile

--rules redundantFileprivate
--rules redundantGet
--rules redundantInit
--rules redundantOptionalBinding
--rules redundantParens
--rules redundantVoidReturnType
--rules semicolons

--rules spaceAroundBraces
--rules spaceAroundBrackets
--rules spaceAroundGenerics

--rules spaceAroundOperators
--rules spaceAroundParens

--rules spaceInsideBraces
--rules spaceInsideBrackets
--rules spaceInsideComments
--rules spaceInsideGenerics
--rules spaceInsideParens
--rules todos

--rules strongifiedSelf
--rules todos
--rules trailingCommas
--rules trailingSpace
--rules typeSugar
Expand Down
10 changes: 6 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ opt_in_rules:
- reduce_into
- redundant_nil_coalescing
- redundant_objc_attribute
- self_binding
- sorted_first_last
- static_operator
- strong_iboutlet
Expand All @@ -69,6 +70,7 @@ opt_in_rules:
- xct_specific_matcher
excluded:
- Pods
- .build

type_name:
excluded:
Expand All @@ -92,7 +94,7 @@ large_tuple:
warning: 3
error: 4
deployment_target:
iOS_deployment_target: 10
tvOS_deployment_target: 10
watchOS_deployment_target: 3
macOS_deployment_target: 10.13
iOS_deployment_target: 13
tvOS_deployment_target: 13
watchOS_deployment_target: 6
macOS_deployment_target: 10.15
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
All notable changes to this project will be documented in this file.
`FetchRequests` adheres to [Semantic Versioning](https://semver.org/).

## [5.0](https://github.com/square/FetchRequests/releases/tag/5.0.0)
Released on 2022-10-25

* Requires Swift 5.7
* Protocols define their primary associated types
* JSON literal arrays and dictionaries now must be strongly typed via the `JSONConvertible` protocol
* Annotate many methods as @MainActor
* All delegate methods
* All code with assert(Thread.isMainThread)
* Faulting an association when you're off the main thread will have different characteristics
* If the association already exists, nothing will change
* If the association does not already exist, it will always return nil and hit the main thread to batch fetch the associations
* More eventing supports occurring off of the main thread
* If needed, it will async bounce to the main thread to actually perform the change
* Newly allowed Events:
* Associated Value creation events
* Entity creation events
* Data reset events
* Note any changes to your model still must occur on the main thread
* data
* isDeleted
* NSSortDescriptor keyPaths
* Association keyPaths

## [4.0.4](https://github.com/square/FetchRequests/releases/tag/4.0.4)
Released on 2022-08-30

Expand Down
2 changes: 1 addition & 1 deletion Example/iOS-Example/Model+Persistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Model {
return UserDefaults.standard.dictionary(forKey: key) ?? [:]
}

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

let defaults = UserDefaults.standard
Expand Down
10 changes: 6 additions & 4 deletions Example/iOS-Example/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ extension Model {
// MARK: - FetchableObjectProtocol

extension Model: FetchableObjectProtocol {
func observeDataChanges(_ handler: @escaping () -> Void) -> InvalidatableToken {
return _data.observeChanges { change in handler() }
func observeDataChanges(_ handler: @escaping @MainActor () -> Void) -> InvalidatableToken {
return _data.observeChanges { change in
handler()
}
}

func observeIsDeletedChanges(_ handler: @escaping () -> Void) -> InvalidatableToken {
return self.observe(\.isDeleted, options: [.old, .new]) { object, change in
func observeIsDeletedChanges(_ handler: @escaping @MainActor () -> Void) -> InvalidatableToken {
return self.observe(\.isDeleted, options: [.old, .new]) { @MainActor(unsafe) object, change in
guard let old = change.oldValue, let new = change.newValue, old != new else {
return
}
Expand Down
9 changes: 6 additions & 3 deletions Example/iOS-Example/Observable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ struct Change<Value> {

@propertyWrapper
class Observable<Value> {
fileprivate var observers: Atomic<[UUID: (Change<Value>) -> Void]> = Atomic(wrappedValue: [:])
typealias Handler = @MainActor (Change<Value>) -> Void

fileprivate var observers: Atomic<[UUID: Handler]> = Atomic(wrappedValue: [:])

var wrappedValue: Value {
@MainActor(unsafe)
didSet {
assert(Thread.isMainThread)

Expand All @@ -34,7 +37,7 @@ class Observable<Value> {
self.wrappedValue = wrappedValue
}

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

extension Observable where Value: Equatable {
func observeChanges(handler: @escaping (Change<Value>) -> Void) -> InvalidatableToken {
func observeChanges(handler: @escaping Handler) -> InvalidatableToken {
return observe { change in
guard change.oldValue != change.newValue else {
return
Expand Down
2 changes: 1 addition & 1 deletion Example/iOS-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extension ViewController {
style: .destructive,
title: NSLocalizedString("Delete", comment: "Delete")
) { [weak self] action, view, completion in
guard let self = self else {
guard let self else {
return
}
let model = self.controller.object(at: indexPath)
Expand Down
8 changes: 4 additions & 4 deletions FetchRequests.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FetchRequests'
s.version = '4.0.4'
s.version = '5.0.0'
s.license = 'MIT'
s.summary = 'NSFetchedResultsController inspired eventing'
s.homepage = 'https://github.com/square/FetchRequests'
Expand All @@ -9,13 +9,13 @@ Pod::Spec.new do |s|

ios_deployment_target = '13.0'
tvos_deployment_target = '13.0'
macos_deployment_target = '10.15'
watchos_deployment_target = '6.0'
macos_deployment_target = '10.15'

s.ios.deployment_target = ios_deployment_target
s.tvos.deployment_target = tvos_deployment_target
s.macos.deployment_target = macos_deployment_target
s.watchos.deployment_target = watchos_deployment_target
s.macos.deployment_target = macos_deployment_target

s.swift_version = '5.0'

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

test_spec.ios.deployment_target = ios_deployment_target
test_spec.watchos.deployment_target = watchos_deployment_target
test_spec.tvos.deployment_target = tvos_deployment_target
test_spec.watchos.deployment_target = watchos_deployment_target
test_spec.macos.deployment_target = macos_deployment_target
end

Expand Down
34 changes: 9 additions & 25 deletions FetchRequests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 471C508022C6D0DC007F73E9 /* Build configuration list for PBXNativeTarget "FetchRequests-iOS" */;
buildPhases = (
4736ABDC22CC3A1500253EB6 /* SwiftLint */,
471C506722C6D0DB007F73E9 /* Headers */,
471C506822C6D0DB007F73E9 /* Sources */,
471C506922C6D0DB007F73E9 /* Frameworks */,
Expand Down Expand Up @@ -649,7 +648,7 @@
attributes = {
CLASSPREFIX = "";
LastSwiftUpdateCheck = 1100;
LastUpgradeCheck = 1100;
LastUpgradeCheck = 1400;
ORGANIZATIONNAME = "Speramus Inc.";
TargetAttributes = {
471C506B22C6D0DB007F73E9 = {
Expand Down Expand Up @@ -747,27 +746,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4736ABDC22CC3A1500253EB6 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
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";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
471C506822C6D0DB007F73E9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -1039,7 +1017,7 @@
INFOPLIST_FILE = FetchRequests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0;
MARKETING_VERSION = 5.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand All @@ -1049,6 +1027,7 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "";
Expand Down Expand Up @@ -1113,7 +1092,7 @@
INFOPLIST_FILE = FetchRequests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0;
MARKETING_VERSION = 5.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.crewapp.FetchRequests;
Expand All @@ -1122,6 +1101,7 @@
SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "";
Expand Down Expand Up @@ -1290,6 +1270,7 @@
47A6ED4422CA90A20034A854 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEAD_CODE_STRIPPING = YES;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -1304,6 +1285,7 @@
47A6ED4522CA90A20034A854 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEAD_CODE_STRIPPING = YES;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -1319,6 +1301,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = FetchRequests/TestsInfo.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1335,6 +1318,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = FetchRequests/TestsInfo.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading