From 6839065425b220d52f5548ac0ff424868faf4e04 Mon Sep 17 00:00:00 2001 From: Tyler Thompson Date: Mon, 1 Aug 2022 18:02:29 -0600 Subject: [PATCH 1/6] [fix-209] - Attempt a fix for #209 - TT --- .../Views/WorkflowItemWrapper.swift | 14 ++++++++------ .../GenericConstraintTests.swift | 2 +- .../SwiftCurrent_SwiftUITests.swift | 2 +- ...Current_SwiftUI_WorkflowBuilderArityTests.swift | 2 +- ...SwiftCurrent_SwiftUI_WorkflowBuilderTests.swift | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift index 2f3b49c73..2b6b796c9 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift @@ -35,12 +35,14 @@ public struct WorkflowItemWrapper Date: Sat, 13 Aug 2022 12:57:48 -0600 Subject: [PATCH 2/6] [fix-209] - Track whether a view has displayed so that skipping works better - TT --- .../Protocols/_WorkflowItemProtocol.swift | 3 +++ .../TypeErased/AnyWorkflowItem.swift | 14 ++++++++++++++ .../Views/EitherWorkflowItem.swift | 12 ++++++++++++ .../Views/OptionalWorkflowItem.swift | 5 +++++ .../SwiftCurrent_SwiftUI/Views/WorkflowGroup.swift | 4 ++++ .../SwiftCurrent_SwiftUI/Views/WorkflowItem.swift | 4 ++++ .../Views/WorkflowItemWrapper.swift | 6 +++++- 7 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftCurrent_SwiftUI/Protocols/_WorkflowItemProtocol.swift b/Sources/SwiftCurrent_SwiftUI/Protocols/_WorkflowItemProtocol.swift index 02569bf77..9e749a4b4 100644 --- a/Sources/SwiftCurrent_SwiftUI/Protocols/_WorkflowItemProtocol.swift +++ b/Sources/SwiftCurrent_SwiftUI/Protocols/_WorkflowItemProtocol.swift @@ -19,6 +19,7 @@ public protocol _WorkflowItemProtocol: View where FlowRepresentableType: FlowRep func canDisplay(_ element: AnyWorkflow.Element?) -> Bool mutating func setElementRef(_ element: AnyWorkflow.Element?) func modify(workflow: AnyWorkflow) + func didDisplay(_ element: AnyWorkflow.Element?) -> Bool } @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) @@ -42,4 +43,6 @@ extension Never: _WorkflowItemProtocol { public func canDisplay(_ element: AnyWorkflow.Element?) -> Bool { false } /// :nodoc: Protocol requirement. public func modify(workflow: AnyWorkflow) { } + /// :nodoc: Protocol requirement. + public func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { false } } diff --git a/Sources/SwiftCurrent_SwiftUI/TypeErased/AnyWorkflowItem.swift b/Sources/SwiftCurrent_SwiftUI/TypeErased/AnyWorkflowItem.swift index deb47a17f..78fbe2b7d 100644 --- a/Sources/SwiftCurrent_SwiftUI/TypeErased/AnyWorkflowItem.swift +++ b/Sources/SwiftCurrent_SwiftUI/TypeErased/AnyWorkflowItem.swift @@ -45,6 +45,11 @@ extension AnyWorkflowItem { public func modify(workflow: AnyWorkflow) { storage.modify(workflow: workflow) } + + /// :nodoc: Protocol requirement. + public func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + storage.didDisplay(element) + } } @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) @@ -59,6 +64,11 @@ fileprivate class AnyWorkflowItemStorageBase { fatalError("AnyWorkflowItemStorageBase called directly, only available internally so something has gone VERY wrong.") } + // swiftlint:disable:next unavailable_function + func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + fatalError("AnyWorkflowItemStorageBase called directly, only available internally so something has gone VERY wrong.") + } + var workflowLaunchStyle: LaunchStyle.SwiftUI.PresentationType { fatalError("AnyWorkflowItemStorageBase called directly, only available internally so something has gone VERY wrong.") } @@ -79,6 +89,10 @@ fileprivate final class AnyWorkflowItemStorage: holder.modify(workflow: workflow) } + override func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + holder.didDisplay(element) + } + override var workflowLaunchStyle: LaunchStyle.SwiftUI.PresentationType { holder.workflowLaunchStyle } diff --git a/Sources/SwiftCurrent_SwiftUI/Views/EitherWorkflowItem.swift b/Sources/SwiftCurrent_SwiftUI/Views/EitherWorkflowItem.swift index 52e547ea6..fd18da1c8 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/EitherWorkflowItem.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/EitherWorkflowItem.swift @@ -34,6 +34,13 @@ public struct EitherWorkflowItem Bool { + switch self { + case .first(let first): return first.didDisplay(element) + case .second(let second): return second.didDisplay(element) + } + } + case first(First) case second(Second) @@ -59,6 +66,11 @@ public struct EitherWorkflowItem Bool { content.canDisplay(element) } + + /// :nodoc: Protocol requirement. + public func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + content.didDisplay(element) + } } @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) diff --git a/Sources/SwiftCurrent_SwiftUI/Views/OptionalWorkflowItem.swift b/Sources/SwiftCurrent_SwiftUI/Views/OptionalWorkflowItem.swift index a9b6fdc3c..21eb7cf71 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/OptionalWorkflowItem.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/OptionalWorkflowItem.swift @@ -30,6 +30,11 @@ public struct OptionalWorkflowItem: View, _WorkflowIt public func canDisplay(_ element: AnyWorkflow.Element?) -> Bool { content?.canDisplay(element) ?? false } + + /// :nodoc: Protocol requirement. + public func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + content?.didDisplay(element) ?? false + } } @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowGroup.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowGroup.swift index fc1ec8787..31dab1011 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowGroup.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowGroup.swift @@ -26,6 +26,10 @@ public struct WorkflowGroup: View, _WorkflowItemProto public func canDisplay(_ element: AnyWorkflow.Element?) -> Bool { content.canDisplay(element) } + + public func didDisplay(_ element: AnyWorkflow.Element?) -> Bool { + content.didDisplay(element) + } } @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItem.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItem.swift index 18569da47..3fa2140b4 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItem.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItem.swift @@ -57,6 +57,10 @@ public struct WorkflowItem Bool { + (elementRef != nil || elementRef === element) + } + public mutating func setElementRef(_ element: AnyWorkflow.Element?) { if canDisplay(element) { elementRef = element diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift index 2b6b796c9..0a5d7b77c 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift @@ -35,7 +35,7 @@ public struct WorkflowItemWrapper Bool { + content.didDisplay(element) || wrapped?.canDisplay(element) == true + } + public func modify(workflow: AnyWorkflow) { content.modify(workflow: workflow) wrapped?.modify(workflow: workflow) From 332d18a07e7eed3f5ac656922d903160ed8fb50b Mon Sep 17 00:00:00 2001 From: Tyler Thompson Date: Sat, 13 Aug 2022 13:51:57 -0600 Subject: [PATCH 3/6] [fix-209] - Linting works and a test that is failing for the wrong reasons is skipped - TT --- .../SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift | 1 + .../SwiftCurrent_SwiftUI/ResultBuilders/WorkflowBuilder.swift | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift index 154a2a92f..c9475df0a 100644 --- a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift +++ b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift @@ -59,6 +59,7 @@ final class UIKitInteropTests: XCTestCase, View { } func testPuttingAUIKitViewInsideASwiftUIWorkflowWithOtherSwiftUIViews() async throws { + throw XCTSkip("Issue with environment objects being read, functionality appears to still work") struct FR1: View, FlowRepresentable, Inspectable { weak var _workflowPointer: AnyFlowRepresentable? let str: String diff --git a/Sources/SwiftCurrent_SwiftUI/ResultBuilders/WorkflowBuilder.swift b/Sources/SwiftCurrent_SwiftUI/ResultBuilders/WorkflowBuilder.swift index c9c53a16e..222e8afe0 100644 --- a/Sources/SwiftCurrent_SwiftUI/ResultBuilders/WorkflowBuilder.swift +++ b/Sources/SwiftCurrent_SwiftUI/ResultBuilders/WorkflowBuilder.swift @@ -5,8 +5,6 @@ // Created by Tyler Thompson on 2/21/22. // Copyright © 2022 WWT and Tyler Thompson. All rights reserved. // swiftlint:disable line_length -// swiftlint:disable operator_usage_whitespace -// swiftlint BUG: https://github.com/realm/SwiftLint/issues/3668 import Foundation From 87e43a266db69c03de10561205866ba22f7c92e6 Mon Sep 17 00:00:00 2001 From: Tyler Thompson Date: Sat, 13 Aug 2022 14:17:23 -0600 Subject: [PATCH 4/6] [fix-209] - Tried explicitly passing the model so that ViewInspector is happy - TT --- .github/fastlane/Fastfile | 30 ++++++++----------- .github/fastlane/README.md | 21 ++++++++----- .github/workflows/CI.yml | 7 +---- .github/workflows/PR_CI.yml | 7 +---- .../Views/WorkflowItemWrapper.swift | 1 + 5 files changed, 29 insertions(+), 37 deletions(-) diff --git a/.github/fastlane/Fastfile b/.github/fastlane/Fastfile index b91f24ea0..32b79be17 100644 --- a/.github/fastlane/Fastfile +++ b/.github/fastlane/Fastfile @@ -35,23 +35,6 @@ platform :ios do end end - lane :CLI_test do - Dir.chdir("..") do - setup_ci() - match( - app_identifier: ["WWT.SwiftCurrent-IRGeneratorTests"], - readonly: is_ci, - git_url: "git@github.com:wwt/swiftcurrent-ios-certs-and-profiles.git" - ) - xcodebuild( - test: true, - scheme: 'SwiftCurrent_CLI', - workspace: 'SwiftCurrent.xcworkspace', - destination: [ 'platform=macOS' ] - ) - end - end - lane :build_swiftpm do # Confirm Core can build against Swift without any Apple SDK requirements sh('rm -rf ../../SwiftCurrent.xcworkspace/') @@ -144,3 +127,16 @@ platform :ios do echo(message: "##[set-output name=version;]#{version}") end end + +platform :macOS do + lane :CLI_test do + scan( + code_coverage: true, + scheme: 'SwiftCurrent_CLI', + workspace: '../SwiftCurrent.xcworkspace', + derived_data_path: "~/Library/Developer/Xcode/DerivedData", + result_bundle: true, + destination: "platform=macOS" + ) + end +end \ No newline at end of file diff --git a/.github/fastlane/README.md b/.github/fastlane/README.md index 3b3346f0b..4da59ae78 100644 --- a/.github/fastlane/README.md +++ b/.github/fastlane/README.md @@ -31,14 +31,6 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do -### ios CLI_test - -```sh -[bundle exec] fastlane ios CLI_test -``` - - - ### ios build_swiftpm ```sh @@ -95,6 +87,19 @@ Release a new version with a minor bump_type Release a new version with a major bump_type +---- + + +## macOS + +### macOS CLI_test + +```sh +[bundle exec] fastlane macOS CLI_test +``` + + + ---- This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c741de3d6..9006f512d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -44,17 +44,12 @@ jobs: env: working-directory: .github DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_DEPLOY_KEY: ${{ secrets.MATCH_DEPLOY_KEY }} GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" - MATCH_READONLY: true steps: - uses: actions/checkout@v2 - name: Run CLI TESTS run: | - eval "$(ssh-agent -s)" - ssh-add - <<< "${MATCH_DEPLOY_KEY}" - bundle exec fastlane CLI_test + bundle exec fastlane macOS CLI_test working-directory: ${{ env.working-directory }} build_for_swift_package_manager: diff --git a/.github/workflows/PR_CI.yml b/.github/workflows/PR_CI.yml index 440354dba..164626f5b 100644 --- a/.github/workflows/PR_CI.yml +++ b/.github/workflows/PR_CI.yml @@ -41,17 +41,12 @@ jobs: env: working-directory: .github DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_DEPLOY_KEY: ${{ secrets.MATCH_DEPLOY_KEY }} GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" - MATCH_READONLY: true steps: - uses: actions/checkout@v2 - name: Run CLI TESTS run: | - eval "$(ssh-agent -s)" - ssh-add - <<< "${MATCH_DEPLOY_KEY}" - bundle exec fastlane CLI_test + bundle exec fastlane macOS CLI_test working-directory: ${{ env.working-directory }} build_for_swift_package_manager: diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift index 0a5d7b77c..0a67ce8d5 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift @@ -47,6 +47,7 @@ public struct WorkflowItemWrapper Date: Sat, 13 Aug 2022 14:34:26 -0600 Subject: [PATCH 5/6] [fix-209] - Stop trying to sign a unit test target...come on - TT --- .../SwiftCurrentLint.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/SwiftCurrentLint/SwiftCurrentLint.xcodeproj/project.pbxproj b/.github/SwiftCurrentLint/SwiftCurrentLint.xcodeproj/project.pbxproj index b109fb1da..b5bb45b14 100644 --- a/.github/SwiftCurrentLint/SwiftCurrentLint.xcodeproj/project.pbxproj +++ b/.github/SwiftCurrentLint/SwiftCurrentLint.xcodeproj/project.pbxproj @@ -347,7 +347,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = KRX3M99K22; @@ -367,7 +367,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = KRX3M99K22; From 4d11119fd676e90e0ad763a0f8f84d181c822a3d Mon Sep 17 00:00:00 2001 From: Tyler Thompson Date: Sat, 13 Aug 2022 14:57:37 -0600 Subject: [PATCH 6/6] [fix-209] - Refactor WorkflowItemWrapper to reduce view graph complexity - TT --- .github/fastlane/Fastfile | 2 +- .github/workflows/CI.yml | 2 +- .github/workflows/PR_CI.yml | 2 +- .../SwiftUIExampleTests/UIKitInteropTests.swift | 1 - .../Views/WorkflowItemWrapper.swift | 17 ++++++++--------- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/fastlane/Fastfile b/.github/fastlane/Fastfile index 32b79be17..ab7b7e622 100644 --- a/.github/fastlane/Fastfile +++ b/.github/fastlane/Fastfile @@ -128,7 +128,7 @@ platform :ios do end end -platform :macOS do +platform :mac do lane :CLI_test do scan( code_coverage: true, diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9006f512d..5dfd97241 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v2 - name: Run CLI TESTS run: | - bundle exec fastlane macOS CLI_test + bundle exec fastlane mac CLI_test working-directory: ${{ env.working-directory }} build_for_swift_package_manager: diff --git a/.github/workflows/PR_CI.yml b/.github/workflows/PR_CI.yml index 164626f5b..244cc21db 100644 --- a/.github/workflows/PR_CI.yml +++ b/.github/workflows/PR_CI.yml @@ -46,7 +46,7 @@ jobs: - uses: actions/checkout@v2 - name: Run CLI TESTS run: | - bundle exec fastlane macOS CLI_test + bundle exec fastlane mac CLI_test working-directory: ${{ env.working-directory }} build_for_swift_package_manager: diff --git a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift index c9475df0a..154a2a92f 100644 --- a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift +++ b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift @@ -59,7 +59,6 @@ final class UIKitInteropTests: XCTestCase, View { } func testPuttingAUIKitViewInsideASwiftUIWorkflowWithOtherSwiftUIViews() async throws { - throw XCTSkip("Issue with environment objects being read, functionality appears to still work") struct FR1: View, FlowRepresentable, Inspectable { weak var _workflowPointer: AnyFlowRepresentable? let str: String diff --git a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift index 0a67ce8d5..e9f62f30f 100644 --- a/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift +++ b/Sources/SwiftCurrent_SwiftUI/Views/WorkflowItemWrapper.swift @@ -35,19 +35,18 @@ public struct WorkflowItemWrapper