Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ee3dab3
[BREAKING] Require Swift 5.8
groue Jul 13, 2024
1643883
Enable strict concurrency checkings
groue Jul 13, 2024
2710b24
[BREAKING] Add dependency on GRDB
groue Jul 13, 2024
e979606
Fix concurrency warnings in EnvironmentStateObject
groue Jul 13, 2024
8680fd5
Fix concurrency warnings in Query
groue Jul 13, 2024
91011fe
[BREAKING] rename DatabaseContext to Context
groue Jul 13, 2024
d7c7765
Queryable methods are MainActor-isolated
groue Jul 13, 2024
487f2eb
Introduce DatabaseContext
groue Jul 13, 2024
a639954
The databaseContext SwiftUI environment key
groue Jul 13, 2024
cbd246a
Combine+MainActor utilities
groue Jul 13, 2024
838b1ad
FetchQueryable
groue Jul 13, 2024
fecd5e9
ObservationQueryable
groue Jul 13, 2024
3086d5f
Update QueryTest project
groue Jul 13, 2024
4205e75
Upgrade demo apps
groue Jul 13, 2024
efb412f
Query exposes its latest error
groue Jul 13, 2024
944e322
DocC + Cleanup
groue Jul 13, 2024
a16d7f8
Fix bug in player presence detection
groue Jul 14, 2024
e9616f8
Fix Xcode 16 beta 3 warnings
groue Jul 14, 2024
bfa9e7a
DocC
groue Jul 14, 2024
286b27a
Fix concurrency warnings
groue Jul 14, 2024
b1bff20
DocC
groue Jul 14, 2024
4d237cf
[WIP] Migrating To GRDBQuery 0.9 guide
groue Jul 14, 2024
5b26a1a
PresenceObservationQueryable
groue Jul 14, 2024
95a04a6
[BREAKING] Require Swift 5.10
groue Jul 14, 2024
257f235
[WIP] Migrating To GRDBQuery 0.9 guide
groue Jul 14, 2024
a54e578
QueryDemo uses PresenceObservationQueryable
groue Jul 14, 2024
5b05ddb
DocC
groue Jul 14, 2024
96bc06d
Hide the databaseContext setter
groue Jul 14, 2024
2722ac1
DocC
groue Jul 15, 2024
a25b23d
Make Publisher.scanPresence public
groue Jul 15, 2024
71abc29
DocC
groue Jul 20, 2024
5964896
Remove dependency on apple/swift-docc-plugin
groue Jul 20, 2024
b13f8ea
Use xcbeautify if present
groue Jul 20, 2024
57721be
Fix Xcode 16 beta 3 warnings
groue Jul 20, 2024
3190d28
README
groue Jul 20, 2024
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
123 changes: 4 additions & 119 deletions Documentation/MVVMDemo/MVVMDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
564014E928364A5300EEA9BC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 564014E828364A5300EEA9BC /* Assets.xcassets */; };
564014EC28364A5300EEA9BC /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 564014EB28364A5300EEA9BC /* Preview Assets.xcassets */; };
564014F628364A5300EEA9BC /* MVVMDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564014F528364A5300EEA9BC /* MVVMDemoTests.swift */; };
5640150028364A5300EEA9BC /* MVVMDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564014FF28364A5300EEA9BC /* MVVMDemoUITests.swift */; };
5640150228364A5300EEA9BC /* MVVMDemoUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5640150128364A5300EEA9BC /* MVVMDemoUITestsLaunchTests.swift */; };
5640151028364AB500EEA9BC /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 5640150F28364AB500EEA9BC /* GRDB */; };
5640151D28364B3D00EEA9BC /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5640151628364B3D00EEA9BC /* PlayerView.swift */; };
5640151E28364B3D00EEA9BC /* PlayerEditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5640151728364B3D00EEA9BC /* PlayerEditionView.swift */; };
Expand All @@ -39,13 +37,6 @@
remoteGlobalIDString = 564014E028364A5200EEA9BC;
remoteInfo = MVVMDemo;
};
564014FC28364A5300EEA9BC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 564014D928364A5200EEA9BC /* Project object */;
proxyType = 1;
remoteGlobalIDString = 564014E028364A5200EEA9BC;
remoteInfo = MVVMDemo;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand All @@ -59,9 +50,6 @@
564014EB28364A5300EEA9BC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
564014F128364A5300EEA9BC /* MVVMDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MVVMDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
564014F528364A5300EEA9BC /* MVVMDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVVMDemoTests.swift; sourceTree = "<group>"; };
564014FB28364A5300EEA9BC /* MVVMDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MVVMDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
564014FF28364A5300EEA9BC /* MVVMDemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVVMDemoUITests.swift; sourceTree = "<group>"; };
5640150128364A5300EEA9BC /* MVVMDemoUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVVMDemoUITestsLaunchTests.swift; sourceTree = "<group>"; };
5640151628364B3D00EEA9BC /* PlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
5640151728364B3D00EEA9BC /* PlayerEditionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerEditionView.swift; sourceTree = "<group>"; };
5640151828364B3D00EEA9BC /* DatabaseButtons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseButtons.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -94,13 +82,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
564014F828364A5300EEA9BC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -110,7 +91,6 @@
5640153A2836921900EEA9BC /* README.md */,
564014E328364A5200EEA9BC /* MVVMDemo */,
564014F428364A5300EEA9BC /* MVVMDemoTests */,
564014FE28364A5300EEA9BC /* MVVMDemoUITests */,
564014E228364A5200EEA9BC /* Products */,
5640152828364D9A00EEA9BC /* Packages */,
5640152A28364DE600EEA9BC /* Frameworks */,
Expand All @@ -122,7 +102,6 @@
children = (
564014E128364A5200EEA9BC /* MVVMDemo.app */,
564014F128364A5300EEA9BC /* MVVMDemoTests.xctest */,
564014FB28364A5300EEA9BC /* MVVMDemoUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -157,15 +136,6 @@
path = MVVMDemoTests;
sourceTree = "<group>";
};
564014FE28364A5300EEA9BC /* MVVMDemoUITests */ = {
isa = PBXGroup;
children = (
564014FF28364A5300EEA9BC /* MVVMDemoUITests.swift */,
5640150128364A5300EEA9BC /* MVVMDemoUITestsLaunchTests.swift */,
);
path = MVVMDemoUITests;
sourceTree = "<group>";
};
5640151228364B0400EEA9BC /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -266,24 +236,6 @@
productReference = 564014F128364A5300EEA9BC /* MVVMDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
564014FA28364A5300EEA9BC /* MVVMDemoUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5640150B28364A5300EEA9BC /* Build configuration list for PBXNativeTarget "MVVMDemoUITests" */;
buildPhases = (
564014F728364A5300EEA9BC /* Sources */,
564014F828364A5300EEA9BC /* Frameworks */,
564014F928364A5300EEA9BC /* Resources */,
);
buildRules = (
);
dependencies = (
564014FD28364A5300EEA9BC /* PBXTargetDependency */,
);
name = MVVMDemoUITests;
productName = MVVMDemoUITests;
productReference = 564014FB28364A5300EEA9BC /* MVVMDemoUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -301,10 +253,6 @@
CreatedOnToolsVersion = 13.4;
TestTargetID = 564014E028364A5200EEA9BC;
};
564014FA28364A5300EEA9BC = {
CreatedOnToolsVersion = 13.4;
TestTargetID = 564014E028364A5200EEA9BC;
};
};
};
buildConfigurationList = 564014DC28364A5200EEA9BC /* Build configuration list for PBXProject "MVVMDemo" */;
Expand All @@ -325,7 +273,6 @@
targets = (
564014E028364A5200EEA9BC /* MVVMDemo */,
564014F028364A5300EEA9BC /* MVVMDemoTests */,
564014FA28364A5300EEA9BC /* MVVMDemoUITests */,
);
};
/* End PBXProject section */
Expand All @@ -347,13 +294,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
564014F928364A5300EEA9BC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -386,15 +326,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
564014F728364A5300EEA9BC /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5640150228364A5300EEA9BC /* MVVMDemoUITestsLaunchTests.swift in Sources */,
5640150028364A5300EEA9BC /* MVVMDemoUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand All @@ -403,11 +334,6 @@
target = 564014E028364A5200EEA9BC /* MVVMDemo */;
targetProxy = 564014F228364A5300EEA9BC /* PBXContainerItemProxy */;
};
564014FD28364A5300EEA9BC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 564014E028364A5200EEA9BC /* MVVMDemo */;
targetProxy = 564014FC28364A5300EEA9BC /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -540,6 +466,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -568,6 +495,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -589,7 +517,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.MVVMDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -608,7 +536,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.MVVMDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -619,40 +547,6 @@
};
name = Release;
};
5640150C28364A5300EEA9BC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.MVVMDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = MVVMDemo;
};
name = Debug;
};
5640150D28364A5300EEA9BC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.MVVMDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = MVVMDemo;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -683,15 +577,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
5640150B28364A5300EEA9BC /* Build configuration list for PBXNativeTarget "MVVMDemoUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5640150C28364A5300EEA9BC /* Debug */,
5640150D28364A5300EEA9BC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down

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

2 changes: 1 addition & 1 deletion Documentation/MVVMDemo/MVVMDemo/MVVMDemoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct MVVMDemoApp: App {
WindowGroup {
AppView()
// Use the on-disk repository in the application
.environment(\.playerRepository, .shared)
.playerRepository(.shared)
}
}
}
49 changes: 8 additions & 41 deletions Documentation/MVVMDemo/MVVMDemo/PlayerRepository+SwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,18 @@ private struct PlayerRepositoryKey: EnvironmentKey {
}

extension EnvironmentValues {
var playerRepository: PlayerRepository {
fileprivate(set) var playerRepository: PlayerRepository {
get { self[PlayerRepositoryKey.self] }
set { self[PlayerRepositoryKey.self] = newValue }
}
}

// MARK: - @Query convenience

// Convenience `Query` initializers for requests that feed
// from `PlayerRepository`.
//
// ```swift
// struct MyView {
// // Without convenience initializer: verbose declaration.
// @Query(MyRequest(), in: \.playerRepository) var myValue
//
// // With convenience initializer: implicit database context.
// @Query(MyRequest()) var myValue
// }
//
// private MyRequest: Queryable {
// func publisher(in playerRepository: PlayerRepository) -> ... { }
// }
// ```
//
// When a request has no parameter, use `init(_ request: Request)`. When
// a request has some varying parameters, pick the initializer that fits the
// runtime behavior needed by your application, as described in
// <https://swiftpackageindex.com/groue/grdbquery/documentation/grdbquery/queryableparameters>.
extension Query where Request.DatabaseContext == PlayerRepository {
/// Creates a `Query`, given an initial `Queryable` request that
/// feeds from `PlayerRepository`.
init(_ request: Request) {
self.init(request, in: \.playerRepository)
}

/// Creates a `Query`, given a SwiftUI binding to a `Queryable`
/// request that feeds from `PlayerRepository`.
init(_ request: Binding<Request>) {
self.init(request, in: \.playerRepository)
}

/// Creates a `Query`, given a `Queryable` request that feeds
/// from `PlayerRepository`.
init(constant request: Request) {
self.init(constant:request, in: \.playerRepository)
extension View {
/// Sets both the `playerRepository` (for writes) and `databaseContext`
/// (for `@Query`) environment values.
func playerRepository(_ repository: PlayerRepository) -> some View {
self
.environment(\.playerRepository, repository)
.databaseContext(.readOnly { repository.reader })
}
}
15 changes: 8 additions & 7 deletions Documentation/MVVMDemo/MVVMDemo/Views/AppView/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ struct AppView: View {
}
}

struct AppView_Previews: PreviewProvider {
static var previews: some View {
AppView().environment(\.playerRepository, .empty())
.previewDisplayName("Database Initially Empty")
AppView().environment(\.playerRepository, .populated())
.previewDisplayName("Database Initially Populated")
}
// MARK: - Previews

#Preview("Database Initially Empty") {
AppView().playerRepository(.empty())
}

#Preview("Database Initially Populated") {
AppView().playerRepository(.populated())
}
Loading