From ea3cdd93745b641e9f534a68abf112d281de67a6 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 12 Feb 2022 13:15:30 +0700 Subject: [PATCH] set service id for keychain --- LiveKitExample.xcodeproj/project.pbxproj | 26 +++++++++---------- Shared/Controllers/AppContext.swift | 2 +- Shared/LiveKitExample.swift | 2 +- Shared/Support/SecureStore.swift | 6 ++++- .../BroadcastExt}/BroadcastExt.entitlements | 0 {BroadcastExt => iOS/BroadcastExt}/Info.plist | 0 .../BroadcastExt}/SampleHandler.swift | 0 7 files changed, 20 insertions(+), 16 deletions(-) rename {BroadcastExt => iOS/BroadcastExt}/BroadcastExt.entitlements (100%) rename {BroadcastExt => iOS/BroadcastExt}/Info.plist (100%) rename {BroadcastExt => iOS/BroadcastExt}/SampleHandler.swift (100%) diff --git a/LiveKitExample.xcodeproj/project.pbxproj b/LiveKitExample.xcodeproj/project.pbxproj index 8588992..f688ea7 100644 --- a/LiveKitExample.xcodeproj/project.pbxproj +++ b/LiveKitExample.xcodeproj/project.pbxproj @@ -172,6 +172,7 @@ isa = PBXGroup; children = ( 6865EA2527513B4500FFAFC3 /* Info.plist */, + 683F05F6273F96B20080C7AC /* BroadcastExt */, 683F0603273FAD690080C7AC /* iOS.entitlements */, ); path = iOS; @@ -191,7 +192,6 @@ 68B3853B271E780600711D5F /* Shared */, 6865EA2427513B4500FFAFC3 /* iOS */, 68B3854A271E780700711D5F /* macOS */, - 683F05F6273F96B20080C7AC /* BroadcastExt */, 68B38544271E780700711D5F /* Products */, 681E3F47271FCB40007BB547 /* Frameworks */, ); @@ -436,11 +436,11 @@ 683F05FE273F96B20080C7AC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_ENTITLEMENTS = BroadcastExt/BroadcastExt.entitlements; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/iOS/BroadcastExt/BroadcastExt.entitlements"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = J48VV6BZV9; - INFOPLIST_FILE = BroadcastExt/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/iOS/BroadcastExt/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = BroadcastExt; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -461,11 +461,11 @@ 683F05FF273F96B20080C7AC /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_ENTITLEMENTS = BroadcastExt/BroadcastExt.entitlements; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/iOS/BroadcastExt/BroadcastExt.entitlements"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = J48VV6BZV9; - INFOPLIST_FILE = BroadcastExt/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/iOS/BroadcastExt/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = BroadcastExt; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -606,7 +606,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = iOS/iOS.entitlements; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/iOS/iOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 2; @@ -640,7 +640,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = iOS/iOS.entitlements; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/iOS/iOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 2; @@ -674,11 +674,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = MacAppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = macOS/macOS.entitlements; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/macOS/macOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = J48VV6BZV9; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -691,7 +691,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = "io.livekit.example.Multiplatform-SwiftUI"; PRODUCT_NAME = LiveKitExample; SDKROOT = macosx; @@ -704,11 +704,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = MacAppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = "LiveKitExample (macOS)Release.entitlements"; + CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/macOS/macOS.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = J48VV6BZV9; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -721,7 +721,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = "io.livekit.example.Multiplatform-SwiftUI"; PRODUCT_NAME = LiveKitExample; SDKROOT = macosx; diff --git a/Shared/Controllers/AppContext.swift b/Shared/Controllers/AppContext.swift index 3475554..b962a61 100644 --- a/Shared/Controllers/AppContext.swift +++ b/Shared/Controllers/AppContext.swift @@ -38,6 +38,6 @@ final class AppContext: ObservableObject { self.preferMetal = store.get(.preferMetal) ?? true self.videoViewMode = store.get(.videoViewMode) ?? .fit self.videoViewMirrored = store.get(.videoViewMirrored) ?? false - self.connectionHistory = store.get(.connectionHistory) ?? [] + self.connectionHistory = store.get(.connectionHistory) ?? Set() } } diff --git a/Shared/LiveKitExample.swift b/Shared/LiveKitExample.swift index 74431b8..3a83fe6 100644 --- a/Shared/LiveKitExample.swift +++ b/Shared/LiveKitExample.swift @@ -2,7 +2,7 @@ import SwiftUI import Logging import LiveKit -let store = SecureStore() +let store = SecureStore(service: "io.livekit.example") struct RoomContextView: View { diff --git a/Shared/Support/SecureStore.swift b/Shared/Support/SecureStore.swift index fcd8059..6c5d4ca 100644 --- a/Shared/Support/SecureStore.swift +++ b/Shared/Support/SecureStore.swift @@ -27,10 +27,14 @@ enum SecureStoreKeys: String { class SecureStore where K.RawValue == String { - let keychain = Keychain() + let keychain: Keychain let encoder = JSONEncoder() let decoder = JSONDecoder() + init(service: String) { + self.keychain = Keychain(service: service) + } + func get(_ key: K) -> T? { guard let data = try? keychain.getData(key.rawValue) else { return nil } return try? decoder.decode(T.self, from: data) diff --git a/BroadcastExt/BroadcastExt.entitlements b/iOS/BroadcastExt/BroadcastExt.entitlements similarity index 100% rename from BroadcastExt/BroadcastExt.entitlements rename to iOS/BroadcastExt/BroadcastExt.entitlements diff --git a/BroadcastExt/Info.plist b/iOS/BroadcastExt/Info.plist similarity index 100% rename from BroadcastExt/Info.plist rename to iOS/BroadcastExt/Info.plist diff --git a/BroadcastExt/SampleHandler.swift b/iOS/BroadcastExt/SampleHandler.swift similarity index 100% rename from BroadcastExt/SampleHandler.swift rename to iOS/BroadcastExt/SampleHandler.swift