QuerySideEffect demo

This commit is contained in:
Gwendal Roué committed 2021-11-24 09:40:15 +01:00
1 parent 861ca5f022
commit ceed45cf22
21 files changed
+1411 -19

No files matched your search

@@ -78,10 +78,8 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -89,7 +87,7 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -97,10 +95,8 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -108,16 +104,7 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
@@ -0,0 +1,709 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
56519D83274CCD1800ED16D8 /* InformationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D82274CCD1800ED16D8 /* InformationStyle.swift */; };
56519D92274D611F00ED16D8 /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D91274D611F00ED16D8 /* PlayerView.swift */; };
56519D94274D623700ED16D8 /* PlayerNotFoundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D93274D623700ED16D8 /* PlayerNotFoundView.swift */; };
56519D96274D629600ED16D8 /* PlayerFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D95274D629600ED16D8 /* PlayerFormView.swift */; };
56519D98274D64C900ED16D8 /* PlayerPresenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D97274D64C900ED16D8 /* PlayerPresenceView.swift */; };
56519D9D274E1BF100ED16D8 /* PlayerRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D9C274E1BF100ED16D8 /* PlayerRequest.swift */; };
56519D9F274E1C1A00ED16D8 /* PlayerPresenceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56519D9E274E1C1A00ED16D8 /* PlayerPresenceRequest.swift */; };
56F8A189273802970011ACBE /* QuerySideEffectsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A188273802970011ACBE /* QuerySideEffectsApp.swift */; };
56F8A18B273802970011ACBE /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A18A273802970011ACBE /* AppView.swift */; };
56F8A18D273802980011ACBE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 56F8A18C273802980011ACBE /* Assets.xcassets */; };
56F8A190273802980011ACBE /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 56F8A18F273802980011ACBE /* Preview Assets.xcassets */; };
56F8A19A273802980011ACBE /* QuerySideEffectsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A199273802980011ACBE /* QuerySideEffectsTests.swift */; };
56F8A1A4273802980011ACBE /* QuerySideEffectsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A1A3273802980011ACBE /* QuerySideEffectsUITests.swift */; };
56F8A1A6273802980011ACBE /* QuerySideEffectsUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A1A5273802980011ACBE /* QuerySideEffectsUITestsLaunchTests.swift */; };
56F8A1BA273803BB0011ACBE /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 56F8A1B9273803BB0011ACBE /* GRDB */; };
56F8A1BC273803BB0011ACBE /* Query in Frameworks */ = {isa = PBXBuildFile; productRef = 56F8A1BB273803BB0011ACBE /* Query */; };
56F8A1BE273803E90011ACBE /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F8A1BD273803E90011ACBE /* Player.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
56F8A196273802980011ACBE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56F8A17D273802970011ACBE /* Project object */;
proxyType = 1;
remoteGlobalIDString = 56F8A184273802970011ACBE;
remoteInfo = QuerySideEffects;
};
56F8A1A0273802980011ACBE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56F8A17D273802970011ACBE /* Project object */;
proxyType = 1;
remoteGlobalIDString = 56F8A184273802970011ACBE;
remoteInfo = QuerySideEffects;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
56519D82274CCD1800ED16D8 /* InformationStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationStyle.swift; sourceTree = "<group>"; };
56519D91274D611F00ED16D8 /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
56519D93274D623700ED16D8 /* PlayerNotFoundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerNotFoundView.swift; sourceTree = "<group>"; };
56519D95274D629600ED16D8 /* PlayerFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerFormView.swift; sourceTree = "<group>"; };
56519D97274D64C900ED16D8 /* PlayerPresenceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerPresenceView.swift; sourceTree = "<group>"; };
56519D9C274E1BF100ED16D8 /* PlayerRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRequest.swift; sourceTree = "<group>"; };
56519D9E274E1C1A00ED16D8 /* PlayerPresenceRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerPresenceRequest.swift; sourceTree = "<group>"; };
56F8A185273802970011ACBE /* QuerySideEffects.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuerySideEffects.app; sourceTree = BUILT_PRODUCTS_DIR; };
56F8A188273802970011ACBE /* QuerySideEffectsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuerySideEffectsApp.swift; sourceTree = "<group>"; };
56F8A18A273802970011ACBE /* AppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
56F8A18C273802980011ACBE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
56F8A18F273802980011ACBE /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
56F8A195273802980011ACBE /* QuerySideEffectsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuerySideEffectsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56F8A199273802980011ACBE /* QuerySideEffectsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuerySideEffectsTests.swift; sourceTree = "<group>"; };
56F8A19F273802980011ACBE /* QuerySideEffectsUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuerySideEffectsUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56F8A1A3273802980011ACBE /* QuerySideEffectsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuerySideEffectsUITests.swift; sourceTree = "<group>"; };
56F8A1A5273802980011ACBE /* QuerySideEffectsUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuerySideEffectsUITestsLaunchTests.swift; sourceTree = "<group>"; };
56F8A1B2273802A50011ACBE /* GRDB.swift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = GRDB.swift; path = ../../..; sourceTree = "<group>"; };
56F8A1B3273802AB0011ACBE /* Query */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Query; path = ../Query; sourceTree = "<group>"; };
56F8A1BD273803E90011ACBE /* Player.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
56F8A182273802970011ACBE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
56F8A1BA273803BB0011ACBE /* GRDB in Frameworks */,
56F8A1BC273803BB0011ACBE /* Query in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A192273802980011ACBE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A19C273802980011ACBE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
56519D99274E1B9A00ED16D8 /* Views */ = {
isa = PBXGroup;
children = (
56F8A18A273802970011ACBE /* AppView.swift */,
56519D82274CCD1800ED16D8 /* InformationStyle.swift */,
56519D95274D629600ED16D8 /* PlayerFormView.swift */,
56519D93274D623700ED16D8 /* PlayerNotFoundView.swift */,
56519D97274D64C900ED16D8 /* PlayerPresenceView.swift */,
56519D91274D611F00ED16D8 /* PlayerView.swift */,
);
path = Views;
sourceTree = "<group>";
};
56519D9A274E1BCB00ED16D8 /* Models */ = {
isa = PBXGroup;
children = (
56F8A1BD273803E90011ACBE /* Player.swift */,
);
path = Models;
sourceTree = "<group>";
};
56519D9B274E1BDC00ED16D8 /* Requests */ = {
isa = PBXGroup;
children = (
56519D9C274E1BF100ED16D8 /* PlayerRequest.swift */,
56519D9E274E1C1A00ED16D8 /* PlayerPresenceRequest.swift */,
);
path = Requests;
sourceTree = "<group>";
};
56F8A17C273802970011ACBE = {
isa = PBXGroup;
children = (
56F8A1B2273802A50011ACBE /* GRDB.swift */,
56F8A1B3273802AB0011ACBE /* Query */,
56F8A187273802970011ACBE /* QuerySideEffects */,
56F8A198273802980011ACBE /* QuerySideEffectsTests */,
56F8A1A2273802980011ACBE /* QuerySideEffectsUITests */,
56F8A186273802970011ACBE /* Products */,
56F8A1B8273803BB0011ACBE /* Frameworks */,
);
sourceTree = "<group>";
};
56F8A186273802970011ACBE /* Products */ = {
isa = PBXGroup;
children = (
56F8A185273802970011ACBE /* QuerySideEffects.app */,
56F8A195273802980011ACBE /* QuerySideEffectsTests.xctest */,
56F8A19F273802980011ACBE /* QuerySideEffectsUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
56F8A187273802970011ACBE /* QuerySideEffects */ = {
isa = PBXGroup;
children = (
56F8A188273802970011ACBE /* QuerySideEffectsApp.swift */,
56519D99274E1B9A00ED16D8 /* Views */,
56519D9A274E1BCB00ED16D8 /* Models */,
56519D9B274E1BDC00ED16D8 /* Requests */,
56F8A18C273802980011ACBE /* Assets.xcassets */,
56F8A18E273802980011ACBE /* Preview Content */,
);
path = QuerySideEffects;
sourceTree = "<group>";
};
56F8A18E273802980011ACBE /* Preview Content */ = {
isa = PBXGroup;
children = (
56F8A18F273802980011ACBE /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
56F8A198273802980011ACBE /* QuerySideEffectsTests */ = {
isa = PBXGroup;
children = (
56F8A199273802980011ACBE /* QuerySideEffectsTests.swift */,
);
path = QuerySideEffectsTests;
sourceTree = "<group>";
};
56F8A1A2273802980011ACBE /* QuerySideEffectsUITests */ = {
isa = PBXGroup;
children = (
56F8A1A3273802980011ACBE /* QuerySideEffectsUITests.swift */,
56F8A1A5273802980011ACBE /* QuerySideEffectsUITestsLaunchTests.swift */,
);
path = QuerySideEffectsUITests;
sourceTree = "<group>";
};
56F8A1B8273803BB0011ACBE /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
56F8A184273802970011ACBE /* QuerySideEffects */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56F8A1A9273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffects" */;
buildPhases = (
56F8A181273802970011ACBE /* Sources */,
56F8A182273802970011ACBE /* Frameworks */,
56F8A183273802970011ACBE /* Resources */,
);
buildRules = (
);
dependencies = (
56F8A1B5273803B60011ACBE /* PBXTargetDependency */,
56F8A1B7273803B60011ACBE /* PBXTargetDependency */,
);
name = QuerySideEffects;
packageProductDependencies = (
56F8A1B9273803BB0011ACBE /* GRDB */,
56F8A1BB273803BB0011ACBE /* Query */,
);
productName = QuerySideEffects;
productReference = 56F8A185273802970011ACBE /* QuerySideEffects.app */;
productType = "com.apple.product-type.application";
};
56F8A194273802980011ACBE /* QuerySideEffectsTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56F8A1AC273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffectsTests" */;
buildPhases = (
56F8A191273802980011ACBE /* Sources */,
56F8A192273802980011ACBE /* Frameworks */,
56F8A193273802980011ACBE /* Resources */,
);
buildRules = (
);
dependencies = (
56F8A197273802980011ACBE /* PBXTargetDependency */,
);
name = QuerySideEffectsTests;
productName = QuerySideEffectsTests;
productReference = 56F8A195273802980011ACBE /* QuerySideEffectsTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
56F8A19E273802980011ACBE /* QuerySideEffectsUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56F8A1AF273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffectsUITests" */;
buildPhases = (
56F8A19B273802980011ACBE /* Sources */,
56F8A19C273802980011ACBE /* Frameworks */,
56F8A19D273802980011ACBE /* Resources */,
);
buildRules = (
);
dependencies = (
56F8A1A1273802980011ACBE /* PBXTargetDependency */,
);
name = QuerySideEffectsUITests;
productName = QuerySideEffectsUITests;
productReference = 56F8A19F273802980011ACBE /* QuerySideEffectsUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
56F8A17D273802970011ACBE /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1310;
LastUpgradeCheck = 1310;
TargetAttributes = {
56F8A184273802970011ACBE = {
CreatedOnToolsVersion = 13.1;
};
56F8A194273802980011ACBE = {
CreatedOnToolsVersion = 13.1;
TestTargetID = 56F8A184273802970011ACBE;
};
56F8A19E273802980011ACBE = {
CreatedOnToolsVersion = 13.1;
TestTargetID = 56F8A184273802970011ACBE;
};
};
};
buildConfigurationList = 56F8A180273802970011ACBE /* Build configuration list for PBXProject "QuerySideEffects" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 56F8A17C273802970011ACBE;
productRefGroup = 56F8A186273802970011ACBE /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
56F8A184273802970011ACBE /* QuerySideEffects */,
56F8A194273802980011ACBE /* QuerySideEffectsTests */,
56F8A19E273802980011ACBE /* QuerySideEffectsUITests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
56F8A183273802970011ACBE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56F8A190273802980011ACBE /* Preview Assets.xcassets in Resources */,
56F8A18D273802980011ACBE /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A193273802980011ACBE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A19D273802980011ACBE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
56F8A181273802970011ACBE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56F8A18B273802970011ACBE /* AppView.swift in Sources */,
56519D83274CCD1800ED16D8 /* InformationStyle.swift in Sources */,
56519D96274D629600ED16D8 /* PlayerFormView.swift in Sources */,
56519D9F274E1C1A00ED16D8 /* PlayerPresenceRequest.swift in Sources */,
56519D94274D623700ED16D8 /* PlayerNotFoundView.swift in Sources */,
56519D9D274E1BF100ED16D8 /* PlayerRequest.swift in Sources */,
56519D92274D611F00ED16D8 /* PlayerView.swift in Sources */,
56F8A1BE273803E90011ACBE /* Player.swift in Sources */,
56F8A189273802970011ACBE /* QuerySideEffectsApp.swift in Sources */,
56519D98274D64C900ED16D8 /* PlayerPresenceView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A191273802980011ACBE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56F8A19A273802980011ACBE /* QuerySideEffectsTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56F8A19B273802980011ACBE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56F8A1A4273802980011ACBE /* QuerySideEffectsUITests.swift in Sources */,
56F8A1A6273802980011ACBE /* QuerySideEffectsUITestsLaunchTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
56F8A197273802980011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 56F8A184273802970011ACBE /* QuerySideEffects */;
targetProxy = 56F8A196273802980011ACBE /* PBXContainerItemProxy */;
};
56F8A1A1273802980011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 56F8A184273802970011ACBE /* QuerySideEffects */;
targetProxy = 56F8A1A0273802980011ACBE /* PBXContainerItemProxy */;
};
56F8A1B5273803B60011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 56F8A1B4273803B60011ACBE /* GRDB */;
};
56F8A1B7273803B60011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 56F8A1B6273803B60011ACBE /* Query */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
56F8A1A7273802980011ACBE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
56F8A1A8273802980011ACBE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
56F8A1AA273802980011ACBE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"QuerySideEffects/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffects;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
56F8A1AB273802980011ACBE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"QuerySideEffects/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffects;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
56F8A1AD273802980011ACBE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffectsTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuerySideEffects.app/QuerySideEffects";
};
name = Debug;
};
56F8A1AE273802980011ACBE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffectsTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QuerySideEffects.app/QuerySideEffects";
};
name = Release;
};
56F8A1B0273802980011ACBE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffectsUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = QuerySideEffects;
};
name = Debug;
};
56F8A1B1273802980011ACBE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.QuerySideEffectsUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = QuerySideEffects;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56F8A180273802970011ACBE /* Build configuration list for PBXProject "QuerySideEffects" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56F8A1A7273802980011ACBE /* Debug */,
56F8A1A8273802980011ACBE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
56F8A1A9273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffects" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56F8A1AA273802980011ACBE /* Debug */,
56F8A1AB273802980011ACBE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
56F8A1AC273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffectsTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56F8A1AD273802980011ACBE /* Debug */,
56F8A1AE273802980011ACBE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
56F8A1AF273802980011ACBE /* Build configuration list for PBXNativeTarget "QuerySideEffectsUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56F8A1B0273802980011ACBE /* Debug */,
56F8A1B1273802980011ACBE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCSwiftPackageProductDependency section */
56F8A1B4273803B60011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
56F8A1B6273803B60011ACBE /* Query */ = {
isa = XCSwiftPackageProductDependency;
productName = Query;
};
56F8A1B9273803BB0011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
56F8A1BB273803BB0011ACBE /* Query */ = {
isa = XCSwiftPackageProductDependency;
productName = Query;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 56F8A17D273802970011ACBE /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,35 @@
import GRDB
struct Player: Codable, Identifiable {
var id: Int64?
var name: String
var score: Int
var photoID: Int
}
extension Player {
private static let names = [
"Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David",
"Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette",
"Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl",
"Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole",
"Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul",
"Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain",
"Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann",
"Zazie", "Zoé"]
/// Creates a new player with random name and random score
static func makeRandom() -> Player {
Player(
id: nil,
name: names.randomElement()!,
score: 10 * Int.random(in: 0...100),
photoID: Int.random(in: 0...1000))
}
}
extension Player: FetchableRecord, MutablePersistableRecord {
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,44 @@
import GRDB
import Query
import SwiftUI
@main
struct QuerySideEffectsApp: App {
var body: some Scene {
WindowGroup {
AppView()
}
}
}
let demoDatabaseQueue: DatabaseQueue = {
let dbQueue = DatabaseQueue()
try! dbQueue.write { db in
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
t.column("photoID", .integer).notNull()
}
// insert a random player (and ignore generated id)
_ = try Player.makeRandom().inserted(db)
}
return dbQueue
}()
private struct DatabaseQueueKey: EnvironmentKey {
static var defaultValue: DatabaseQueue { demoDatabaseQueue }
}
extension EnvironmentValues {
var dbQueue: DatabaseQueue {
get { self[DatabaseQueueKey.self] }
set { self[DatabaseQueueKey.self] = newValue }
}
}
extension Query where QueryableType.DatabaseContext == DatabaseQueue {
init(_ query: QueryableType) {
self.init(query, in: \.dbQueue)
}
}
@@ -0,0 +1,54 @@
import Combine
import GRDB
import Query
struct PlayerPresenceRequest: Queryable {
static var defaultValue: PlayerPresence { .missing }
var id: Int64
func publisher(in dbQueue: DatabaseQueue) -> AnyPublisher<PlayerPresence, Error> {
ValueObservation
.tracking(Player.filter(id: id).fetchOne)
.publisher(in: dbQueue, scheduling: .immediate)
.scan(.missing) { (previous, player) in
if let player = player {
return .existing(player)
} else if let player = previous.player {
return .gone(player)
} else {
return .missing
}
}
.eraseToAnyPublisher()
}
}
enum PlayerPresence {
/// The player exists in the database
case existing(Player)
/// Player no longer exists, but we have its latest value.
case gone(Player)
/// Player does not exist, and we don't have any information about it.
case missing
var player: Player? {
switch self {
case let .existing(player), let .gone(player):
return player
case .missing:
return nil
}
}
var exists: Bool {
switch self {
case .existing:
return true
case .gone, .missing:
return false
}
}
}
@@ -0,0 +1,12 @@
import Query
import GRDB
struct PlayerRequest: Queryable {
static var defaultValue: Player? { nil }
func publisher(in dbQueue: DatabaseQueue) -> DatabasePublishers.Value<Player?> {
ValueObservation
.tracking(Player.fetchOne)
.publisher(in: dbQueue, scheduling: .immediate)
}
}
@@ -0,0 +1,90 @@
import Query
import SwiftUI
import GRDB
struct AppView: View {
/// A helper `Identifiable` type that can feed SwiftUI `sheet(item:onDismiss:content:)`
private struct EditedPlayer: Identifiable {
var id: Int64
}
@Environment(\.dbQueue) private var dbQueue
@Query(PlayerRequest()) private var player
@State private var editedPlayer: EditedPlayer?
var body: some View {
VStack {
informationHeader(playerExists: player != nil)
Spacer()
if let player = player, let id = player.id {
PlayerView(player: player, edit: {
editPlayer(id: id)
})
Spacer()
informationFooter(id: id)
} else {
Text("The database contains no player.")
Spacer()
}
}
.padding(.horizontal)
.sheet(item: $editedPlayer) { player in
PlayerPresenceView(id: player.id)
}
}
private func informationHeader(playerExists: Bool) -> some View {
VStack {
Text("The application observes the database and displays information about the player.")
.informationStyle()
if !playerExists {
Button("Create a Player") {
try! dbQueue.write { db in
_ = try Player.makeRandom().inserted(db)
}
}
}
}
.informationBox()
}
private func informationFooter(id: Int64) -> some View {
VStack(spacing: 10) {
Text("**What if another application component deletes the player at the most unexpected moment?**")
.informationStyle()
Button("Delete Player") {
_ = try! dbQueue.write(Player.deleteAll)
}
Spacer().frame(height: 10)
Text("What if the player is deleted soon after the Edit button is hit?")
.informationStyle()
Button("Edit Player Then Delete") {
editPlayer(id: id)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
_ = try! dbQueue.write(Player.deleteAll)
}
}
Spacer().frame(height: 10)
Text("What if the player is deleted right before the Edit button is hit?")
.informationStyle()
Button("Delete Then Edit Player") {
_ = try! dbQueue.write(Player.deleteAll)
editPlayer(id: id)
}
}
.informationBox()
}
private func editPlayer(id: Int64) {
editedPlayer = EditedPlayer(id: id)
}
}
struct AppView_Previews: PreviewProvider {
static var previews: some View {
AppView()
}
}
@@ -0,0 +1,48 @@
import SwiftUI
/// The style for information text
struct InformationStyle: ViewModifier {
func body(content: Content) -> some View {
content
.frame(maxWidth: .infinity, alignment: .leading)
.foregroundColor(Color(uiColor: UIColor.secondaryLabel))
.font(.callout)
}
}
/// The style for information boxes
struct InformationBox: ViewModifier {
func body(content: Content) -> some View {
content
.padding()
.frame(maxWidth: .infinity, alignment: .center)
.background(Color(UIColor.secondarySystemBackground))
.buttonStyle(.borderedProminent)
.tint(.purple)
.cornerRadius(10)
}
}
extension View {
func informationStyle() -> some View {
modifier(InformationStyle())
}
func informationBox() -> some View {
modifier(InformationBox())
}
}
struct Information_Previews: PreviewProvider {
static var previews: some View {
VStack {
Text("Info 1")
.informationStyle()
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque et.")
.informationStyle()
Button("OK") { }
}
.informationBox()
.padding()
}
}
@@ -0,0 +1,40 @@
import GRDB
import SwiftUI
struct PlayerFormView: View {
@Environment(\.dbQueue) var dbQueue
var player: Player
var body: some View {
Stepper(
"Score: \(player.score)",
onIncrement: {
modifyPlayer { $0.score += 10 }
},
onDecrement: {
modifyPlayer { $0.score = max(0, $0.score - 10) }
})
}
private func modifyPlayer(_ transform: (inout Player) -> Void) {
do {
_ = try dbQueue.write { db in
var player = player
try player.updateChanges(db, with: transform)
}
} catch PersistenceError.recordNotFound {
// Oops, player no longer exists.
// Ignore this error: it is handled in PlayerPresenceView.
} catch {
fatalError("\(error)")
}
}
}
struct PlayerFormView_Previews: PreviewProvider {
static var previews: some View {
PlayerFormView(player: .makeRandom())
.padding()
}
}
@@ -0,0 +1,23 @@
import SwiftUI
struct PlayerNotFoundView: View {
var body: some View {
ZStack {
Color(UIColor.systemGroupedBackground).ignoresSafeArea()
VStack {
Spacer()
Text("404").font(Font.system(size: 64)).fontWeight(.heavy)
Text("😵").font(Font.system(size: 100))
Spacer()
Spacer()
Spacer()
}.padding()
}
}
}
struct PlayerNotFoundView_Previews: PreviewProvider {
static var previews: some View {
PlayerNotFoundView()
}
}
@@ -0,0 +1,71 @@
import GRDB
import Query
import SwiftUI
struct PlayerPresenceView: View {
@Environment(\.dbQueue) private var dbQueue
@Environment(\.dismiss) private var dismiss
@Query<PlayerPresenceRequest> private var playerPresence: PlayerPresence
@State var gonePlayerAlertPresented = false
init(id: Int64) {
_playerPresence = Query(PlayerPresenceRequest(id: id))
}
var body: some View {
NavigationView {
if let player = playerPresence.player {
VStack {
PlayerFormView(player: player)
Spacer()
if playerPresence.exists {
VStack(spacing: 10) {
Text("**What if another application component deletes the player at the most unexpected moment?**")
.informationStyle()
Button("Delete Player") {
_ = try! dbQueue.write(Player.deleteAll)
}
}
.informationBox()
}
}
.padding(.horizontal)
.navigationTitle(player.name)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("Done") { dismiss() }
}
}
} else {
PlayerNotFoundView()
}
}
.alert("Ooops, player is gone.", isPresented: $gonePlayerAlertPresented, actions: {
Button("OK") { dismiss() }
})
.onAppear {
if !playerPresence.exists {
gonePlayerAlertPresented = true
}
}
.onChange(of: playerPresence.exists, perform: { playerExists in
if !playerExists {
gonePlayerAlertPresented = true
}
})
}
}
struct PlayerPresenceView_Previews_Existing: PreviewProvider {
static var previews: some View {
PlayerPresenceView(id: 1)
}
}
struct PlayerPresenceView_Previews_Missing: PreviewProvider {
static var previews: some View {
PlayerPresenceView(id: -1)
}
}
@@ -0,0 +1,36 @@
import SwiftUI
struct PlayerView: View {
var player: Player
var edit: () -> Void
var body: some View {
HStack {
AsyncImage(
url: URL(string: "https://picsum.photos/seed/\(player.photoID)/200"),
content: { image in
image.resizable()
},
placeholder: {
ProgressView()
})
.frame(width: 70, height: 70)
.cornerRadius(10)
VStack(alignment: .leading) {
Text(player.name).bold()
Text("Score: \(player.score)")
}
.padding(.vertical, 10)
Spacer()
Button("Edit", action: edit)
.buttonStyle(.borderedProminent)
}
}
}
struct PlayerView_Previews: PreviewProvider {
static var previews: some View {
PlayerView(player: .makeRandom(), edit: { })
.padding()
}
}
@@ -0,0 +1,33 @@
//
// QuerySideEffectsTests.swift
// QuerySideEffectsTests
//
// Created by Gwendal Roué on 07/11/2021.
//
import XCTest
@testable import QuerySideEffects
class QuerySideEffectsTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
@@ -0,0 +1,42 @@
//
// QuerySideEffectsUITests.swift
// QuerySideEffectsUITests
//
// Created by Gwendal Roué on 07/11/2021.
//
import XCTest
class QuerySideEffectsUITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
}
@@ -0,0 +1,32 @@
//
// QuerySideEffectsUITestsLaunchTests.swift
// QuerySideEffectsUITests
//
// Created by Gwendal Roué on 07/11/2021.
//
import XCTest
class QuerySideEffectsUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
override func setUpWithError() throws {
continueAfterFailure = false
}
func testLaunch() throws {
let app = XCUIApplication()
app.launch()
// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}