diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 416b1844..37fddd4a 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -34,7 +34,7 @@ jobs: # OpenSwiftUI-Package is not listed currently # OTHER_SWIFT_FLAGS="-warnings-as-errors" \ AccessLevelOnImport will cause build warning via xcodebuild env: - OPENSWIFTUI_ATTRIBUTEGRAPH: 0 + OPENGRAPH_ATTRIBUTEGRAPH: 0 # Test is currently not supported due to the link issue to PrivateFramework # - name: Build and run tests in debug mode with coverage # run: | diff --git a/Package.resolved b/Package.resolved index 22b65abe..0d13a781 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,7 +15,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenGraph", "state" : { "branch" : "main", - "revision" : "6835ce0972f40ef76f1214dc0efc75ec19082631" + "revision" : "2d795fb606d41db52dea5786cb079f6fc7ae84cb" } }, { diff --git a/Package.swift b/Package.swift index f3b09723..f6704939 100644 --- a/Package.swift +++ b/Package.swift @@ -14,6 +14,7 @@ let openSwiftUITarget = Target.target( "OpenSwiftUIShims", "CoreServices", "UIKitCore", + .product(name: "OpenGraphShims", package: "OpenGraph"), ], swiftSettings: [ .enableExperimentalFeature("AccessLevelOnImport"), @@ -95,25 +96,30 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool { } #if os(macOS) -let attributeGraphCondition = envEnable("OPENSWIFTUI_ATTRIBUTEGRAPH", default: true) +let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true) #else -let attributeGraphCondition = envEnable("OPENSWIFTUI_ATTRIBUTEGRAPH") +let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH") #endif + +extension Target { + func addAGSettings() { + dependencies.append(.product(name: "AttributeGraph", package: "OpenGraph")) + + var swiftSettings = swiftSettings ?? [] + swiftSettings.append(.define("OPENGRAPH_ATTRIBUTEGRAPH")) + self.swiftSettings = swiftSettings + + var linkerSettings = linkerSettings ?? [] + linkerSettings.append(.unsafeFlags([systemFrameworkSearchFlag, "/System/Library/PrivateFrameworks/"], .when(platforms: [.macOS]))) + linkerSettings.append(.linkedFramework("AttributeGraph", .when(platforms: [.macOS]))) + self.linkerSettings = linkerSettings + } +} + if attributeGraphCondition { - openSwiftUITarget.dependencies.append( - .product(name: "AttributeGraph", package: "OpenGraph") - ) - var swiftSettings = openSwiftUITarget.swiftSettings ?? [] - swiftSettings.append(.define("OPENSWIFTUI_ATTRIBUTEGRAPH")) - openSwiftUITarget.swiftSettings = swiftSettings - var linkerSettings = openSwiftUITarget.linkerSettings ?? [] - linkerSettings.append(.unsafeFlags([systemFrameworkSearchFlag, "/System/Library/PrivateFrameworks/"], .when(platforms: [.macOS]))) - linkerSettings.append(.linkedFramework("AttributeGraph", .when(platforms: [.macOS]))) - openSwiftUITarget.linkerSettings = linkerSettings -} else { - openSwiftUITarget.dependencies.append( - .product(name: "OpenGraph", package: "OpenGraph") - ) + openSwiftUITarget.addAGSettings() + openSwiftUITestTarget.addAGSettings() + openSwiftUICompatibilityTestTarget.addAGSettings() } #if os(macOS) diff --git a/Sources/OpenSwiftUI/DataAndStorage/Internal/Property/PropertyList.swift b/Sources/OpenSwiftUI/DataAndStorage/Internal/Property/PropertyList.swift index 53e3ebb4..ec594f8a 100644 --- a/Sources/OpenSwiftUI/DataAndStorage/Internal/Property/PropertyList.swift +++ b/Sources/OpenSwiftUI/DataAndStorage/Internal/Property/PropertyList.swift @@ -7,11 +7,7 @@ // Status: Blocked by merge // ID: 2B32D570B0B3D2A55DA9D4BFC1584D20 -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph -#else -internal import OpenGraph -#endif +internal import OpenGraphShims // MARK: - PropertyList diff --git a/Sources/OpenSwiftUI/DataAndStorage/Internal/UniqueID.swift b/Sources/OpenSwiftUI/DataAndStorage/Internal/UniqueID.swift index 8aa7aa75..c3130749 100644 --- a/Sources/OpenSwiftUI/DataAndStorage/Internal/UniqueID.swift +++ b/Sources/OpenSwiftUI/DataAndStorage/Internal/UniqueID.swift @@ -6,11 +6,7 @@ // Lastest Version: iOS 15.5 // Status: Complete -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph -#else -internal import OpenGraph -#endif +internal import OpenGraphShims struct UniqueID: Hashable { static let zero = UniqueID(value: 0) @@ -19,11 +15,7 @@ struct UniqueID: Hashable { @inline(__always) init() { - #if OPENSWIFTUI_ATTRIBUTEGRAPH - self.value = Int(AGMakeUniqueID()) - #else - self.value = Int(OGMakeUniqueID()) - #endif + value = Int(makeUniqueID()) } private init(value: Int) { diff --git a/Sources/OpenSwiftUI/GraphShims.swift b/Sources/OpenSwiftUI/GraphShims.swift deleted file mode 100644 index cfe7deb7..00000000 --- a/Sources/OpenSwiftUI/GraphShims.swift +++ /dev/null @@ -1,6 +0,0 @@ -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph - -typealias OGAttribute = AGAttribute -typealias OGUniqueID = AGUniqueID -#endif diff --git a/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphInputs.swift b/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphInputs.swift index 896f3149..7e08ac8b 100644 --- a/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphInputs.swift +++ b/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphInputs.swift @@ -1,8 +1,4 @@ -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph -#else -internal import OpenGraph -#endif +internal import OpenGraphShims public struct _GraphInputs { // var customInputs: PropertyList diff --git a/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphValue.swift b/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphValue.swift index 5ade580b..59ef83d4 100644 --- a/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphValue.swift +++ b/Sources/OpenSwiftUI/Internal/Graph/TODO/_GraphValue.swift @@ -1,8 +1,4 @@ -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph -#else -internal import OpenGraph -#endif +internal import OpenGraphShims public struct _GraphValue: Equatable { var value: Attribute diff --git a/Sources/OpenSwiftUI/Views/View/TODO/_ConditionalContent.swift b/Sources/OpenSwiftUI/Views/View/TODO/_ConditionalContent.swift index 04bc78bb..7199c256 100644 --- a/Sources/OpenSwiftUI/Views/View/TODO/_ConditionalContent.swift +++ b/Sources/OpenSwiftUI/Views/View/TODO/_ConditionalContent.swift @@ -8,11 +8,7 @@ // Status: WIP // ID: 1A625ACC143FD8524C590782FD8F4F8C -#if OPENSWIFTUI_ATTRIBUTEGRAPH -internal import AttributeGraph -#else -internal import OpenGraph -#endif +internal import OpenGraphShims @frozen public struct _ConditionalContent {