From c86795a7c8aefa784ff6982c92bfdfb4fca38a54 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:59:20 +0900 Subject: [PATCH] Update for v2 (#3) --- .github/workflows/testing-matrix.yaml | 48 +++++ .../xcshareddata/swiftpm/Package.resolved | 186 +++++++++--------- .../project.pbxproj | 144 +++++++++++++- .../LiveKitLivestreamExampleTests.swift | 42 ++++ Shared/API.swift | 10 +- Shared/App.swift | 2 +- Shared/Contexts/AppContext.swift | 2 +- Shared/Contexts/RoomContext.swift | 30 ++- Shared/Extensions/HideKeyboard.swift | 2 +- Shared/MainView.swift | 2 +- Shared/Sheets/OptionsSheet.swift | 2 +- Shared/Sheets/UsersSheet.swift | 2 +- Shared/StreamView.swift | 2 +- Shared/StreamerPrepareView.swift | 12 +- Shared/Types/ChatMessage.swift | 2 +- Shared/Types/ConnectionDetails.swift | 2 +- Shared/Types/CreateStream.swift | 2 +- Shared/Types/InviteToStage.swift | 2 +- Shared/Types/JoinStream.swift | 2 +- Shared/Types/LivestreamError.swift | 2 +- Shared/Types/ParticipantMetadata.swift | 2 +- Shared/Types/RoomMetadata.swift | 2 +- Shared/Types/StreamEvent.swift | 2 +- Shared/ViewerPrepareView.swift | 12 +- Shared/Views/MessageBarView.swift | 5 +- Shared/Views/PublisherVideoView.swift | 2 +- Shared/Views/StreamEventTileView.swift | 6 +- Shared/Views/StreamEventsListView.swift | 2 +- Shared/Views/StyledButton.swift | 2 +- Shared/Views/StyledTextField.swift | 2 +- Shared/Views/SwitchCameraButton.swift | 2 +- Shared/Views/TextLabel.swift | 2 +- Shared/Views/UserTileView.swift | 10 +- Shared/WelcomeView.swift | 2 +- 34 files changed, 384 insertions(+), 167 deletions(-) create mode 100644 .github/workflows/testing-matrix.yaml create mode 100644 LiveKitLivestreamExampleTests/LiveKitLivestreamExampleTests.swift diff --git a/.github/workflows/testing-matrix.yaml b/.github/workflows/testing-matrix.yaml new file mode 100644 index 0000000..5d824a3 --- /dev/null +++ b/.github/workflows/testing-matrix.yaml @@ -0,0 +1,48 @@ +name: Testing Matrix + +on: + workflow_dispatch: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + run_all_tests: + strategy: + fail-fast: false + matrix: + xcode-version: [14.2, 15.2] + destination: ['platform=iOS Simulator,OS=17.2,name=iPhone 14 Pro', 'platform=macOS', 'platform=macOS,variant=Mac Catalyst'] + + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode-version }} + + - name: Xcode Version + run: xcodebuild -version + + - name: Show SDKs + run: xcodebuild -showsdks + + # TODO: Add step to install iOS 13 + # - name: Install iOS 13 + # run: xcversion simulators --install='iOS 13.0' + + # - name: Download iOS platforms + # run: xcodebuild -downloadPlatform iOS + + - name: Show Destinations + run: xcodebuild -scheme LiveKitLivestreamExample -showdestinations + + - name: Run All Tests + run: xcodebuild test -project ./LiveKitLivestreamExample.xcodeproj -scheme LiveKitLivestreamExample -destination '${{ matrix.destination }}' diff --git a/LiveKitLivestreamExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LiveKitLivestreamExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved index b791ed7..7d227fc 100644 --- a/LiveKitLivestreamExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LiveKitLivestreamExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,97 +1,95 @@ { - "object": { - "pins": [ - { - "package": "AlertToast", - "repositoryURL": "https://github.com/elai950/AlertToast", - "state": { - "branch": null, - "revision": "b39252eacd159904afd7d718bba0afabb87f2f2f", - "version": "1.3.9" - } - }, - { - "package": "Nuke", - "repositoryURL": "https://github.com/kean/Nuke", - "state": { - "branch": null, - "revision": "8ecbfc886da39bccb01c34abef5f2ff4073ad633", - "version": "12.4.0" - } - }, - { - "package": "SFSafeSymbols", - "repositoryURL": "https://github.com/SFSafeSymbols/SFSafeSymbols.git", - "state": { - "branch": null, - "revision": "7cca2d60925876b5953a2cf7341cd80fbeac983c", - "version": "4.1.1" - } - }, - { - "package": "SwiftDocCPlugin", - "repositoryURL": "https://github.com/apple/swift-docc-plugin.git", - "state": { - "branch": null, - "revision": "26ac5758409154cc448d7ab82389c520fa8a8247", - "version": "1.3.0" - } - }, - { - "package": "SymbolKit", - "repositoryURL": "https://github.com/apple/swift-docc-symbolkit", - "state": { - "branch": null, - "revision": "b45d1f2ed151d057b54504d653e0da5552844e34", - "version": "1.0.0" - } - }, - { - "package": "swift-log", - "repositoryURL": "https://github.com/apple/swift-log", - "state": { - "branch": null, - "revision": "e97a6fcb1ab07462881ac165fdbb37f067e205d5", - "version": "1.5.4" - } - }, - { - "package": "SwiftProtobuf", - "repositoryURL": "https://github.com/apple/swift-protobuf.git", - "state": { - "branch": null, - "revision": "65e8f29b2d63c4e38e736b25c27b83e012159be8", - "version": "1.25.2" - } - }, - { - "package": "SwiftBackports", - "repositoryURL": "https://github.com/shaps80/SwiftBackports", - "state": { - "branch": null, - "revision": "ddca6a237c1ba2291d5a3cc47ec8480ce6e9f805", - "version": "1.0.3" - } - }, - { - "package": "SwiftUIBackports", - "repositoryURL": "https://github.com/shaps80/SwiftUIBackports", - "state": { - "branch": null, - "revision": "3042f0cf4b9f0d5b0bb08ad17f742a43bc4fdfc5", - "version": "2.8.0" - } - }, - { - "package": "WebRTC", - "repositoryURL": "https://github.com/livekit/webrtc-xcframework.git", - "state": { - "branch": null, - "revision": "da80ea5be0a2b92ca805ab7ee9ad191f6d938a5f", - "version": "114.5735.10" - } + "pins" : [ + { + "identity" : "alerttoast", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elai950/AlertToast", + "state" : { + "revision" : "b39252eacd159904afd7d718bba0afabb87f2f2f", + "version" : "1.3.9" } - ] - }, - "version": 1 + }, + { + "identity" : "nuke", + "kind" : "remoteSourceControl", + "location" : "https://github.com/kean/Nuke", + "state" : { + "revision" : "8ecbfc886da39bccb01c34abef5f2ff4073ad633", + "version" : "12.4.0" + } + }, + { + "identity" : "sfsafesymbols", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SFSafeSymbols/SFSafeSymbols.git", + "state" : { + "revision" : "7cca2d60925876b5953a2cf7341cd80fbeac983c", + "version" : "4.1.1" + } + }, + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin.git", + "state" : { + "revision" : "26ac5758409154cc448d7ab82389c520fa8a8247", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log", + "state" : { + "revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5", + "version" : "1.5.4" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8", + "version" : "1.25.2" + } + }, + { + "identity" : "swiftbackports", + "kind" : "remoteSourceControl", + "location" : "https://github.com/shaps80/SwiftBackports", + "state" : { + "revision" : "ddca6a237c1ba2291d5a3cc47ec8480ce6e9f805", + "version" : "1.0.3" + } + }, + { + "identity" : "swiftuibackports", + "kind" : "remoteSourceControl", + "location" : "https://github.com/shaps80/SwiftUIBackports", + "state" : { + "revision" : "3042f0cf4b9f0d5b0bb08ad17f742a43bc4fdfc5", + "version" : "2.8.0" + } + }, + { + "identity" : "webrtc-xcframework", + "kind" : "remoteSourceControl", + "location" : "https://github.com/livekit/webrtc-xcframework.git", + "state" : { + "revision" : "56e5119f00daa2e42e10670d29ae2edbff6be961", + "version" : "114.5735.13" + } + } + ], + "version" : 2 } diff --git a/LiveKitLivestreamExample.xcodeproj/project.pbxproj b/LiveKitLivestreamExample.xcodeproj/project.pbxproj index f8b72a8..ed2d06b 100644 --- a/LiveKitLivestreamExample.xcodeproj/project.pbxproj +++ b/LiveKitLivestreamExample.xcodeproj/project.pbxproj @@ -41,6 +41,7 @@ 68A108C72A5CFC2E00200FAE /* HideKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A108C62A5CFC2E00200FAE /* HideKeyboard.swift */; }; 68D594E42A78B1C500ABBD2C /* AlertToast in Frameworks */ = {isa = PBXBuildFile; productRef = 68D594E32A78B1C500ABBD2C /* AlertToast */; }; 68D594E82A78C67500ABBD2C /* NukeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 68D594E72A78C67500ABBD2C /* NukeUI */; }; + 68E21C8A2B8CCC440079CD03 /* LiveKitLivestreamExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E21C892B8CCC440079CD03 /* LiveKitLivestreamExampleTests.swift */; }; 68F4BE9A2A76903500E847F9 /* ChatMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68F4BE992A76903500E847F9 /* ChatMessage.swift */; }; 68FBA36F2A381A530015853E /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68FBA36E2A381A530015853E /* WelcomeView.swift */; }; 68FBA3712A381F650015853E /* StyledButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68FBA3702A381F650015853E /* StyledButton.swift */; }; @@ -48,6 +49,16 @@ 68FBA3752A3824D80015853E /* StyledTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68FBA3742A3824D80015853E /* StyledTextField.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 68E21C8B2B8CCC440079CD03 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 683865992A29F9A3005D0947 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 683865A02A29F9A3005D0947; + remoteInfo = LiveKitLivestreamExample; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 6801A7652A3900CD009FC4DA /* ViewerPrepareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewerPrepareView.swift; sourceTree = ""; }; 6801A7672A3903E2009FC4DA /* LiveKitLivestreamExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "LiveKitLivestreamExample-Info.plist"; sourceTree = ""; }; @@ -79,6 +90,8 @@ 68928F8E2A40CB9C005F084A /* StreamEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamEvent.swift; sourceTree = ""; }; 6895EA462A38B85000519535 /* macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = macOS.entitlements; sourceTree = ""; }; 68A108C62A5CFC2E00200FAE /* HideKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideKeyboard.swift; sourceTree = ""; }; + 68E21C872B8CCC440079CD03 /* LiveKitLivestreamExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LiveKitLivestreamExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 68E21C892B8CCC440079CD03 /* LiveKitLivestreamExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveKitLivestreamExampleTests.swift; sourceTree = ""; }; 68F4BE992A76903500E847F9 /* ChatMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessage.swift; sourceTree = ""; }; 68FBA36E2A381A530015853E /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = ""; }; 68FBA3702A381F650015853E /* StyledButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyledButton.swift; sourceTree = ""; }; @@ -101,6 +114,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 68E21C842B8CCC440079CD03 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -119,6 +139,7 @@ 6801A7672A3903E2009FC4DA /* LiveKitLivestreamExample-Info.plist */, 6895EA452A38B82100519535 /* macOS */, 683865A32A29F9A3005D0947 /* Shared */, + 68E21C882B8CCC440079CD03 /* LiveKitLivestreamExampleTests */, 683865A22A29F9A3005D0947 /* Products */, 687E311F2A2DCAC500032AE6 /* Frameworks */, ); @@ -128,6 +149,7 @@ isa = PBXGroup; children = ( 683865A12A29F9A3005D0947 /* LK Live.app */, + 68E21C872B8CCC440079CD03 /* LiveKitLivestreamExampleTests.xctest */, ); name = Products; sourceTree = ""; @@ -225,6 +247,14 @@ path = Extensions; sourceTree = ""; }; + 68E21C882B8CCC440079CD03 /* LiveKitLivestreamExampleTests */ = { + isa = PBXGroup; + children = ( + 68E21C892B8CCC440079CD03 /* LiveKitLivestreamExampleTests.swift */, + ); + path = LiveKitLivestreamExampleTests; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -254,6 +284,24 @@ productReference = 683865A12A29F9A3005D0947 /* LK Live.app */; productType = "com.apple.product-type.application"; }; + 68E21C862B8CCC440079CD03 /* LiveKitLivestreamExampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 68E21C8D2B8CCC440079CD03 /* Build configuration list for PBXNativeTarget "LiveKitLivestreamExampleTests" */; + buildPhases = ( + 68E21C832B8CCC440079CD03 /* Sources */, + 68E21C842B8CCC440079CD03 /* Frameworks */, + 68E21C852B8CCC440079CD03 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 68E21C8C2B8CCC440079CD03 /* PBXTargetDependency */, + ); + name = LiveKitLivestreamExampleTests; + productName = LiveKitLivestreamExampleTests; + productReference = 68E21C872B8CCC440079CD03 /* LiveKitLivestreamExampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -261,12 +309,16 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1430; + LastSwiftUpdateCheck = 1520; LastUpgradeCheck = 1430; TargetAttributes = { 683865A02A29F9A3005D0947 = { CreatedOnToolsVersion = 14.3; }; + 68E21C862B8CCC440079CD03 = { + CreatedOnToolsVersion = 15.2; + TestTargetID = 683865A02A29F9A3005D0947; + }; }; }; buildConfigurationList = 6838659C2A29F9A3005D0947 /* Build configuration list for PBXProject "LiveKitLivestreamExample" */; @@ -290,6 +342,7 @@ projectRoot = ""; targets = ( 683865A02A29F9A3005D0947 /* LiveKitLivestreamExample */, + 68E21C862B8CCC440079CD03 /* LiveKitLivestreamExampleTests */, ); }; /* End PBXProject section */ @@ -304,6 +357,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 68E21C852B8CCC440079CD03 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -344,8 +404,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 68E21C832B8CCC440079CD03 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 68E21C8A2B8CCC440079CD03 /* LiveKitLivestreamExampleTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 68E21C8C2B8CCC440079CD03 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 683865A02A29F9A3005D0947 /* LiveKitLivestreamExample */; + targetProxy = 68E21C8B2B8CCC440079CD03 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 683865AE2A29F9A4005D0947 /* Debug */ = { isa = XCBuildConfiguration; @@ -494,7 +570,7 @@ PRODUCT_NAME = "LK Live"; SDKROOT = auto; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -538,7 +614,7 @@ PRODUCT_NAME = "LK Live"; SDKROOT = auto; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -546,6 +622,59 @@ }; name = Release; }; + 68E21C8E2B8CCC440079CD03 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 76TVFCUKK7; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.livekit.LiveKitLivestreamExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LK Live.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LK Live"; + }; + name = Debug; + }; + 68E21C8F2B8CCC440079CD03 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 76TVFCUKK7; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.livekit.LiveKitLivestreamExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LK Live.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LK Live"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -567,6 +696,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 68E21C8D2B8CCC440079CD03 /* Build configuration list for PBXNativeTarget "LiveKitLivestreamExampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68E21C8E2B8CCC440079CD03 /* Debug */, + 68E21C8F2B8CCC440079CD03 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ diff --git a/LiveKitLivestreamExampleTests/LiveKitLivestreamExampleTests.swift b/LiveKitLivestreamExampleTests/LiveKitLivestreamExampleTests.swift new file mode 100644 index 0000000..9d1bb3c --- /dev/null +++ b/LiveKitLivestreamExampleTests/LiveKitLivestreamExampleTests.swift @@ -0,0 +1,42 @@ +/* + * Copyright 2024 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XCTest + +final class LiveKitLivestreamExampleTests: XCTestCase { + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + measure { + // Put the code you want to measure the time of here. + } + } +} diff --git a/Shared/API.swift b/Shared/API.swift index 43fff30..6a0744b 100644 --- a/Shared/API.swift +++ b/Shared/API.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,15 +101,15 @@ class API { try await post(apiPath: "/api/stop_stream") } - public func inviteToStage(identity: String) async throws { + public func inviteToStage(identity: Participant.Identity) async throws { assert(authToken != nil) - let p = InviteToStageRequest(identity: identity) + let p = InviteToStageRequest(identity: identity.stringValue) try await post(apiPath: "/api/invite_to_stage", data: p) } - public func removeFromStage(identity: String? = nil) async throws { + public func removeFromStage(identity: Participant.Identity? = nil) async throws { assert(authToken != nil) - let p = InviteToStageRequest(identity: identity) + let p = InviteToStageRequest(identity: identity?.stringValue) try await post(apiPath: "/api/remove_from_stage", data: p) } diff --git a/Shared/App.swift b/Shared/App.swift index 6d7b94b..a5e4f9c 100644 --- a/Shared/App.swift +++ b/Shared/App.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Contexts/AppContext.swift b/Shared/Contexts/AppContext.swift index 9c7077d..2d51374 100644 --- a/Shared/Contexts/AppContext.swift +++ b/Shared/Contexts/AppContext.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Contexts/RoomContext.swift b/Shared/Contexts/RoomContext.swift index 5ee1cc8..ae27bc9 100644 --- a/Shared/Contexts/RoomContext.swift +++ b/Shared/Contexts/RoomContext.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ final class RoomContext: NSObject, ObservableObject { // Network busy states @Published public var connectBusy = false @Published public var endStreamBusy = false - @Published public var inviteBusy: Set = [] + @Published public var inviteBusy: Set = [] @Published public private(set) var step: Step = .welcome @Published public var events = [ChatMessage]() @@ -62,7 +62,7 @@ final class RoomContext: NSObject, ObservableObject { // Computed helpers public var isStreamOwner: Bool { - room.typedMetadata.creatorIdentity == room.localParticipant.identity + room.typedMetadata.creatorIdentity == room.localParticipant.identity?.stringValue } public var isStreamHost: Bool { @@ -98,7 +98,7 @@ final class RoomContext: NSObject, ObservableObject { do { // Ensure permissions... - guard await LiveKit.ensureDeviceAccess(for: [.video, .audio]) else { + guard await LiveKitSDK.ensureDeviceAccess(for: [.video, .audio]) else { // Both .video and .audio device permissions are required... throw LivestreamError.permissions } @@ -181,7 +181,7 @@ final class RoomContext: NSObject, ObservableObject { } } - public func inviteToStage(identity: String) { + public func inviteToStage(identity: Participant.Identity) { Task { Task { @MainActor in inviteBusy.insert(identity) } defer { Task { @MainActor in inviteBusy.remove(identity) } } @@ -195,7 +195,7 @@ final class RoomContext: NSObject, ObservableObject { } } - public func removeFromStage(identity: String? = nil) { + public func removeFromStage(identity: Participant.Identity? = nil) { Task { do { logger.info("Removing from stage \(String(describing: identity))...") @@ -239,13 +239,13 @@ final class RoomContext: NSObject, ObservableObject { message = "" guard let jsonData = try? encoder.encode(chatMessage) else { return } - try await room.localParticipant.publish(data: jsonData, topic: RoomContext.chatTopic) + try await room.localParticipant.publish(data: jsonData, options: DataPublishOptions(topic: RoomContext.chatTopic)) } } } extension RoomContext: RoomDelegate { - func room(_: Room, participant: RemoteParticipant?, didReceiveData data: Data, topic: String) { + func room(_: Room, participant: RemoteParticipant?, didReceiveData data: Data, forTopic topic: String) { // Check if chat topic guard topic == RoomContext.chatTopic else { return } @@ -256,15 +256,7 @@ extension RoomContext: RoomDelegate { } } - func room(_: Room, didUpdate _: String?) { - // logger.info("room metadata: \()") - } - - func room(_: Room, participant: Participant, didUpdate _: String?) { - logger.info("participant metadata: \(participant.typedMetadata)") - } - - func room(_: Room, didUpdate connectionState: ConnectionState, oldValue: ConnectionState) { + func room(_: Room, didUpdateConnectionState connectionState: ConnectionState, from oldValue: ConnectionState) { if case .disconnected = connectionState, case .connected = oldValue { @@ -285,7 +277,7 @@ extension RoomContext: RoomDelegate { } } - func room(_: Room, participant: Participant, didUpdate _: ParticipantPermissions) { + func room(_: Room, participant: Participant, didUpdatePermissions _: ParticipantPermissions) { if let participant = participant as? LocalParticipant, participant.canPublish { @@ -293,7 +285,7 @@ extension RoomContext: RoomDelegate { Task { do { // Ensure permissions... - guard await LiveKit.ensureDeviceAccess(for: [.video, .audio]) else { + guard await LiveKitSDK.ensureDeviceAccess(for: [.video, .audio]) else { // Both .video and .audio device permissions are required... throw LivestreamError.permissions } diff --git a/Shared/Extensions/HideKeyboard.swift b/Shared/Extensions/HideKeyboard.swift index 5a2c930..7b6aca6 100644 --- a/Shared/Extensions/HideKeyboard.swift +++ b/Shared/Extensions/HideKeyboard.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/MainView.swift b/Shared/MainView.swift index c0a35ea..d5de113 100644 --- a/Shared/MainView.swift +++ b/Shared/MainView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Sheets/OptionsSheet.swift b/Shared/Sheets/OptionsSheet.swift index 64e1ba1..b12e55c 100644 --- a/Shared/Sheets/OptionsSheet.swift +++ b/Shared/Sheets/OptionsSheet.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Sheets/UsersSheet.swift b/Shared/Sheets/UsersSheet.swift index 6acc038..3f7f09e 100644 --- a/Shared/Sheets/UsersSheet.swift +++ b/Shared/Sheets/UsersSheet.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/StreamView.swift b/Shared/StreamView.swift index c3f66fd..411e28e 100644 --- a/Shared/StreamView.swift +++ b/Shared/StreamView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/StreamerPrepareView.swift b/Shared/StreamerPrepareView.swift index da114ba..299c811 100644 --- a/Shared/StreamerPrepareView.swift +++ b/Shared/StreamerPrepareView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ struct StreamerPrepareView: View { @EnvironmentObject var room: Room @State private var showDialog = false - @State private var disconnectReason: DisconnectReason? + @State private var disconnectError: LiveKitError? var body: some View { VStack(alignment: .leading, spacing: 12) { @@ -62,15 +62,15 @@ struct StreamerPrepareView: View { } .padding() .onChange(of: room.connectionState) { _ in - if case let .disconnected(reason) = room.connectionState { - disconnectReason = reason + if case .disconnected = room.connectionState { + disconnectError = room.disconnectError showDialog = true } } .alert(isPresented: $showDialog) { Alert(title: Text("Disconnected"), - message: Text("Reason: " + (disconnectReason != nil - ? String(describing: disconnectReason!) + message: Text("Reason: " + (disconnectError != nil + ? String(describing: disconnectError!) : "Unknown"))) } } diff --git a/Shared/Types/ChatMessage.swift b/Shared/Types/ChatMessage.swift index 38a8dfa..a380441 100644 --- a/Shared/Types/ChatMessage.swift +++ b/Shared/Types/ChatMessage.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/ConnectionDetails.swift b/Shared/Types/ConnectionDetails.swift index dbbad69..9f0ea22 100644 --- a/Shared/Types/ConnectionDetails.swift +++ b/Shared/Types/ConnectionDetails.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/CreateStream.swift b/Shared/Types/CreateStream.swift index 6ece308..d046e96 100644 --- a/Shared/Types/CreateStream.swift +++ b/Shared/Types/CreateStream.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/InviteToStage.swift b/Shared/Types/InviteToStage.swift index e398b68..615ee10 100644 --- a/Shared/Types/InviteToStage.swift +++ b/Shared/Types/InviteToStage.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/JoinStream.swift b/Shared/Types/JoinStream.swift index f379592..4473995 100644 --- a/Shared/Types/JoinStream.swift +++ b/Shared/Types/JoinStream.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/LivestreamError.swift b/Shared/Types/LivestreamError.swift index ebf1f97..36df294 100644 --- a/Shared/Types/LivestreamError.swift +++ b/Shared/Types/LivestreamError.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/ParticipantMetadata.swift b/Shared/Types/ParticipantMetadata.swift index a470ad2..9da06d1 100644 --- a/Shared/Types/ParticipantMetadata.swift +++ b/Shared/Types/ParticipantMetadata.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/RoomMetadata.swift b/Shared/Types/RoomMetadata.swift index 6a799d8..1d4e6d7 100644 --- a/Shared/Types/RoomMetadata.swift +++ b/Shared/Types/RoomMetadata.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Types/StreamEvent.swift b/Shared/Types/StreamEvent.swift index def8ec4..b687e25 100644 --- a/Shared/Types/StreamEvent.swift +++ b/Shared/Types/StreamEvent.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/ViewerPrepareView.swift b/Shared/ViewerPrepareView.swift index faf145c..dc53eca 100644 --- a/Shared/ViewerPrepareView.swift +++ b/Shared/ViewerPrepareView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ struct ViewerPrepareView: View { @EnvironmentObject var room: Room @State private var showDialog = false - @State private var disconnectReason: DisconnectReason? + @State private var disconnectError: LiveKitError? var body: some View { VStack(alignment: .leading, spacing: 12) { @@ -56,15 +56,15 @@ struct ViewerPrepareView: View { } .padding() .onChange(of: room.connectionState) { _ in - if case let .disconnected(reason) = room.connectionState { - disconnectReason = reason + if case .disconnected = room.connectionState { + disconnectError = room.disconnectError showDialog = true } } .alert(isPresented: $showDialog) { Alert(title: Text("Disconnected"), - message: Text("Reason: " + (disconnectReason != nil - ? String(describing: disconnectReason!) + message: Text("Reason: " + (disconnectError != nil + ? String(describing: disconnectError!) : "Unknown"))) } } diff --git a/Shared/Views/MessageBarView.swift b/Shared/Views/MessageBarView.swift index a0445fb..6d7adeb 100644 --- a/Shared/Views/MessageBarView.swift +++ b/Shared/Views/MessageBarView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,6 @@ struct MessageBarView: View { let moreAction: () -> Void var body: some View { - let isCameraEnabled = room.localParticipant.isCameraEnabled() - let isMicEnabled = room.localParticipant.isMicrophoneEnabled() - HStack { TextField("", text: $roomCtx.message, axis: .vertical) .focused($focusFields, equals: .message) diff --git a/Shared/Views/PublisherVideoView.swift b/Shared/Views/PublisherVideoView.swift index eaba378..0119dd0 100644 --- a/Shared/Views/PublisherVideoView.swift +++ b/Shared/Views/PublisherVideoView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/StreamEventTileView.swift b/Shared/Views/StreamEventTileView.swift index c37c37d..0e1fa05 100644 --- a/Shared/Views/StreamEventTileView.swift +++ b/Shared/Views/StreamEventTileView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import SwiftUI func image(for participant: Participant?) -> some View { Group { if let participant { - LazyImage(url: URL(string: "https://api.multiavatar.com/\(participant.identity).png")) { state in + LazyImage(url: URL(string: "https://api.multiavatar.com/\(String(describing: participant.identity?.stringValue)).png")) { state in if let image = state.image { image .resizable() @@ -53,7 +53,7 @@ struct StreamEventTileView: View { VStack(alignment: .leading, spacing: 5) { if let participant = entry.participant { - Text(participant.identity ?? "") + Text(String(describing: participant.identity)) .font(.system(size: 14)) .fontWeight(.bold) .frame(maxWidth: .infinity, alignment: .leading) diff --git a/Shared/Views/StreamEventsListView.swift b/Shared/Views/StreamEventsListView.swift index 891b2de..fa69382 100644 --- a/Shared/Views/StreamEventsListView.swift +++ b/Shared/Views/StreamEventsListView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/StyledButton.swift b/Shared/Views/StyledButton.swift index 17de21c..96e192f 100644 --- a/Shared/Views/StyledButton.swift +++ b/Shared/Views/StyledButton.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/StyledTextField.swift b/Shared/Views/StyledTextField.swift index 4b434b6..be8f3cb 100644 --- a/Shared/Views/StyledTextField.swift +++ b/Shared/Views/StyledTextField.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/SwitchCameraButton.swift b/Shared/Views/SwitchCameraButton.swift index a6db816..8615770 100644 --- a/Shared/Views/SwitchCameraButton.swift +++ b/Shared/Views/SwitchCameraButton.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/TextLabel.swift b/Shared/Views/TextLabel.swift index a7a82eb..cbce943 100644 --- a/Shared/Views/TextLabel.swift +++ b/Shared/Views/TextLabel.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Shared/Views/UserTileView.swift b/Shared/Views/UserTileView.swift index efc18a2..f71780d 100644 --- a/Shared/Views/UserTileView.swift +++ b/Shared/Views/UserTileView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ struct UserTileView: View { } var isCreator: Bool { - room.typedMetadata.creatorIdentity == participant.identity + room.typedMetadata.creatorIdentity == participant.identity?.stringValue } var isCoHost: Bool { @@ -77,7 +77,7 @@ struct UserTileView: View { image(for: participant) .frame(width: 30, height: 30) - Text(participant.identity ?? "") + Text(String(describing: participant.identity)) .font(.system(size: 14, weight: .bold)) if isCreator || isCoHost { @@ -101,7 +101,9 @@ struct UserTileView: View { actionButton(title: participant.invited ? "Cancel" : "Reject", style: .destructive) { - roomCtx.removeFromStage(identity: participant.identity) + if let identity = participant.identity { + roomCtx.removeFromStage(identity: identity) + } } } diff --git a/Shared/WelcomeView.swift b/Shared/WelcomeView.swift index 329a651..31e6d9f 100644 --- a/Shared/WelcomeView.swift +++ b/Shared/WelcomeView.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 LiveKit + * Copyright 2024 LiveKit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.