From 284aa09a473eb16b6cb7908c975d77ac766c4607 Mon Sep 17 00:00:00 2001 From: Alexandr Romanov Date: Fri, 27 Sep 2024 00:42:12 +0300 Subject: [PATCH] Upd ci (#1) Fix tvOS --- .github/workflows/ci.yml | 22 ++++++--- Package.swift | 11 +++-- .../RoutingViews/RoutingSidebarView.swift | 48 +++++++++---------- .../RoutingViews/RoutingSplitView.swift | 8 ++++ 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 891df34..3690f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI on: push: - branches: ["main"] + branches: + - '**' workflow_dispatch: jobs: @@ -10,8 +11,16 @@ jobs: build-swiftpm: name: Build SwiftPM uses: oversizedev/GithubWorkflows/.github/workflows/build-swiftpm.yml@main + strategy: + matrix: + destination: + - platform=iOS Simulator,name=iPhone 16,OS=18.0 + - platform=watchOS Simulator,name=Apple Watch SE (40mm) (2nd generation),OS=11.0 + - platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=18.0 + - platform=macOS,arch=arm64 with: - package: "OversizeRouter" + package: OversizeRouter + destination: ${{ matrix.destination }} secrets: inherit # tests: @@ -21,7 +30,8 @@ jobs: # secrets: inherit bump: - name: Bump version - needs: build-swiftpm - uses: oversizedev/GithubWorkflows/.github/workflows/bump.yml@main - secrets: inherit + name: Bump version + needs: build-swiftpm + if: github.ref == 'refs/heads/main' + uses: oversizedev/GithubWorkflows/.github/workflows/bump.yml@main + secrets: inherit diff --git a/Package.swift b/Package.swift index 639ec74..8f4af43 100644 --- a/Package.swift +++ b/Package.swift @@ -2,8 +2,9 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription +import Foundation -let productionDependencies: [PackageDescription.Package.Dependency] = [ +let remoteDependencies: [PackageDescription.Package.Dependency] = [ .package(url: "https://github.com/oversizedev/OversizeUI.git", .upToNextMajor(from: "3.0.2")), .package(url: "https://github.com/oversizedev/OversizeServices.git", .upToNextMajor(from: "1.4.0")), .package(url: "https://github.com/oversizedev/OversizeModels.git", .upToNextMajor(from: "0.1.0")), @@ -11,7 +12,7 @@ let productionDependencies: [PackageDescription.Package.Dependency] = [ .package(url: "https://github.com/oversizedev/OversizeLocalizable.git", .upToNextMajor(from: "1.5.0")), ] -let developmentDependencies: [PackageDescription.Package.Dependency] = [ +let localDependencies: [PackageDescription.Package.Dependency] = [ .package(name: "OversizeUI", path: "../OversizeUI"), .package(name: "OversizeServices", path: "../OversizeServices"), .package(name: "OversizeModels", path: "../OversizeModels"), @@ -19,7 +20,11 @@ let developmentDependencies: [PackageDescription.Package.Dependency] = [ .package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")), ] -let dependencies: [PackageDescription.Package.Dependency] = developmentDependencies +var dependencies: [PackageDescription.Package.Dependency] = localDependencies + +if ProcessInfo.processInfo.environment["BUILD_MODE"] == "PRODUCTION" { + dependencies = remoteDependencies +} let package = Package( name: "OversizeRouter", diff --git a/Sources/OversizeRouter/RoutingViews/RoutingSidebarView.swift b/Sources/OversizeRouter/RoutingViews/RoutingSidebarView.swift index 114af8b..e6a883a 100644 --- a/Sources/OversizeRouter/RoutingViews/RoutingSidebarView.swift +++ b/Sources/OversizeRouter/RoutingViews/RoutingSidebarView.swift @@ -20,35 +20,33 @@ public struct RoutingSidebarView: View where Tab: TabableView { } public var body: some View { - if #available(macOS 15.0, iOS 18.0, *) { - TabView(selection: $router.selection) { - ForEach(router.tabs) { tab in - tab.view() - .tag(tab) - .tabItem { - tab.icon - Text(tab.title) - } - .environment(router) - .environment(hudRouter) - } - } + #if os(iOS) || os(macOS) || os(tvOS) || os(visionOS) + if #available(iOS 18.0, macOS 15.0, tvOS 18.0, visionOS 2.0, *) { + tabView .tabViewStyle(.sidebarAdaptable) .hud(hudRouter.hudText, isPresented: $hudRouter.isShowHud) } else { - TabView(selection: $router.selection) { - ForEach(router.tabs) { tab in - tab.view() - .tag(tab) - .tabItem { - tab.icon - Text(tab.title) - } - .environment(router) - .environment(hudRouter) - } - } + tabView .hud(hudRouter.hudText, isPresented: $hudRouter.isShowHud) } + #else + + tabView + #endif + } + + var tabView: some View { + TabView(selection: $router.selection) { + ForEach(router.tabs) { tab in + tab.view() + .tag(tab) + .tabItem { + tab.icon + Text(tab.title) + } + .environment(router) + .environment(hudRouter) + } + } } } diff --git a/Sources/OversizeRouter/RoutingViews/RoutingSplitView.swift b/Sources/OversizeRouter/RoutingViews/RoutingSplitView.swift index dbdddfc..2a4babf 100644 --- a/Sources/OversizeRouter/RoutingViews/RoutingSplitView.swift +++ b/Sources/OversizeRouter/RoutingViews/RoutingSplitView.swift @@ -57,6 +57,14 @@ public struct RoutingSplitView: View where Tab: } } .listStyle(.sidebar) + #elseif os(watchOS) || os(tvOS) + List { + ForEach(router.tabs) { menu in + NavigationLink(value: menu) { + Text(menu.title) + } + } + } #else List(selection: $router.selection) { topSidebar