From b84a0f00ba571b06854ad046e71cce9234fe1c44 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Wed, 11 Oct 2023 16:18:51 +0100 Subject: [PATCH 1/3] Add demo app google client id --- DemoApp/Info.plist | 8 +-- DemoApp/Resources/GoogleSignIn.plist | 4 +- .../Sources/Components/AppEnvironment.swift | 3 +- DemoApp/Sources/Views/Login/LoginView.swift | 18 +++--- Gemfile.lock | 4 +- StreamVideo.xcodeproj/project.pbxproj | 59 +------------------ .../xcshareddata/xcschemes/DemoApp.xcscheme | 39 ++++++++++++ .../xcschemes/DemoAppUIKit.xcscheme | 20 ++++++- .../xcschemes/StreamVideo.xcscheme | 18 ++++++ fastlane/Fastfile | 18 ++++-- fastlane/Pluginfile | 2 +- 11 files changed, 112 insertions(+), 81 deletions(-) diff --git a/DemoApp/Info.plist b/DemoApp/Info.plist index 0e167794f..1d6c536f2 100644 --- a/DemoApp/Info.plist +++ b/DemoApp/Info.plist @@ -40,17 +40,17 @@ CFBundleTypeRole Editor CFBundleURLName - com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh + $(GOOGLE_CLIENT_ID) CFBundleURLSchemes - com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh + $(GOOGLE_CLIENT_ID) + GIDClientID + $(GOOGLE_CLIENT_ID) CFBundleVersion 1 - GIDClientID - com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh ITSAppUsesNonExemptEncryption NSAppTransportSecurity diff --git a/DemoApp/Resources/GoogleSignIn.plist b/DemoApp/Resources/GoogleSignIn.plist index dc4978b57..5117c3f48 100644 --- a/DemoApp/Resources/GoogleSignIn.plist +++ b/DemoApp/Resources/GoogleSignIn.plist @@ -3,9 +3,9 @@ CLIENT_ID - 347024607410-48j4atipav0tcr4pesap4elr1u9t11uh.apps.googleusercontent.com + $(GOOGLE_CLIENT_ID) REVERSED_CLIENT_ID - com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh + $(REVERSED_GOOGLE_CLIENT_ID) PLIST_VERSION 1 BUNDLE_ID diff --git a/DemoApp/Sources/Components/AppEnvironment.swift b/DemoApp/Sources/Components/AppEnvironment.swift index ab008dc16..aea1a2cc8 100644 --- a/DemoApp/Sources/Components/AppEnvironment.swift +++ b/DemoApp/Sources/Components/AppEnvironment.swift @@ -63,7 +63,7 @@ extension AppEnvironment { }() static var googleClientId: String = { - return "347024607410-48j4atipav0tcr4pesap4elr1u9t11uh.apps.googleusercontent.com" + return AppEnvironment.value(for: .GoogleSignIn)! }() } @@ -115,6 +115,7 @@ extension AppEnvironment { enum Variable: String { case JWTExpiration = "JWT_EXPIRATION" + case GoogleSignIn = "REVERSED_GOOGLE_CLIENT_ID" } static func contains(_ argument: Argument) -> Bool { diff --git a/DemoApp/Sources/Views/Login/LoginView.swift b/DemoApp/Sources/Views/Login/LoginView.swift index 69d3c15cb..e69f93a22 100644 --- a/DemoApp/Sources/Views/Login/LoginView.swift +++ b/DemoApp/Sources/Views/Login/LoginView.swift @@ -54,15 +54,17 @@ struct LoginView: View { Image(systemName: "person.crop.circle.badge.clock.fill") } - LoginItemView { - Task { - let credentials = try await GoogleHelper.signIn() - completion(credentials) + if AppEnvironment.value(for: .GoogleSignIn)?.isEmpty == false { + LoginItemView { + Task { + let credentials = try await GoogleHelper.signIn() + completion(credentials) + } + } title: { + Text("Login with Stream account") + } icon: { + Image(systemName: "person.crop.circle.badge.clock.fill") } - } title: { - Text("Login with Stream account") - } icon: { - Image(systemName: "person.crop.circle.badge.clock.fill") } LoginItemView { diff --git a/Gemfile.lock b/Gemfile.lock index c4f0f81e1..64c290cda 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -189,7 +189,7 @@ GEM bundler fastlane pry - fastlane-plugin-stream_actions (0.3.20) + fastlane-plugin-stream_actions (0.3.22) xctest_list (= 1.2.1) fastlane-plugin-versioning (0.5.2) ffi (1.16.2) @@ -406,7 +406,7 @@ DEPENDENCIES fastlane fastlane-plugin-emerge fastlane-plugin-lizard - fastlane-plugin-stream_actions (= 0.3.20) + fastlane-plugin-stream_actions (= 0.3.22) fastlane-plugin-versioning jazzy json diff --git a/StreamVideo.xcodeproj/project.pbxproj b/StreamVideo.xcodeproj/project.pbxproj index 6f2bb950d..d6924f10f 100644 --- a/StreamVideo.xcodeproj/project.pbxproj +++ b/StreamVideo.xcodeproj/project.pbxproj @@ -3247,7 +3247,6 @@ isa = PBXNativeTarget; buildConfigurationList = 842D8BD12865B31D00801910 /* Build configuration list for PBXNativeTarget "DemoApp" */; buildPhases = ( - 82DE10C72A827B010057BDA8 /* ShellScript */, 842D8BBF2865B31B00801910 /* Sources */, 842D8BC02865B31B00801910 /* Frameworks */, 842D8BC12865B31B00801910 /* Resources */, @@ -3299,7 +3298,6 @@ isa = PBXNativeTarget; buildConfigurationList = 8493225D2908378B0013C029 /* Build configuration list for PBXNativeTarget "DemoAppUIKit" */; buildPhases = ( - 82010CAD2A851C06005C125D /* ShellScript */, 84932248290837890013C029 /* Sources */, 84932249290837890013C029 /* Frameworks */, 8493224A290837890013C029 /* Resources */, @@ -3347,7 +3345,6 @@ isa = PBXNativeTarget; buildConfigurationList = 84F737FF287C13AD00A363F4 /* Build configuration list for PBXNativeTarget "StreamVideoTests" */; buildPhases = ( - 827297E42A4585EA00774306 /* ShellScript */, 84F737F0287C13AD00A363F4 /* Sources */, 84F737F1287C13AD00A363F4 /* Frameworks */, 84F737F2287C13AD00A363F4 /* Resources */, @@ -3664,61 +3661,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 82010CAD2A851C06005C125D /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n"; - }; - 827297E42A4585EA00774306 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n"; - showEnvVarsInLog = 0; - }; - 82DE10C72A827B010057BDA8 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n"; - }; 8434C53A289BBDF30001490A /* SwiftGen */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -5208,6 +5150,7 @@ }; 842D8BD22865B31D00801910 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8206D84F2A5DB9300099F5EC /* Credentials.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; diff --git a/StreamVideo.xcodeproj/xcshareddata/xcschemes/DemoApp.xcscheme b/StreamVideo.xcodeproj/xcshareddata/xcschemes/DemoApp.xcscheme index 2f0cbea00..a338074bc 100644 --- a/StreamVideo.xcodeproj/xcshareddata/xcschemes/DemoApp.xcscheme +++ b/StreamVideo.xcodeproj/xcshareddata/xcschemes/DemoApp.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + + + + + + + + + + + + + + version = "1.7"> + + + + + + + + + + + + + + + + + + + + Date: Thu, 12 Oct 2023 13:57:07 +0100 Subject: [PATCH 2/3] Update things --- DemoApp/Info.plist | 12 ++++++++++-- DemoApp/Sources/Components/AppEnvironment.swift | 7 ++----- DemoApp/Sources/DemoApp.swift | 2 -- DemoApp/Sources/Views/Login/GoogleHelper.swift | 7 +++++-- DemoApp/Sources/Views/Login/LoginView.swift | 5 ++++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/DemoApp/Info.plist b/DemoApp/Info.plist index 1d6c536f2..32c02b2e5 100644 --- a/DemoApp/Info.plist +++ b/DemoApp/Info.plist @@ -46,9 +46,17 @@ $(GOOGLE_CLIENT_ID) + + CFBundleTypeRole + Editor + CFBundleURLName + $(REVERSED_GOOGLE_CLIENT_ID) + CFBundleURLSchemes + + $(REVERSED_GOOGLE_CLIENT_ID) + + - GIDClientID - $(GOOGLE_CLIENT_ID) CFBundleVersion 1 ITSAppUsesNonExemptEncryption diff --git a/DemoApp/Sources/Components/AppEnvironment.swift b/DemoApp/Sources/Components/AppEnvironment.swift index aea1a2cc8..f30a415d3 100644 --- a/DemoApp/Sources/Components/AppEnvironment.swift +++ b/DemoApp/Sources/Components/AppEnvironment.swift @@ -61,10 +61,6 @@ extension AppEnvironment { return .production } }() - - static var googleClientId: String = { - return AppEnvironment.value(for: .GoogleSignIn)! - }() } extension AppEnvironment { @@ -115,7 +111,8 @@ extension AppEnvironment { enum Variable: String { case JWTExpiration = "JWT_EXPIRATION" - case GoogleSignIn = "REVERSED_GOOGLE_CLIENT_ID" + case googleClientId = "GOOGLE_CLIENT_ID" + case googleReversedClientId = "REVERSED_GOOGLE_CLIENT_ID" } static func contains(_ argument: Argument) -> Bool { diff --git a/DemoApp/Sources/DemoApp.swift b/DemoApp/Sources/DemoApp.swift index 45f2d5535..1ad39bcb1 100644 --- a/DemoApp/Sources/DemoApp.swift +++ b/DemoApp/Sources/DemoApp.swift @@ -17,8 +17,6 @@ struct DemoApp: App { @StateObject var appState: AppState private let router: Router - - lazy var signInConfig = GIDConfiguration(clientID: AppEnvironment.googleClientId) // MARK: - Lifecycle diff --git a/DemoApp/Sources/Views/Login/GoogleHelper.swift b/DemoApp/Sources/Views/Login/GoogleHelper.swift index d8e43746d..7b7427505 100644 --- a/DemoApp/Sources/Views/Login/GoogleHelper.swift +++ b/DemoApp/Sources/Views/Login/GoogleHelper.swift @@ -17,11 +17,14 @@ enum GoogleHelper { private static let directoryScope = "https://www.googleapis.com/auth/directory.readonly" static func signIn() async throws -> UserCredentials { - guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else { + guard + let rootViewController = UIApplication.shared.windows.first?.rootViewController, + let clientId = AppEnvironment.value(for: .googleClientId) + else { throw ClientError.Unexpected("No view controller available") } - let config = GIDConfiguration(clientID: AppEnvironment.googleClientId) + let config = GIDConfiguration(clientID: clientId) return try await withCheckedThrowingContinuation { continuation in GIDSignIn.sharedInstance.signIn(with: config, presenting: rootViewController) { user, error in guard let userProfile = user?.profile else { diff --git a/DemoApp/Sources/Views/Login/LoginView.swift b/DemoApp/Sources/Views/Login/LoginView.swift index e69f93a22..f73b6eeea 100644 --- a/DemoApp/Sources/Views/Login/LoginView.swift +++ b/DemoApp/Sources/Views/Login/LoginView.swift @@ -54,7 +54,10 @@ struct LoginView: View { Image(systemName: "person.crop.circle.badge.clock.fill") } - if AppEnvironment.value(for: .GoogleSignIn)?.isEmpty == false { + if + AppEnvironment.value(for: .googleClientId)?.isEmpty == false, + AppEnvironment.value(for: .googleReversedClientId)?.isEmpty == false + { LoginItemView { Task { let credentials = try await GoogleHelper.signIn() From e0cdd8ee6d4d103aa286b4c9f9847de241bebdaa Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Thu, 12 Oct 2023 15:29:05 +0100 Subject: [PATCH 3/3] Add badge --- Gemfile | 1 + Gemfile.lock | 5 +++++ fastlane/Fastfile | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e37358f2d..85071c6eb 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } +gem 'badge' gem 'cocoapods' gem 'danger' gem 'danger-commit_lint' diff --git a/Gemfile.lock b/Gemfile.lock index 64c290cda..d969aecb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,6 +33,10 @@ GEM aws-sigv4 (1.6.0) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) + badge (0.13.0) + fastimage (>= 1.6) + fastlane (>= 2.0) + mini_magick (>= 4.9.4, < 5.0.0) claide (1.1.0) claide-plugins (0.9.2) cork @@ -400,6 +404,7 @@ PLATFORMS ruby DEPENDENCIES + badge cocoapods danger danger-commit_lint diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 0ab2496ff..9c40dad80 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -88,7 +88,10 @@ lane :match_me do |options| end lane :swiftui_testflight_build do |options| - xcargs = options[:configuration] == 'Debug' ? "GOOGLE_CLIENT_ID='#{gci}' REVERSED_GOOGLE_CLIENT_ID=#{reversed_gci}" : nil + beta = options[:configuration] == 'Debug' + badge(path: 'DemoApp/') if beta + xcargs = beta ? "GOOGLE_CLIENT_ID='#{gci}' REVERSED_GOOGLE_CLIENT_ID=#{reversed_gci}" : nil + upload_beta( app_target: 'DemoApp', app_identifier: 'io.getstream.iOS.VideoDemoApp',