diff --git a/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.pbxproj b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.pbxproj new file mode 100644 index 00000000..d318ce1e --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.pbxproj @@ -0,0 +1,505 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 2AA20D9326A0BC4800C2E123 /* RefreshableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA20D9226A0BC4800C2E123 /* RefreshableTests.swift */; }; + 2AC9838926A0ABFF00A5812A /* Refreshable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC9838826A0ABFE00A5812A /* Refreshable.swift */; }; + 4BD5EB2726A0C24700CC723B /* ComposableRefreshable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5EB2626A0C24700CC723B /* ComposableRefreshable.swift */; }; + CA5ECF92267A79F0002067FF /* FactClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5ECF91267A79F0002067FF /* FactClient.swift */; }; + DC89C41924460F95006900B9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC89C41824460F95006900B9 /* SceneDelegate.swift */; }; + DC89C41D24460F96006900B9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC89C41C24460F96006900B9 /* Assets.xcassets */; }; + DCD2EDA626A73D5500D4A55A /* ComposableArchitecture in Frameworks */ = {isa = PBXBuildFile; productRef = DCD2EDA526A73D5500D4A55A /* ComposableArchitecture */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + DC89C42A24460F96006900B9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DC89C40B24460F95006900B9 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DC89C41224460F95006900B9; + remoteInfo = CaseStudies; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + DC89C43D2446106D006900B9 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + DC89C44124461077006900B9 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2AA20D9226A0BC4800C2E123 /* RefreshableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshableTests.swift; sourceTree = ""; }; + 2AC9838826A0ABFE00A5812A /* Refreshable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Refreshable.swift; sourceTree = ""; }; + 4BD5EB2626A0C24700CC723B /* ComposableRefreshable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposableRefreshable.swift; sourceTree = ""; }; + CA5ECF91267A79F0002067FF /* FactClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FactClient.swift; sourceTree = ""; }; + DC89C41324460F95006900B9 /* SwiftUICaseStudies.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUICaseStudies.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DC89C41824460F95006900B9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + DC89C41C24460F96006900B9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + DC89C42424460F96006900B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DC89C42924460F96006900B9 /* SwiftUICaseStudiesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftUICaseStudiesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + DC89C41024460F95006900B9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DCD2EDA626A73D5500D4A55A /* ComposableArchitecture in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DC89C42624460F96006900B9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + DC89C40A24460F95006900B9 = { + isa = PBXGroup; + children = ( + DC89C43A2446106D006900B9 /* Frameworks */, + DC89C41424460F95006900B9 /* Products */, + DC89C41524460F95006900B9 /* SwiftUICaseStudies */, + DC89C42C24460F96006900B9 /* SwiftUICaseStudiesTests */, + ); + sourceTree = ""; + }; + DC89C41424460F95006900B9 /* Products */ = { + isa = PBXGroup; + children = ( + DC89C41324460F95006900B9 /* SwiftUICaseStudies.app */, + DC89C42924460F96006900B9 /* SwiftUICaseStudiesTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + DC89C41524460F95006900B9 /* SwiftUICaseStudies */ = { + isa = PBXGroup; + children = ( + DC89C42424460F96006900B9 /* Info.plist */, + CA5ECF91267A79F0002067FF /* FactClient.swift */, + DC89C41824460F95006900B9 /* SceneDelegate.swift */, + DC89C41C24460F96006900B9 /* Assets.xcassets */, + 2AC9838826A0ABFE00A5812A /* Refreshable.swift */, + 4BD5EB2626A0C24700CC723B /* ComposableRefreshable.swift */, + ); + path = SwiftUICaseStudies; + sourceTree = ""; + }; + DC89C42C24460F96006900B9 /* SwiftUICaseStudiesTests */ = { + isa = PBXGroup; + children = ( + 2AA20D9226A0BC4800C2E123 /* RefreshableTests.swift */, + ); + path = SwiftUICaseStudiesTests; + sourceTree = ""; + }; + DC89C43A2446106D006900B9 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + DC89C41224460F95006900B9 /* SwiftUICaseStudies */ = { + isa = PBXNativeTarget; + buildConfigurationList = DC89C43224460F96006900B9 /* Build configuration list for PBXNativeTarget "SwiftUICaseStudies" */; + buildPhases = ( + DC89C40F24460F95006900B9 /* Sources */, + DC89C41024460F95006900B9 /* Frameworks */, + DC89C41124460F95006900B9 /* Resources */, + DC89C43D2446106D006900B9 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftUICaseStudies; + packageProductDependencies = ( + DCD2EDA526A73D5500D4A55A /* ComposableArchitecture */, + ); + productName = CaseStudies; + productReference = DC89C41324460F95006900B9 /* SwiftUICaseStudies.app */; + productType = "com.apple.product-type.application"; + }; + DC89C42824460F96006900B9 /* SwiftUICaseStudiesTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = DC89C43524460F96006900B9 /* Build configuration list for PBXNativeTarget "SwiftUICaseStudiesTests" */; + buildPhases = ( + DC89C42524460F96006900B9 /* Sources */, + DC89C42624460F96006900B9 /* Frameworks */, + DC89C42724460F96006900B9 /* Resources */, + DC89C44124461077006900B9 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + DC89C42B24460F96006900B9 /* PBXTargetDependency */, + ); + name = SwiftUICaseStudiesTests; + packageProductDependencies = ( + ); + productName = CaseStudiesTests; + productReference = DC89C42924460F96006900B9 /* SwiftUICaseStudiesTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + DC89C40B24460F95006900B9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1150; + LastUpgradeCheck = 1240; + ORGANIZATIONNAME = "Point-Free"; + TargetAttributes = { + DC89C41224460F95006900B9 = { + CreatedOnToolsVersion = 11.4; + }; + DC89C42824460F96006900B9 = { + CreatedOnToolsVersion = 11.4; + TestTargetID = DC89C41224460F95006900B9; + }; + }; + }; + buildConfigurationList = DC89C40E24460F95006900B9 /* Build configuration list for PBXProject "CaseStudies" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = DC89C40A24460F95006900B9; + packageReferences = ( + DCD2EDA426A73D5500D4A55A /* XCRemoteSwiftPackageReference "swift-composable-architecture" */, + ); + productRefGroup = DC89C41424460F95006900B9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + DC89C41224460F95006900B9 /* SwiftUICaseStudies */, + DC89C42824460F96006900B9 /* SwiftUICaseStudiesTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + DC89C41124460F95006900B9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DC89C41D24460F96006900B9 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DC89C42724460F96006900B9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + DC89C40F24460F95006900B9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CA5ECF92267A79F0002067FF /* FactClient.swift in Sources */, + DC89C41924460F95006900B9 /* SceneDelegate.swift in Sources */, + 4BD5EB2726A0C24700CC723B /* ComposableRefreshable.swift in Sources */, + 2AC9838926A0ABFF00A5812A /* Refreshable.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DC89C42524460F96006900B9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2AA20D9326A0BC4800C2E123 /* RefreshableTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + DC89C42B24460F96006900B9 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DC89C41224460F95006900B9 /* SwiftUICaseStudies */; + targetProxy = DC89C42A24460F96006900B9 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + DC89C43024460F96006900B9 /* 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++14"; + 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; + 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; + }; + DC89C43124460F96006900B9 /* 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++14"; + 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; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + DC89C43324460F96006900B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = SwiftUICaseStudies/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + DC89C43424460F96006900B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = SwiftUICaseStudies/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + DC89C43624460F96006900B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies"; + }; + name = Debug; + }; + DC89C43724460F96006900B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + DC89C40E24460F95006900B9 /* Build configuration list for PBXProject "CaseStudies" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DC89C43024460F96006900B9 /* Debug */, + DC89C43124460F96006900B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + DC89C43224460F96006900B9 /* Build configuration list for PBXNativeTarget "SwiftUICaseStudies" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DC89C43324460F96006900B9 /* Debug */, + DC89C43424460F96006900B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + DC89C43524460F96006900B9 /* Build configuration list for PBXNativeTarget "SwiftUICaseStudiesTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DC89C43624460F96006900B9 /* Debug */, + DC89C43724460F96006900B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + DCD2EDA426A73D5500D4A55A /* XCRemoteSwiftPackageReference "swift-composable-architecture" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/pointfreeco/swift-composable-architecture.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.21.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + DCD2EDA526A73D5500D4A55A /* ComposableArchitecture */ = { + isa = XCSwiftPackageProductDependency; + package = DCD2EDA426A73D5500D4A55A /* XCRemoteSwiftPackageReference "swift-composable-architecture" */; + productName = ComposableArchitecture; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = DC89C40B24460F95006900B9 /* Project object */; +} diff --git a/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/xcshareddata/xcschemes/CaseStudies (SwiftUI).xcscheme b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/xcshareddata/xcschemes/CaseStudies (SwiftUI).xcscheme new file mode 100644 index 00000000..7cd4593a --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/CaseStudies.xcodeproj/xcshareddata/xcschemes/CaseStudies (SwiftUI).xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/AppIcon.png b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/AppIcon.png new file mode 100644 index 00000000..186b90e3 Binary files /dev/null and b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/AppIcon.png differ diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/Contents.json b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..e4b96da0 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,99 @@ +{ + "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" + }, + { + "filename" : "AppIcon.png", + "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 + } +} diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/Contents.json b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/ComposableRefreshable.swift b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/ComposableRefreshable.swift new file mode 100644 index 00000000..9d3eabff --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/ComposableRefreshable.swift @@ -0,0 +1,128 @@ +import Combine +import ComposableArchitecture +import SwiftUI + +struct PullToRefreshState: Equatable { + var count = 0 + var fact: String? + var isLoading = false +} + +enum PullToRefreshAction: Equatable { + case cancelButtonTapped + case factResponse(Result) + case decrementButtonTapped + case incrementButtonTapped + case refresh +} + +struct PullToRefreshEnvironment { + var fact: FactClient + var mainQueue: AnySchedulerOf +} + +let pullToRefreshReducer = Reducer< + PullToRefreshState, + PullToRefreshAction, + PullToRefreshEnvironment +> { state, action, environment in + + struct CancelId: Hashable {} + + switch action { + case .cancelButtonTapped: + state.isLoading = false + return .cancel(id: CancelId()) + + case let .factResponse(.success(fact)): + state.isLoading = false + state.fact = fact + return .none + + case .factResponse(.failure): + state.isLoading = false + // TODO: do some error handling + return .none + + case .decrementButtonTapped: + state.count -= 1 + return .none + + case .incrementButtonTapped: + state.count += 1 + return .none + + case .refresh: + state.fact = nil + state.isLoading = true + return environment.fact.fetch(state.count) +// .receive(on: environment.mainQueue) + .delay(for: 2, scheduler: environment.mainQueue.animation()) + .catchToEffect() + .map(PullToRefreshAction.factResponse) + .cancellable(id: CancelId()) + } +} + +struct PullToRefreshView: View { + let store: Store + + var body: some View { + WithViewStore(self.store) { viewStore in + List { + HStack { + Button("-") { viewStore.send(.decrementButtonTapped) } + Text("\(viewStore.count)") + Button("+") { viewStore.send(.incrementButtonTapped) } + } + .buttonStyle(.plain) + + if let fact = viewStore.fact { + Text(fact) + } + if viewStore.isLoading { + Button("Cancel") { + viewStore.send(.cancelButtonTapped, animation: .default) + } + } + } + .refreshable { + await viewStore.send(.refresh, while: \.isLoading) + } + } + } +} + +extension ViewStore { + func send( + _ action: Action, + while predicate: @escaping (State) -> Bool + ) async { + self.send(action) + await withUnsafeContinuation { (continuation: UnsafeContinuation) in + var cancellable: Cancellable? + cancellable = self.publisher + .filter { !predicate($0) } + .prefix(1) + .sink { _ in + continuation.resume() + _ = cancellable + } + } + } +} + +struct PullToRefresh_Previews: PreviewProvider { + static var previews: some View { + PullToRefreshView( + store: .init( + initialState: .init(), + reducer: pullToRefreshReducer, + environment: PullToRefreshEnvironment( + fact: .live, + mainQueue: .main + ) + ) + ) + } +} diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/FactClient.swift b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/FactClient.swift new file mode 100644 index 00000000..e26ba751 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/FactClient.swift @@ -0,0 +1,42 @@ +import Combine +import ComposableArchitecture +import XCTestDynamicOverlay + +struct FactClient { + var fetch: (Int) -> Effect + + struct Error: Swift.Error, Equatable {} +} + +extension FactClient { + // This is the "live" fact dependency that reaches into the outside world to fetch trivia. + // Typically this live implementation of the dependency would live in its own module so that the + // main feature doesn't need to compile it. + static let live = Self( + fetch: { number in + URLSession.shared.dataTaskPublisher( + for: URL(string: "http://numbersapi.com/\(number)/trivia")! + ) + .map { data, _ in String(decoding: data, as: UTF8.self) } + .catch { _ in + // Sometimes numbersapi.com can be flakey, so if it ever fails we will just + // default to a mock response. + Just("\(number) is a good number Brent") + .delay(for: 1, scheduler: DispatchQueue.main) + } + .setFailureType(to: Error.self) + .eraseToEffect() + }) +} + +#if DEBUG + extension FactClient { + // This is the "failing" fact dependency that is useful to plug into tests that you want + // to prove do not need the dependency. + static let failing = Self( + fetch: { _ in + XCTFail("\(Self.self).fact is unimplemented.") + return .none + }) + } +#endif diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Info.plist b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Info.plist new file mode 100644 index 00000000..162e5aaa --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Info.plist @@ -0,0 +1,65 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UILaunchStoryboardName + LaunchScreen + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Refreshable.swift b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Refreshable.swift new file mode 100644 index 00000000..014fb89f --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/Refreshable.swift @@ -0,0 +1,93 @@ +import SwiftUI + +class PullToRefreshViewModel: ObservableObject { + @Published var count = 0 + @Published var fact: String? = nil + + @Published private var task: Task? + let fetch: (Int) async throws -> String + + init(fetch: @escaping (Int) async throws -> String) { + self.fetch = fetch + } + + var isLoading: Bool { + self.task != nil + } + + func incrementButtonTapped() { + self.count += 1 + } + + func decrementButtonTapped() { + self.count -= 1 + } + + @MainActor + func getFact() async { + self.fact = nil + + self.task = Task { + try await self.fetch(self.count) + } + defer { self.task = nil } + + do { + let fact = try await task?.value + withAnimation { + self.fact = fact + } + + } catch { + // TODO: do some error handling + } + } + + func cancelButtonTapped() { + self.task?.cancel() + self.task = nil + } +} + +struct VanillaPullToRefreshView: View { + @ObservedObject var viewModel: PullToRefreshViewModel + + var body: some View { + List { + HStack { + Button("-") { self.viewModel.decrementButtonTapped() } + Text("\(self.viewModel.count)") + Button("+") { self.viewModel.incrementButtonTapped() } + } + .buttonStyle(.plain) + + if let fact = self.viewModel.fact { + Text(fact) + } + if self.viewModel.isLoading { + Button("Cancel") { + self.viewModel.cancelButtonTapped() + } + } + } + .refreshable { + await self.viewModel.getFact() + } + } +} + +struct VanillaPullToRefreshView_Previews: PreviewProvider { + static var previews: some View { + VanillaPullToRefreshView( + viewModel: .init( + fetch: { count in + await Task.sleep(2 * NSEC_PER_SEC) + + let (data, _) = try await URLSession.shared.data(from: .init(string: "http://numbersapi.com/\(count)/trivia")!) + + return String(decoding: data, as: UTF8.self) + } + ) + ) + } +} diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/SceneDelegate.swift b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/SceneDelegate.swift new file mode 100644 index 00000000..18415c86 --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudies/SceneDelegate.swift @@ -0,0 +1,37 @@ +import SwiftUI +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + var window: UIWindow? + + func scene( + _ scene: UIScene, + willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions + ) { + self.window = (scene as? UIWindowScene).map(UIWindow.init(windowScene:)) + self.window?.rootViewController = UIHostingController( + rootView: PullToRefreshView( + store: .init( + initialState: .init(), + reducer: pullToRefreshReducer, + environment: PullToRefreshEnvironment( + fact: .live, + mainQueue: .main + ) + ) + ) + ) + self.window?.makeKeyAndVisible() + } +} + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + true + } +} diff --git a/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudiesTests/RefreshableTests.swift b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudiesTests/RefreshableTests.swift new file mode 100644 index 00000000..ccc3f21d --- /dev/null +++ b/0154-refreshable-pt2/CaseStudies/SwiftUICaseStudiesTests/RefreshableTests.swift @@ -0,0 +1,71 @@ +import ComposableArchitecture +@testable import SwiftUICaseStudies +import XCTest + +class RefreshableTests: XCTestCase { + func testTca() { + let store = TestStore( + initialState: .init(), + reducer: pullToRefreshReducer, + environment: .init( + fact: .init(fetch: { .init(value: "\($0) is a good number.") }), + mainQueue: .immediate + ) + ) + + store.send(.incrementButtonTapped) { + $0.count = 1 + } + store.send(.refresh) { + $0.isLoading = true + } + store.receive(.factResponse(.success("1 is a good number."))) { + $0.isLoading = false + $0.fact = "1 is a good number." + } + } + + func testTca_Cancellation() { + let mainQueue = DispatchQueue.test + let store = TestStore( + initialState: .init(), + reducer: pullToRefreshReducer, + environment: .init( + fact: .init(fetch: { .init(value: "\($0) is a good number.") }), + mainQueue: mainQueue.eraseToAnyScheduler() + ) + ) + + store.send(.incrementButtonTapped) { + $0.count = 1 + } + store.send(.refresh) { + $0.isLoading = true + } + store.send(.cancelButtonTapped) { + $0.isLoading = false + } + } + + func testVanilla() async { + let viewModel = PullToRefreshViewModel( + fetch: { count in + await Task.sleep(20_000_000) + return "\(count) is a good number." + } + ) + + viewModel.incrementButtonTapped() + XCTAssertEqual(viewModel.count, 1) + + XCTAssertEqual(viewModel.isLoading, false) + let task = Task { + await viewModel.getFact() + } + await Task.sleep(10_000_000) + XCTAssertEqual(viewModel.isLoading, true) + await task.value + XCTAssertEqual(viewModel.fact, "1 is a good number.") + XCTAssertEqual(viewModel.isLoading, false) + } +}