diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index e5f6cd00..4d46ece9 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -50,9 +50,9 @@ jobs: needs: cancel_previous runs-on: macos-11 steps: - - uses: maxim-lobanov/setup-xcode@v1 + - uses: maxim-lobanov/setup-xcode@v1.5.1 with: - xcode-version: '13.2.1' + xcode-version: latest-stable - uses: actions/checkout@v2 - uses: actions/cache@v2 with: @@ -108,9 +108,9 @@ jobs: needs: cancel_previous runs-on: macos-11 steps: - - uses: maxim-lobanov/setup-xcode@v1 + - uses: maxim-lobanov/setup-xcode@v1.5.1 with: - xcode-version: '13.2.1' + xcode-version: latest-stable - uses: actions/checkout@v2 - uses: actions/cache@v2 with: @@ -133,6 +133,10 @@ jobs: run: | cd Examples/apps/SegmentUIKitExample xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -sdk iphonesimulator + - name: build for ios simulator + run: | + cd Examples/apps/SegmentWeatherWidget + xcodebuild -workspace "SegmentWeatherWidget.xcworkspace" -scheme "SegmentWeatherWidget" -sdk iphonesimulator - name: build for mac catalyst run: | cd Examples/apps/SegmentUIKitExample diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.pbxproj b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.pbxproj new file mode 100644 index 00000000..e22ab34e --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.pbxproj @@ -0,0 +1,599 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 82C21C9E2913169C00121B41 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 82C21C9D2913169C00121B41 /* Segment */; }; + 82C21CA0291316B500121B41 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 82C21C9F291316B500121B41 /* Segment */; }; + 82E374D22909C8D1002CFC26 /* SegmentWeatherWidgetApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374D12909C8D1002CFC26 /* SegmentWeatherWidgetApp.swift */; }; + 82E374D42909C8D1002CFC26 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374D32909C8D1002CFC26 /* ContentView.swift */; }; + 82E374D62909C8D3002CFC26 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82E374D52909C8D3002CFC26 /* Assets.xcassets */; }; + 82E374D92909C8D3002CFC26 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82E374D82909C8D3002CFC26 /* Preview Assets.xcassets */; }; + 82E374E62909C908002CFC26 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82E374E52909C908002CFC26 /* WidgetKit.framework */; }; + 82E374E82909C908002CFC26 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82E374E72909C908002CFC26 /* SwiftUI.framework */; }; + 82E374EB2909C908002CFC26 /* WeatherWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374EA2909C908002CFC26 /* WeatherWidget.swift */; }; + 82E374EE2909C90B002CFC26 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82E374ED2909C90B002CFC26 /* Assets.xcassets */; }; + 82E374F02909C90B002CFC26 /* WeatherWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 82E374EC2909C908002CFC26 /* WeatherWidget.intentdefinition */; }; + 82E374F12909C90B002CFC26 /* WeatherWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 82E374EC2909C908002CFC26 /* WeatherWidget.intentdefinition */; }; + 82E374F42909C90B002CFC26 /* WeatherWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 82E374E32909C908002CFC26 /* WeatherWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 82E375052909C9F2002CFC26 /* WeatherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374FA2909C9F2002CFC26 /* WeatherService.swift */; }; + 82E375062909C9F2002CFC26 /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374FC2909C9F2002CFC26 /* Weather.swift */; }; + 82E375072909C9F2002CFC26 /* WeatherUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374FE2909C9F2002CFC26 /* WeatherUtils.swift */; }; + 82E375082909C9F2002CFC26 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E374FF2909C9F2002CFC26 /* Date+Extensions.swift */; }; + 82E3750C2909C9F2002CFC26 /* WeatherWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E375042909C9F2002CFC26 /* WeatherWidgetView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 82E374F22909C90B002CFC26 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 82E374C62909C8D1002CFC26 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 82E374E22909C908002CFC26; + remoteInfo = WeatherWidgetExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 82E374F82909C90B002CFC26 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 82E374F42909C90B002CFC26 /* WeatherWidgetExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 8207AACA2909CFA2001F69D6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 82E374CE2909C8D1002CFC26 /* SegmentWeatherWidget.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SegmentWeatherWidget.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 82E374D12909C8D1002CFC26 /* SegmentWeatherWidgetApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentWeatherWidgetApp.swift; sourceTree = ""; }; + 82E374D32909C8D1002CFC26 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 82E374D52909C8D3002CFC26 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 82E374D82909C8D3002CFC26 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 82E374E32909C908002CFC26 /* WeatherWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WeatherWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 82E374E52909C908002CFC26 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + 82E374E72909C908002CFC26 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + 82E374EA2909C908002CFC26 /* WeatherWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherWidget.swift; sourceTree = ""; }; + 82E374EC2909C908002CFC26 /* WeatherWidget.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = WeatherWidget.intentdefinition; sourceTree = ""; }; + 82E374ED2909C90B002CFC26 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 82E374EF2909C90B002CFC26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 82E374FA2909C9F2002CFC26 /* WeatherService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherService.swift; sourceTree = ""; }; + 82E374FC2909C9F2002CFC26 /* Weather.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; + 82E374FE2909C9F2002CFC26 /* WeatherUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherUtils.swift; sourceTree = ""; }; + 82E374FF2909C9F2002CFC26 /* Date+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = ""; }; + 82E375042909C9F2002CFC26 /* WeatherWidgetView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherWidgetView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 82E374CB2909C8D1002CFC26 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 82C21C9E2913169C00121B41 /* Segment in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 82E374E02909C908002CFC26 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 82C21CA0291316B500121B41 /* Segment in Frameworks */, + 82E374E82909C908002CFC26 /* SwiftUI.framework in Frameworks */, + 82E374E62909C908002CFC26 /* WidgetKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 82E374C52909C8D1002CFC26 = { + isa = PBXGroup; + children = ( + 82E374D02909C8D1002CFC26 /* SegmentWeatherWidget */, + 82E374E92909C908002CFC26 /* WeatherWidget */, + 82E374E42909C908002CFC26 /* Frameworks */, + 82E374CF2909C8D1002CFC26 /* Products */, + ); + sourceTree = ""; + }; + 82E374CF2909C8D1002CFC26 /* Products */ = { + isa = PBXGroup; + children = ( + 82E374CE2909C8D1002CFC26 /* SegmentWeatherWidget.app */, + 82E374E32909C908002CFC26 /* WeatherWidgetExtension.appex */, + ); + name = Products; + sourceTree = ""; + }; + 82E374D02909C8D1002CFC26 /* SegmentWeatherWidget */ = { + isa = PBXGroup; + children = ( + 8207AACA2909CFA2001F69D6 /* Info.plist */, + 82E374D12909C8D1002CFC26 /* SegmentWeatherWidgetApp.swift */, + 82E374D32909C8D1002CFC26 /* ContentView.swift */, + 82E374D52909C8D3002CFC26 /* Assets.xcassets */, + 82E374D72909C8D3002CFC26 /* Preview Content */, + ); + path = SegmentWeatherWidget; + sourceTree = ""; + }; + 82E374D72909C8D3002CFC26 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 82E374D82909C8D3002CFC26 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 82E374E42909C908002CFC26 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 82E374E52909C908002CFC26 /* WidgetKit.framework */, + 82E374E72909C908002CFC26 /* SwiftUI.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 82E374E92909C908002CFC26 /* WeatherWidget */ = { + isa = PBXGroup; + children = ( + 82E374FB2909C9F2002CFC26 /* Models */, + 82E374F92909C9F2002CFC26 /* Service */, + 82E374FD2909C9F2002CFC26 /* Utils */, + 82E374EA2909C908002CFC26 /* WeatherWidget.swift */, + 82E375042909C9F2002CFC26 /* WeatherWidgetView.swift */, + 82E374EC2909C908002CFC26 /* WeatherWidget.intentdefinition */, + 82E374ED2909C90B002CFC26 /* Assets.xcassets */, + 82E374EF2909C90B002CFC26 /* Info.plist */, + ); + path = WeatherWidget; + sourceTree = ""; + }; + 82E374F92909C9F2002CFC26 /* Service */ = { + isa = PBXGroup; + children = ( + 82E374FA2909C9F2002CFC26 /* WeatherService.swift */, + ); + path = Service; + sourceTree = ""; + }; + 82E374FB2909C9F2002CFC26 /* Models */ = { + isa = PBXGroup; + children = ( + 82E374FC2909C9F2002CFC26 /* Weather.swift */, + ); + path = Models; + sourceTree = ""; + }; + 82E374FD2909C9F2002CFC26 /* Utils */ = { + isa = PBXGroup; + children = ( + 82E374FE2909C9F2002CFC26 /* WeatherUtils.swift */, + 82E374FF2909C9F2002CFC26 /* Date+Extensions.swift */, + ); + path = Utils; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 82E374CD2909C8D1002CFC26 /* SegmentWeatherWidget */ = { + isa = PBXNativeTarget; + buildConfigurationList = 82E374DC2909C8D3002CFC26 /* Build configuration list for PBXNativeTarget "SegmentWeatherWidget" */; + buildPhases = ( + 82E374CA2909C8D1002CFC26 /* Sources */, + 82E374CB2909C8D1002CFC26 /* Frameworks */, + 82E374CC2909C8D1002CFC26 /* Resources */, + 82E374F82909C90B002CFC26 /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + 82E374F32909C90B002CFC26 /* PBXTargetDependency */, + ); + name = SegmentWeatherWidget; + packageProductDependencies = ( + 82C21C9D2913169C00121B41 /* Segment */, + ); + productName = SegmentWeatherWidget; + productReference = 82E374CE2909C8D1002CFC26 /* SegmentWeatherWidget.app */; + productType = "com.apple.product-type.application"; + }; + 82E374E22909C908002CFC26 /* WeatherWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 82E374F52909C90B002CFC26 /* Build configuration list for PBXNativeTarget "WeatherWidgetExtension" */; + buildPhases = ( + 82E374DF2909C908002CFC26 /* Sources */, + 82E374E02909C908002CFC26 /* Frameworks */, + 82E374E12909C908002CFC26 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WeatherWidgetExtension; + packageProductDependencies = ( + 82C21C9F291316B500121B41 /* Segment */, + ); + productName = WeatherWidgetExtension; + productReference = 82E374E32909C908002CFC26 /* WeatherWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 82E374C62909C8D1002CFC26 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1400; + LastUpgradeCheck = 1400; + TargetAttributes = { + 82E374CD2909C8D1002CFC26 = { + CreatedOnToolsVersion = 14.0.1; + }; + 82E374E22909C908002CFC26 = { + CreatedOnToolsVersion = 14.0.1; + }; + }; + }; + buildConfigurationList = 82E374C92909C8D1002CFC26 /* Build configuration list for PBXProject "SegmentWeatherWidget" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 82E374C52909C8D1002CFC26; + packageReferences = ( + ); + productRefGroup = 82E374CF2909C8D1002CFC26 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 82E374CD2909C8D1002CFC26 /* SegmentWeatherWidget */, + 82E374E22909C908002CFC26 /* WeatherWidgetExtension */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 82E374CC2909C8D1002CFC26 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 82E374D92909C8D3002CFC26 /* Preview Assets.xcassets in Resources */, + 82E374D62909C8D3002CFC26 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 82E374E12909C908002CFC26 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 82E374EE2909C90B002CFC26 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 82E374CA2909C8D1002CFC26 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 82E374D42909C8D1002CFC26 /* ContentView.swift in Sources */, + 82E374D22909C8D1002CFC26 /* SegmentWeatherWidgetApp.swift in Sources */, + 82E374F12909C90B002CFC26 /* WeatherWidget.intentdefinition in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 82E374DF2909C908002CFC26 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 82E375062909C9F2002CFC26 /* Weather.swift in Sources */, + 82E374EB2909C908002CFC26 /* WeatherWidget.swift in Sources */, + 82E375052909C9F2002CFC26 /* WeatherService.swift in Sources */, + 82E375072909C9F2002CFC26 /* WeatherUtils.swift in Sources */, + 82E374F02909C90B002CFC26 /* WeatherWidget.intentdefinition in Sources */, + 82E3750C2909C9F2002CFC26 /* WeatherWidgetView.swift in Sources */, + 82E375082909C9F2002CFC26 /* Date+Extensions.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 82E374F32909C90B002CFC26 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 82E374E22909C908002CFC26 /* WeatherWidgetExtension */; + targetProxy = 82E374F22909C90B002CFC26 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 82E374DA2909C8D3002CFC26 /* 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++20"; + 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 = 16.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; + }; + 82E374DB2909C8D3002CFC26 /* 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++20"; + 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 = 16.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; + }; + 82E374DD2909C8D3002CFC26 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"SegmentWeatherWidget/Preview Content\""; + DEVELOPMENT_TEAM = V8R4668S2H; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = SegmentWeatherWidget/Info.plist; + 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.AlanCharles.SegmentWeatherWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 82E374DE2909C8D3002CFC26 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"SegmentWeatherWidget/Preview Content\""; + DEVELOPMENT_TEAM = V8R4668S2H; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = SegmentWeatherWidget/Info.plist; + 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.AlanCharles.SegmentWeatherWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 82E374F62909C90B002CFC26 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = V8R4668S2H; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = WeatherWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = WeatherWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.AlanCharles.SegmentWeatherWidget.WeatherWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 82E374F72909C90B002CFC26 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = V8R4668S2H; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = WeatherWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = WeatherWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.AlanCharles.SegmentWeatherWidget.WeatherWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 82E374C92909C8D1002CFC26 /* Build configuration list for PBXProject "SegmentWeatherWidget" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 82E374DA2909C8D3002CFC26 /* Debug */, + 82E374DB2909C8D3002CFC26 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 82E374DC2909C8D3002CFC26 /* Build configuration list for PBXNativeTarget "SegmentWeatherWidget" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 82E374DD2909C8D3002CFC26 /* Debug */, + 82E374DE2909C8D3002CFC26 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 82E374F52909C90B002CFC26 /* Build configuration list for PBXNativeTarget "WeatherWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 82E374F62909C90B002CFC26 /* Debug */, + 82E374F72909C90B002CFC26 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 82C21C9D2913169C00121B41 /* Segment */ = { + isa = XCSwiftPackageProductDependency; + productName = Segment; + }; + 82C21C9F291316B500121B41 /* Segment */ = { + isa = XCSwiftPackageProductDependency; + productName = Segment; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 82E374C62909C8D1002CFC26 /* Project object */; +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/SegmentWeatherWidget.xcscheme b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/SegmentWeatherWidget.xcscheme new file mode 100644 index 00000000..c5ff7b4b --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/SegmentWeatherWidget.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/WeatherWidgetExtension.xcscheme b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/WeatherWidgetExtension.xcscheme new file mode 100644 index 00000000..5a37843a --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcodeproj/xcshareddata/xcschemes/WeatherWidgetExtension.xcscheme @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/contents.xcworkspacedata b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..c1724d40 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/Contents.json b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/ContentView.swift b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/ContentView.swift new file mode 100644 index 00000000..edc2a6b9 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/ContentView.swift @@ -0,0 +1,26 @@ +// +// ContentView.swift +// SegmentWeatherWidget +// +// Created by Alan Charles on 10/26/22. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundColor(.accentColor) + Text("Hello, world!") + } + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Info.plist b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Info.plist new file mode 100644 index 00000000..e56bbfad --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Info.plist @@ -0,0 +1,10 @@ + + + + + NSUserActivityTypes + + ConfigurationIntent + + + diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Preview Content/Preview Assets.xcassets/Contents.json b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/SegmentWeatherWidgetApp.swift b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/SegmentWeatherWidgetApp.swift new file mode 100644 index 00000000..779d4563 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/SegmentWeatherWidget/SegmentWeatherWidgetApp.swift @@ -0,0 +1,19 @@ +// +// SegmentWeatherWidgetApp.swift +// SegmentWeatherWidget +// +// Created by Alan Charles on 10/26/22. +// + +import SwiftUI +import Segment + +@main +struct SegmentWeatherWidgetApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} + diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/Contents.json b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Info.plist b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Info.plist new file mode 100644 index 00000000..0f118fb7 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Models/Weather.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Models/Weather.swift new file mode 100644 index 00000000..6cb63765 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Models/Weather.swift @@ -0,0 +1,19 @@ +// +// Weather.swift +// SegmentWeatherWidgetExample +// +// Created by Alan Charles on 10/26/22. +// + +import Foundation + +struct Weather: Codable { + let name: String + let temperature: Int + let unit: String + let description: String +} + +struct WeatherResponse: Codable { + let forecast: [Weather] +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Service/WeatherService.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Service/WeatherService.swift new file mode 100644 index 00000000..49e8b359 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Service/WeatherService.swift @@ -0,0 +1,36 @@ +// +// WeatherService.swift +// SegmentWeatherWidgetExample +// +// Created by Alan Charles on 10/26/22. +// + +import Foundation +import Segment + +class WeatherService { + let url = URL(string: "https://api.lil.software/weather?latitude=37.7749&longitude=-122.4194")! + + + func getWeather(completion: @escaping (Result<[Weather], Error>) -> Void) { + URLSession.shared.dataTask(with: url) {data, response, error in + guard error == nil else { + completion(.failure(error!)) + return + } + + completion(.success(self.getWeatherResponse(fromData: data!))) + }.resume() + } + + private func getWeatherResponse(fromData data: Data) -> [Weather] { + let weatherData = try? JSONDecoder().decode(WeatherResponse.self, from: data) + + if let weather = weatherData { + return weather.forecast + } + + return [Weather(name: "Error", temperature: 0, unit: "", description: "")] + } +} + diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/Date+Extensions.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/Date+Extensions.swift new file mode 100644 index 00000000..5590de8f --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/Date+Extensions.swift @@ -0,0 +1,51 @@ +// +// Date+Extensions.swift +// SegmentWeatherWidgetExample +// +// Created by Alan Charles on 10/26/22. +// + +import Foundation + + +extension Date { + func timeOnly() -> String { + let formatter = DateFormatter() + formatter.dateFormat = "hh:mm a" + + return formatter.string(from: self) + } + + func timeSinceDate() -> String { + let fromDate = self + let toDate = Date() + + // Year + if let interval = Calendar.current.dateComponents([.year], from: fromDate, to: toDate).year, interval > 0 { + return interval == 1 ? "\(interval)" + "" + "year ago": "\(interval)" + "" + "years ago" + } + + // Month + if let interval = Calendar.current.dateComponents([.month], from: fromDate, to: toDate).month, interval > 0 { + return interval == 1 ? "\(interval)" + "" + "month ago" : "\(interval)" + "" + "months ago" + } + + // Day + if let interval = Calendar.current.dateComponents([.day], from: fromDate, to: toDate).day, interval > 0 { + return interval == 1 ? "\(interval)" + "" + "day ago" : "\(interval)" + "" + "days ago" + } + + // Hour + if let interval = Calendar.current.dateComponents([.hour], from: fromDate, to: toDate).hour, interval > 0 { + return interval == 1 ? "\(interval)" + "" + "hour ago" : "\(interval)" + "" + "hours ago" + } + + // Minute + if let interval = Calendar.current.dateComponents([.minute], from: fromDate, to: toDate).minute, interval > 0 { + return interval == 1 ? "\(interval)" + "" + "minute ago" : "\(interval)" + "" + "minutes ago" + } + + return "a moment ago" + } + +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/WeatherUtils.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/WeatherUtils.swift new file mode 100644 index 00000000..edb0d89e --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/Utils/WeatherUtils.swift @@ -0,0 +1,39 @@ +// +// WeatherUtils.swift +// SegmentWeatherWidgetExample +// +// Created by Alan Charles on 10/26/22. +// + +import Foundation + +struct WeatherUtils { + static func getWeatherIcon(_ conditionString: String) -> String { + let current = conditionString.lowercased() + switch current { + case _ where current.contains("partly sunny"): + return "🌤️" + + case _ where current.contains("light rain"): + return "☔️" + + case _ where current.contains("cloudy"): + return "☁️" + + case _ where current.contains("drizzle"): + return "🌧️" + + case _ where current.contains("sunny"): + return "☀️" + + case _ where current.contains("clear"): + return "☀️" + + case _ where current.contains("fog"): + return "🌫️" + + default: + return "🌤️" + } + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.intentdefinition b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.intentdefinition new file mode 100644 index 00000000..3c8fdf69 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.intentdefinition @@ -0,0 +1,57 @@ + + + + + INEnums + + INIntentDefinitionModelVersion + 1.2 + INIntentDefinitionNamespace + 88xZPY + INIntentDefinitionSystemVersion + 22A380 + INIntentDefinitionToolsBuildVersion + 14A400 + INIntentDefinitionToolsVersion + 14.0.1 + INIntents + + + INIntentCategory + information + INIntentDescriptionID + tVvJ9c + INIntentIneligibleForSuggestions + + INIntentName + Configuration + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + + INIntentTitle + Configuration + INIntentTitleID + gpCwrM + INIntentType + Custom + INIntentVerb + View + + + INTypes + + + diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.swift new file mode 100644 index 00000000..c23e59bb --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidget.swift @@ -0,0 +1,94 @@ +// +// WeatherWidget.swift +// WeatherWidget +// +// Created by Alan Charles on 10/26/22. +// + +import Segment +import WidgetKit +import SwiftUI +import Intents + +struct WeatherTimelineProvider: TimelineProvider { + + + typealias Entry = WeatherEntry + + private func snapshotWeatherInfo() -> [Weather] { + var weatherInfo = [Weather]() + for i in 0...9 { + let weather = Weather(name: "Day \(i + 1)", temperature: 10 * i, unit: "F", description: "Cloudy") + weatherInfo.append(weather) + } + return weatherInfo + } + + func placeholder(in context: TimelineProvider.Context) -> WeatherEntry { + WeatherEntry(date: Date(), weatherInfo: snapshotWeatherInfo()) + } + + func getSnapshot(in context: TimelineProvider.Context, completion: @escaping (WeatherEntry) -> Void) { + completion(WeatherEntry(date: Date(), weatherInfo: snapshotWeatherInfo())) + } + + func getTimeline(in context: TimelineProvider.Context, completion: @escaping (WidgetKit.Timeline) -> Void) { + let currentDate = Date() + let refreshDate = Calendar.current.date(byAdding: .minute, value: 15, to: currentDate)! + + WeatherService().getWeather { result in + let weatherInfo: [Weather] + + switch result { + case .success(let fetchedWeather): + weatherInfo = fetchedWeather + case .failure(let err): + weatherInfo = [Weather(name: "Error", temperature: 0, unit: "", description: "\(err.localizedDescription)")] + } + + let entry = WeatherEntry(date: currentDate, weatherInfo: weatherInfo) + let timeline = WidgetKit.Timeline(entries: [entry], policy: .after(refreshDate)) + completion(timeline) + } + } +} + +struct SimpleEntry: TimelineEntry { + let date: Date + let configuration: ConfigurationIntent +} + +struct WeatherEntry: TimelineEntry { + let date: Date + let weatherInfo: [Weather] +} + +@main +struct WeatherWidget: Widget { + let kind: String = "WeatherWidget" + var analytics: Analytics? + init() { + let configuration = Segment.Configuration(writeKey: "WRITE_KEY") + + configuration.flushAt(1) + analytics = Segment.Analytics(configuration: configuration) + analytics?.track(name: "Widget Launched") + } + + private let supportedFamilies:[WidgetFamily] = { + if #available(iOSApplicationExtension 16.0, *) { + return [.systemSmall, .systemMedium, .systemLarge, .accessoryInline, .accessoryCircular, .accessoryRectangular] + } else { + return [.systemSmall, .systemMedium, .systemLarge] + } + }() + + var body: some WidgetConfiguration { + StaticConfiguration(kind: kind, provider: WeatherTimelineProvider()){ entry in + WeatherEntryView(entry: entry) + } + .configurationDisplayName("SF Weather Widget") + .description("This widget shows the current weather for SF.") + .supportedFamilies(supportedFamilies) + } +} diff --git a/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidgetView.swift b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidgetView.swift new file mode 100644 index 00000000..70bce628 --- /dev/null +++ b/Examples/apps/SegmentWeatherWidget/WeatherWidget/WeatherWidgetView.swift @@ -0,0 +1,119 @@ +// +// WeatherWidgetView.swift +// SegmentWeatherWidgetExample +// +// Created by Alan Charles on 10/26/22. +// + +import SwiftUI +import Segment + +struct WeatherView: View { + let weather: Weather + let updatedData: Date + + var body: some View { + + VStack(alignment: .leading) { + Text("San Francisco") + Text("\(weather.temperature)°\(weather.unit)") + .font(.largeTitle) + Text(WeatherUtils.getWeatherIcon(weather.description)) + .padding(.top, 10) + Text(weather.description) + .font(.footnote) + + HStack { + Spacer() + Text("Update: \(updatedData.timeOnly())") + .font(.system(size: 12)) + .foregroundColor(.secondary) + } + }.padding() + } +} + +struct DailyWeatherView: View { + let weather: Weather + + var body: some View { + VStack(alignment: .leading) { + Text(weather.name.lowercased().contains("night") ? "\(weather.name.prefix(2)) 🌙" : weather.name.prefix(2)) + Text("\(weather.temperature)°\(weather.unit)") + Text(WeatherUtils.getWeatherIcon(weather.description)) + .padding(.top, 10) + }.padding() + } +} + +struct WeatherEntryView: View { + var analytics: Analytics? + let entry: WeatherEntry + + @Environment(\.widgetFamily) var family + + let baseColor = Color.gray.opacity(0.2) + let darkColor = Color.black.opacity(0.8) + var body: some View { + + switch family { + case .systemSmall: + ZStack { + baseColor + WeatherView(weather: entry.weatherInfo[0], updatedData: entry.date) + }.edgesIgnoringSafeArea(.all) + case .systemMedium: + ZStack { + HStack(spacing: 0) { + Rectangle().fill(baseColor) + Rectangle().fill(darkColor) + } + HStack { + WeatherView(weather: entry.weatherInfo[0], updatedData: entry.date) + WeatherView(weather: entry.weatherInfo[1], updatedData: entry.date) + .foregroundColor(.white) + } + } + case .systemLarge: + VStack{ + ZStack { + HStack(spacing: 0) { + Rectangle().fill(baseColor) + Rectangle().fill(darkColor) + } + HStack { + WeatherView(weather: entry.weatherInfo[0], updatedData: entry.date) + WeatherView(weather: entry.weatherInfo[1], updatedData: entry.date) + .foregroundColor(.white) + } + + } + VStack { + HStack { + VStack(alignment: .leading) { + DailyWeatherView(weather: entry.weatherInfo[2]) + DailyWeatherView(weather: entry.weatherInfo[3]) + } + VStack(alignment: .leading) { + DailyWeatherView(weather: entry.weatherInfo[4]) + DailyWeatherView(weather: entry.weatherInfo[5]) + } + VStack(alignment: .leading) { + DailyWeatherView(weather: entry.weatherInfo[6]) + DailyWeatherView(weather: entry.weatherInfo[7]) + } + VStack(alignment: .leading) { + DailyWeatherView(weather: entry.weatherInfo[8]) + DailyWeatherView(weather: entry.weatherInfo[9]) + } + } + } + } + default: + ZStack { + baseColor + WeatherView(weather: entry.weatherInfo[0], updatedData: entry.date) + }.edgesIgnoringSafeArea(.all) + } + } +}