From 1866915bce62d261a98776b4e2331ac8269b566d Mon Sep 17 00:00:00 2001 From: Kevin McKee Date: Mon, 23 Jun 2025 07:56:58 -0700 Subject: [PATCH 1/3] Sharing the ContentVIew across both apps. --- OAuthSample.xcodeproj/project.pbxproj | 2 + OAuthSampleWatch/Classes/ContentView.swift | 69 ---------------------- 2 files changed, 2 insertions(+), 69 deletions(-) delete mode 100644 OAuthSampleWatch/Classes/ContentView.swift diff --git a/OAuthSample.xcodeproj/project.pbxproj b/OAuthSample.xcodeproj/project.pbxproj index 2faf9b9..d0da6fe 100644 --- a/OAuthSample.xcodeproj/project.pbxproj +++ b/OAuthSample.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ CE38E0ED2E0719EB0065319C /* OAuth+Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE38E0EC2E0719EB0065319C /* OAuth+Window.swift */; }; CE4317502E08AF77009B3DF1 /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CE43174F2E08AF77009B3DF1 /* OAuthKit */; }; CE4317512E08B0BB009B3DF1 /* oauth.json in Resources */ = {isa = PBXBuildFile; fileRef = CE1FE0CC2BF6F73000078EB1 /* oauth.json */; }; + CE43175A2E09A27D009B3DF1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1FE0BB2BF66AC400078EB1 /* ContentView.swift */; }; CE65D4F52DEB6C4A00A24D2A /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CE65D4F42DEB6C4A00A24D2A /* OAuthKit */; }; CEC9CBB62DE946EF00F181DF /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CEC9CBB52DE946EF00F181DF /* OAuthKit */; }; CEF889822E08ACFF0083845F /* OAuthSampleWatch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = CEF889782E08ACFD0083845F /* OAuthSampleWatch.app */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -275,6 +276,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CE43175A2E09A27D009B3DF1 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OAuthSampleWatch/Classes/ContentView.swift b/OAuthSampleWatch/Classes/ContentView.swift deleted file mode 100644 index fbb11a3..0000000 --- a/OAuthSampleWatch/Classes/ContentView.swift +++ /dev/null @@ -1,69 +0,0 @@ -// -// ContentView.swift -// OAuthSampleWatch -// -// Created by Kevin McKee -// - -import OAuthKit -import SwiftUI - -struct ContentView: View { - - @Environment(\.oauth) - var oauth: OAuth - - var body: some View { - - VStack(spacing: 8) { - switch oauth.state { - case .empty: - providerList - case .authorizing(let provider, let grantType): - Text("Authorizing [\(provider.id)] with [\(grantType.rawValue)]") - case .requestingAccessToken(let provider): - Text("Requesting Access Token [\(provider.id)]") - case .requestingDeviceCode(let provider): - Text("Requesting Device Code [\(provider.id)]") - case .authorized(let provider, _): - HStack { - Button("Authorized [\(provider.id)]") { - oauth.clear() - } - Button { - oauth.authorize(provider: provider, grantType: .refreshToken) - } label: { - Image(systemName: "arrow.clockwise") - } - - } - case .receivedDeviceCode(_, let deviceCode): - Text("To login, visit") - Text(.init("[\(deviceCode.verificationUri)](\(deviceCode.verificationUri))")) - .foregroundStyle(.blue) - Text("and enter the following code:") - Text(deviceCode.userCode) - .padding() - .border(Color.primary) - .font(.title) - } - } - .onChange(of: oauth.state) { _, state in - debugPrint("✅", state) - } - .padding() - } - - /// Displays a list of oauth providers. - var providerList: some View { - List(oauth.providers) { provider in - Button(provider.id) { - // Start authorization (See companion iOS app for details) - } - } - } -} - -#Preview { - ContentView() -} From c38d330ac10b0cb4cdc8c8f12860dddf920d6a51 Mon Sep 17 00:00:00 2001 From: Kevin McKee Date: Mon, 23 Jun 2025 08:00:20 -0700 Subject: [PATCH 2/3] Sharing the swift files across apps. --- OAuthSample.xcodeproj/project.pbxproj | 4 ++++ .../AccentColor.colorset/Contents.json | 11 ---------- .../AppIcon.appiconset/Contents.json | 13 ----------- .../Assets.xcassets/Contents.json | 6 ----- .../Classes/OAuthSampleWatchApp.swift | 22 ------------------- 5 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 OAuthSampleWatch/Assets.xcassets/AccentColor.colorset/Contents.json delete mode 100644 OAuthSampleWatch/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 OAuthSampleWatch/Assets.xcassets/Contents.json delete mode 100644 OAuthSampleWatch/Classes/OAuthSampleWatchApp.swift diff --git a/OAuthSample.xcodeproj/project.pbxproj b/OAuthSample.xcodeproj/project.pbxproj index d0da6fe..34e2cd9 100644 --- a/OAuthSample.xcodeproj/project.pbxproj +++ b/OAuthSample.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ CE4317502E08AF77009B3DF1 /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CE43174F2E08AF77009B3DF1 /* OAuthKit */; }; CE4317512E08B0BB009B3DF1 /* oauth.json in Resources */ = {isa = PBXBuildFile; fileRef = CE1FE0CC2BF6F73000078EB1 /* oauth.json */; }; CE43175A2E09A27D009B3DF1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1FE0BB2BF66AC400078EB1 /* ContentView.swift */; }; + CE43175B2E09A2E5009B3DF1 /* OAuthSampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1FE0B92BF66AC400078EB1 /* OAuthSampleApp.swift */; }; + CE43175C2E09A321009B3DF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE1FE0BD2BF66AC500078EB1 /* Assets.xcassets */; }; CE65D4F52DEB6C4A00A24D2A /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CE65D4F42DEB6C4A00A24D2A /* OAuthKit */; }; CEC9CBB62DE946EF00F181DF /* OAuthKit in Frameworks */ = {isa = PBXBuildFile; productRef = CEC9CBB52DE946EF00F181DF /* OAuthKit */; }; CEF889822E08ACFF0083845F /* OAuthSampleWatch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = CEF889782E08ACFD0083845F /* OAuthSampleWatch.app */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -255,6 +257,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + CE43175C2E09A321009B3DF1 /* Assets.xcassets in Resources */, CE4317512E08B0BB009B3DF1 /* oauth.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -277,6 +280,7 @@ buildActionMask = 2147483647; files = ( CE43175A2E09A27D009B3DF1 /* ContentView.swift in Sources */, + CE43175B2E09A2E5009B3DF1 /* OAuthSampleApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OAuthSampleWatch/Assets.xcassets/AccentColor.colorset/Contents.json b/OAuthSampleWatch/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb87897..0000000 --- a/OAuthSampleWatch/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/OAuthSampleWatch/Assets.xcassets/AppIcon.appiconset/Contents.json b/OAuthSampleWatch/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 49c81cd..0000000 --- a/OAuthSampleWatch/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "platform" : "watchos", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/OAuthSampleWatch/Assets.xcassets/Contents.json b/OAuthSampleWatch/Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/OAuthSampleWatch/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/OAuthSampleWatch/Classes/OAuthSampleWatchApp.swift b/OAuthSampleWatch/Classes/OAuthSampleWatchApp.swift deleted file mode 100644 index f8eb94b..0000000 --- a/OAuthSampleWatch/Classes/OAuthSampleWatchApp.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// OAuthSampleWatchApp.swift -// OAuthSampleWatch -// -// Created by Kevin McKee -// - -import OAuthKit -import SwiftUI - -@main -struct OAuthSampleWatchApp: App { - - @Environment(\.oauth) - var oauth: OAuth - - var body: some Scene { - WindowGroup { - ContentView() - } - } -} From 239d1874eb65cd8c104327fb9043d48c10a1e93b Mon Sep 17 00:00:00 2001 From: Kevin McKee Date: Mon, 23 Jun 2025 08:03:05 -0700 Subject: [PATCH 3/3] Sharing views and assets across apps. --- OAuthSample.xcodeproj/project.pbxproj | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/OAuthSample.xcodeproj/project.pbxproj b/OAuthSample.xcodeproj/project.pbxproj index 34e2cd9..e895fec 100644 --- a/OAuthSample.xcodeproj/project.pbxproj +++ b/OAuthSample.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 70; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ @@ -61,10 +61,6 @@ CEF889782E08ACFD0083845F /* OAuthSampleWatch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OAuthSampleWatch.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ -/* Begin PBXFileSystemSynchronizedRootGroup section */ - CEF889792E08ACFD0083845F /* OAuthSampleWatch */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = OAuthSampleWatch; sourceTree = ""; }; -/* End PBXFileSystemSynchronizedRootGroup section */ - /* Begin PBXFrameworksBuildPhase section */ CE1FE0B32BF66AC400078EB1 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; @@ -91,7 +87,6 @@ isa = PBXGroup; children = ( CE1FE0B82BF66AC400078EB1 /* OAuthSample */, - CEF889792E08ACFD0083845F /* OAuthSampleWatch */, CE43174E2E08AF77009B3DF1 /* Frameworks */, CE1FE0B72BF66AC400078EB1 /* Products */, ); @@ -191,9 +186,6 @@ ); dependencies = ( ); - fileSystemSynchronizedGroups = ( - CEF889792E08ACFD0083845F /* OAuthSampleWatch */, - ); name = OAuthSampleWatch; packageProductDependencies = ( CE43174F2E08AF77009B3DF1 /* OAuthKit */,