From c320828787207e37d410419fd5773a87fb47f290 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 27 Oct 2026 03:01:39 +0800 Subject: [PATCH 1/3] build: update OpenObservation revision --- Example/Tuist/Package.resolved | 2 +- Package.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Tuist/Package.resolved b/Example/Tuist/Package.resolved index 8cab4b15c..2b24e979e 100644 --- a/Example/Tuist/Package.resolved +++ b/Example/Tuist/Package.resolved @@ -34,7 +34,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenObservation", "state" : { "branch" : "main", - "revision" : "51c52f318eb3278b1eaa8b724f50d1af9f9f8bae" + "revision" : "b030e44d6471cf1d760137e5da6805cf57aa885b" } }, { diff --git a/Package.resolved b/Package.resolved index 263d4789a..4293c6dea 100644 --- a/Package.resolved +++ b/Package.resolved @@ -34,7 +34,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenObservation", "state" : { "branch" : "main", - "revision" : "51c52f318eb3278b1eaa8b724f50d1af9f9f8bae" + "revision" : "b030e44d6471cf1d760137e5da6805cf57aa885b" } }, { From 0076f3cf07e44e2965e5113e65118b6f1a64ee05 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 26 Oct 2026 22:05:40 +0800 Subject: [PATCH 2/3] feat: add public Clang modules and Metal headers --- Package.resolved | 2 +- Package.swift | 5 +- Scripts/CI/Tests/framework-header-tests.js | 80 +++++++++++++++++++ Scripts/build_xcframework.sh | 6 ++ Scripts/install_framework_headers.js | 39 +++++++++ Sources/COpenSwiftUI/Public/OpenSwiftUI.h | 22 +++++ .../COpenSwiftUI/Public/OpenSwiftUI_Metal.h | 31 +++++++ Sources/COpenSwiftUI/Public/module.modulemap | 6 ++ Sources/COpenSwiftUI/module.modulemap | 8 ++ .../AppKit/AppKitKeyEventConversions.swift | 2 +- .../UIKit/UIKitKeyEventConversions.swift | 2 +- Sources/OpenSwiftUI/Export.swift | 8 ++ Sources/OpenSwiftUI/Macro/PreviewMacro.swift | 2 +- .../OpenSwiftUI_SPI/Public/OpenSwiftUICore.h | 25 ++++++ .../Public/OpenSwiftUI_Metal.h | 31 +++++++ .../OpenSwiftUI_SPI/Public/module.modulemap | 6 ++ Sources/OpenSwiftUI_SPI/module.modulemap | 2 + 17 files changed, 272 insertions(+), 5 deletions(-) create mode 100644 Scripts/CI/Tests/framework-header-tests.js create mode 100644 Scripts/install_framework_headers.js create mode 100644 Sources/COpenSwiftUI/Public/OpenSwiftUI.h create mode 100644 Sources/COpenSwiftUI/Public/OpenSwiftUI_Metal.h create mode 100644 Sources/COpenSwiftUI/Public/module.modulemap create mode 100644 Sources/COpenSwiftUI/module.modulemap create mode 100644 Sources/OpenSwiftUI_SPI/Public/OpenSwiftUICore.h create mode 100644 Sources/OpenSwiftUI_SPI/Public/OpenSwiftUI_Metal.h create mode 100644 Sources/OpenSwiftUI_SPI/Public/module.modulemap diff --git a/Package.resolved b/Package.resolved index 4293c6dea..b8db4f941 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "d5e925ff2998f16faece44ea17def8ad6be9208977c0303ec099d396bf1fffbe", + "originHash" : "baa9d73a9a30e9cf8367ffea2c8151f6ed08ebfb5fe1056d2f5c10994c2e31fc", "pins" : [ { "identity" : "darwinprivateframeworks", diff --git a/Package.swift b/Package.swift index 20043b9ee..e2e650214 100644 --- a/Package.swift +++ b/Package.swift @@ -660,6 +660,7 @@ let openSwiftUICoreTarget = Target.target( cxxSettings: sharedCxxSettings, swiftSettings: sharedSwiftSettings + [ .unsafeFlags(["-module-abi-name", "OpenSwiftUI"]), + .unsafeFlags(["-import-underlying-module"], .when(platforms: .darwinPlatforms)), ], linkerSettings: computeCondition ? [ .linkedLibrary("c++", .when(platforms: .darwinPlatforms)), @@ -713,7 +714,9 @@ let openSwiftUITarget = Target.target( ], cSettings: sharedCSettings, cxxSettings: sharedCxxSettings, - swiftSettings: sharedSwiftSettings, + swiftSettings: sharedSwiftSettings + [ + .unsafeFlags(["-import-underlying-module"], .when(platforms: .darwinPlatforms)), + ], linkerSettings: [ // Force Objective-C categories from static COpenSwiftUI into the final framework. .unsafeFlags(["-Xlinker", "-ObjC"], .when(platforms: .darwinPlatforms)), diff --git a/Scripts/CI/Tests/framework-header-tests.js b/Scripts/CI/Tests/framework-header-tests.js new file mode 100644 index 000000000..5deb63cb6 --- /dev/null +++ b/Scripts/CI/Tests/framework-header-tests.js @@ -0,0 +1,80 @@ +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const os = require("node:os"); +const path = require("node:path"); +const test = require("node:test"); + +const { installFrameworkHeaders } = require("../../install_framework_headers.js"); + +function fixture(t, versioned) { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "framework headers ")); + t.after(() => fs.rmSync(root, { recursive: true, force: true })); + const source = path.join(root, "Public"); + const framework = path.join(root, "OpenSwiftUI.framework"); + const contents = versioned ? path.join(framework, "Versions/A") : framework; + fs.mkdirSync(source, { recursive: true }); + fs.mkdirSync(path.join(source, "Details")); + fs.mkdirSync(path.join(contents, "Headers"), { recursive: true }); + if (versioned) { + fs.symlinkSync("A", path.join(framework, "Versions/Current")); + fs.symlinkSync("Versions/Current/Headers", path.join(framework, "Headers")); + } + fs.writeFileSync(path.join(source, "OpenSwiftUI.h"), '#include "Details/Exports.h"\n'); + fs.writeFileSync(path.join(source, "Details/Exports.h"), "#define PUBLIC_VALUE 42\n"); + fs.writeFileSync(path.join(source, "OpenSwiftUI_Metal.h"), "#if defined(__METAL_VERSION__)\nnamespace OpenSwiftUI {}\n#endif\n"); + fs.writeFileSync(path.join(root, "Internal.h"), "#define INTERNAL_VALUE 7\n"); + fs.writeFileSync(path.join(source, "module.modulemap"), `module OpenSwiftUI { + umbrella header "OpenSwiftUI.h" + textual header "OpenSwiftUI_Metal.h" + export * + module * { export * } +} +`); + fs.writeFileSync(path.join(contents, "Headers/OpenSwiftUI-Swift.h"), "// Generated Swift declarations\n"); + return { source, framework, contents }; +} + +for (const versioned of [false, true]) { + test(`installs a self-contained public module in a ${versioned ? "versioned" : "flat"} framework`, t => { + const f = fixture(t, versioned); + installFrameworkHeaders("OpenSwiftUI", f.framework, f.source); + const headers = path.join(f.contents, "Headers"); + assert.equal(fs.readFileSync(path.join(headers, "Details/Exports.h"), "utf8"), "#define PUBLIC_VALUE 42\n"); + assert.equal(fs.existsSync(path.join(headers, "OpenSwiftUI-Swift.h")), false); + assert.equal(fs.readFileSync(path.join(headers, "OpenSwiftUI_Metal.h"), "utf8"), fs.readFileSync(path.join(f.source, "OpenSwiftUI_Metal.h"), "utf8")); + assert.equal(fs.existsSync(path.join(headers, "Internal.h")), false); + assert.equal(fs.existsSync(path.join(headers, "module.modulemap")), false); + const map = fs.readFileSync(path.join(f.contents, "Modules/module.modulemap"), "utf8"); + assert.match(map, /^framework module OpenSwiftUI \{/); + assert.match(map, /umbrella header "OpenSwiftUI.h"/); + assert.match(map, /textual header "OpenSwiftUI_Metal.h"/); + assert.equal(map.includes("OpenSwiftUI.Swift"), false); + assert.equal(map.includes("OpenSwiftUI-Swift.h"), false); + assert.equal(map.includes(f.source), false); + installFrameworkHeaders("OpenSwiftUI", f.framework, f.source); + assert.equal(fs.readFileSync(path.join(f.contents, "Modules/module.modulemap"), "utf8"), map); + }); +} + +test("installs public headers without a generated Swift header", t => { + const f = fixture(t, false); + fs.unlinkSync(path.join(f.contents, "Headers/OpenSwiftUI-Swift.h")); + installFrameworkHeaders("OpenSwiftUI", f.framework, f.source); + assert.equal(fs.existsSync(path.join(f.contents, "Headers/OpenSwiftUI.h")), true); + assert.equal(fs.existsSync(path.join(f.contents, "Headers/OpenSwiftUI-Swift.h")), false); +}); + +test("rejects a missing public umbrella before changing the framework", t => { + const f = fixture(t, false); + fs.unlinkSync(path.join(f.source, "OpenSwiftUI.h")); + assert.throws(() => installFrameworkHeaders("OpenSwiftUI", f.framework, f.source), /OpenSwiftUI.h/); + assert.equal(fs.existsSync(path.join(f.contents, "Headers/OpenSwiftUI-Swift.h")), true); + assert.equal(fs.existsSync(path.join(f.contents, "Headers/OpenSwiftUI_Metal.h")), false); +}); + +test("rejects a module map for a different module", t => { + const f = fixture(t, false); + fs.writeFileSync(path.join(f.source, "module.modulemap"), 'module Internal { header "Internal.h" }\n'); + assert.throws(() => installFrameworkHeaders("OpenSwiftUI", f.framework, f.source), /OpenSwiftUI/); + assert.equal(fs.existsSync(path.join(f.contents, "Headers/OpenSwiftUI.h")), false); +}); diff --git a/Scripts/build_xcframework.sh b/Scripts/build_xcframework.sh index 62c6955f2..6a997609d 100755 --- a/Scripts/build_xcframework.sh +++ b/Scripts/build_xcframework.sh @@ -571,6 +571,12 @@ build_framework() { ln -s Versions/Current/Modules "$framework/Modules" fi + case "$scheme" in + OpenSwiftUI|OpenSwiftUICore) + node "$SCRIPT_DIR/install_framework_headers.js" "$scheme" "$framework" + ;; + esac + flatten_framework_resource_bundles "$scheme" "$framework" node "$SCRIPT_DIR/normalize_swiftinterface.js" "$modules_path" strip_release_metadata "$modules_path" diff --git a/Scripts/install_framework_headers.js b/Scripts/install_framework_headers.js new file mode 100644 index 000000000..77c9bf522 --- /dev/null +++ b/Scripts/install_framework_headers.js @@ -0,0 +1,39 @@ +const fs = require("node:fs"); +const path = require("node:path"); + +function installFrameworkHeaders(name, framework, source) { + const contents = fs.existsSync(path.join(framework, "Versions")) + ? path.join(framework, "Versions/Current") : framework; + const headers = path.join(contents, "Headers"); + const modules = path.join(contents, "Modules"); + const sourceMap = fs.readFileSync(path.join(source, "module.modulemap"), "utf8"); + const declaration = `module ${name} {`; + if (!sourceMap.startsWith(declaration)) { + throw new Error(`Expected a public module map for ${name}.`); + } + fs.accessSync(path.join(source, `${name}.h`)); + + // Keep the source and framework exports in one module map. Only their layout differs. + const frameworkMap = sourceMap.replace(declaration, `framework ${declaration}`); + fs.cpSync(source, headers, { + recursive: true, + dereference: true, + filter: file => fs.statSync(file).isDirectory() || file.endsWith(".h"), + }); + fs.rmSync(path.join(headers, `${name}-Swift.h`), { force: true }); + fs.mkdirSync(modules, { recursive: true }); + fs.writeFileSync(path.join(modules, "module.modulemap"), frameworkMap); +} + +if (require.main === module) { + const carriers = { OpenSwiftUI: "COpenSwiftUI", OpenSwiftUICore: "OpenSwiftUI_SPI" }; + const [name, framework] = process.argv.slice(2); + if (process.argv.length !== 4 || !carriers[name]) { + console.error("Usage: node Scripts/install_framework_headers.js "); + process.exitCode = 64; + } else { + installFrameworkHeaders(name, framework, path.join(__dirname, "../Sources", carriers[name], "Public")); + } +} + +module.exports = { installFrameworkHeaders }; diff --git a/Sources/COpenSwiftUI/Public/OpenSwiftUI.h b/Sources/COpenSwiftUI/Public/OpenSwiftUI.h new file mode 100644 index 000000000..06da54161 --- /dev/null +++ b/Sources/COpenSwiftUI/Public/OpenSwiftUI.h @@ -0,0 +1,22 @@ +// +// OpenSwiftUI.h +// OpenSwiftUI + +#ifndef OPENSWIFTUI_PUBLIC_H +#define OPENSWIFTUI_PUBLIC_H + +#if defined(__METAL_VERSION__) +#include "OpenSwiftUI_Metal.h" +#elif defined(__APPLE__) +#import + +#if TARGET_OS_OSX && __has_include() +#import +#endif + +#if !TARGET_OS_OSX && __has_include() +#import +#endif +#endif + +#endif /* OPENSWIFTUI_PUBLIC_H */ diff --git a/Sources/COpenSwiftUI/Public/OpenSwiftUI_Metal.h b/Sources/COpenSwiftUI/Public/OpenSwiftUI_Metal.h new file mode 100644 index 000000000..c524ca7c1 --- /dev/null +++ b/Sources/COpenSwiftUI/Public/OpenSwiftUI_Metal.h @@ -0,0 +1,31 @@ +// +// OpenSwiftUI_Metal.h +// OpenSwiftUI + +#ifndef OPENSWIFTUI_METAL_H +#define OPENSWIFTUI_METAL_H + +#if defined(__METAL_VERSION__) + +#include + +namespace OpenSwiftUI { + +/// A region of a rasterized layer. +struct Layer { + metal::texture2d tex; + float2 info[5]; + + /// Samples the layer at a position in user coordinates with linear filtering. + /// Returns premultiplied RGBA in the layer's working color space. + half4 sample(float2 p) const { + p = metal::fma(p.x, info[0], metal::fma(p.y, info[1], info[2])); + p = metal::clamp(p, info[3], info[4]); + return tex.sample(metal::sampler(metal::filter::linear), p); + } +}; + +} // namespace OpenSwiftUI + +#endif /* defined(__METAL_VERSION__) */ +#endif /* OPENSWIFTUI_METAL_H */ diff --git a/Sources/COpenSwiftUI/Public/module.modulemap b/Sources/COpenSwiftUI/Public/module.modulemap new file mode 100644 index 000000000..7e5e879b9 --- /dev/null +++ b/Sources/COpenSwiftUI/Public/module.modulemap @@ -0,0 +1,6 @@ +module OpenSwiftUI { + umbrella header "OpenSwiftUI.h" + textual header "OpenSwiftUI_Metal.h" + export * + module * { export * } +} diff --git a/Sources/COpenSwiftUI/module.modulemap b/Sources/COpenSwiftUI/module.modulemap new file mode 100644 index 000000000..99c16c2a3 --- /dev/null +++ b/Sources/COpenSwiftUI/module.modulemap @@ -0,0 +1,8 @@ +module COpenSwiftUI { + umbrella "." + exclude header "Public/OpenSwiftUI.h" + exclude header "Public/OpenSwiftUI_Metal.h" + export * +} + +extern module OpenSwiftUI "Public/module.modulemap" diff --git a/Sources/OpenSwiftUI/Event/Platform/AppKit/AppKitKeyEventConversions.swift b/Sources/OpenSwiftUI/Event/Platform/AppKit/AppKitKeyEventConversions.swift index 5fd6a3a14..b15f9b760 100644 --- a/Sources/OpenSwiftUI/Event/Platform/AppKit/AppKitKeyEventConversions.swift +++ b/Sources/OpenSwiftUI/Event/Platform/AppKit/AppKitKeyEventConversions.swift @@ -13,7 +13,7 @@ import OpenSwiftUICore // MARK: - NSEvent + KeyEventProvider extension NSEvent: KeyEventProvider { - func resolve(phase: EventPhase) -> KeyEvent? { + package func resolve(phase: EventPhase) -> KeyEvent? { KeyEvent( phase: isARepeat ? .active : phase, timestamp: Time(seconds: timestamp), diff --git a/Sources/OpenSwiftUI/Event/Platform/UIKit/UIKitKeyEventConversions.swift b/Sources/OpenSwiftUI/Event/Platform/UIKit/UIKitKeyEventConversions.swift index 61ffbd686..196767d95 100644 --- a/Sources/OpenSwiftUI/Event/Platform/UIKit/UIKitKeyEventConversions.swift +++ b/Sources/OpenSwiftUI/Event/Platform/UIKit/UIKitKeyEventConversions.swift @@ -15,7 +15,7 @@ import UIKit // MARK: - UIPress + KeyEventProvider extension UIPress: KeyEventProvider { - func resolve(phase: EventPhase) -> KeyEvent? { + package func resolve(phase: EventPhase) -> KeyEvent? { guard let key else { return nil } diff --git a/Sources/OpenSwiftUI/Export.swift b/Sources/OpenSwiftUI/Export.swift index 3295b182f..2db954243 100644 --- a/Sources/OpenSwiftUI/Export.swift +++ b/Sources/OpenSwiftUI/Export.swift @@ -16,6 +16,14 @@ package typealias UniqueID = OpenSwiftUICore.UniqueID @_exported import CoreGraphics #endif +#if canImport(CoreTransferable) +@_exported import CoreTransferable +#endif + +#if canImport(DeveloperToolsSupport) +@_exported import DeveloperToolsSupport +#endif + #if canImport(OpenCombine) public import OpenCombine public typealias Published = OpenCombine.Published diff --git a/Sources/OpenSwiftUI/Macro/PreviewMacro.swift b/Sources/OpenSwiftUI/Macro/PreviewMacro.swift index 1517e3be5..d8dcaf041 100644 --- a/Sources/OpenSwiftUI/Macro/PreviewMacro.swift +++ b/Sources/OpenSwiftUI/Macro/PreviewMacro.swift @@ -3,7 +3,7 @@ // OpenSwiftUI #if canImport(DeveloperToolsSupport) -@_exported import DeveloperToolsSupport +public import DeveloperToolsSupport import OpenSwiftUICore /// Creates an Xcode preview from an OpenSwiftUI view. diff --git a/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUICore.h b/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUICore.h new file mode 100644 index 000000000..b41ee77a0 --- /dev/null +++ b/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUICore.h @@ -0,0 +1,25 @@ +// +// OpenSwiftUICore.h +// OpenSwiftUICore + +#ifndef OPENSWIFTUICORE_PUBLIC_H +#define OPENSWIFTUICORE_PUBLIC_H + +#if defined(__METAL_VERSION__) +#include "OpenSwiftUI_Metal.h" +#elif defined(__APPLE__) +#import +#import +#import +#import + +#if __has_include() +#import +#endif + +#if TARGET_OS_VISION && __has_include() +#import +#endif +#endif + +#endif /* OPENSWIFTUICORE_PUBLIC_H */ diff --git a/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUI_Metal.h b/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUI_Metal.h new file mode 100644 index 000000000..c524ca7c1 --- /dev/null +++ b/Sources/OpenSwiftUI_SPI/Public/OpenSwiftUI_Metal.h @@ -0,0 +1,31 @@ +// +// OpenSwiftUI_Metal.h +// OpenSwiftUI + +#ifndef OPENSWIFTUI_METAL_H +#define OPENSWIFTUI_METAL_H + +#if defined(__METAL_VERSION__) + +#include + +namespace OpenSwiftUI { + +/// A region of a rasterized layer. +struct Layer { + metal::texture2d tex; + float2 info[5]; + + /// Samples the layer at a position in user coordinates with linear filtering. + /// Returns premultiplied RGBA in the layer's working color space. + half4 sample(float2 p) const { + p = metal::fma(p.x, info[0], metal::fma(p.y, info[1], info[2])); + p = metal::clamp(p, info[3], info[4]); + return tex.sample(metal::sampler(metal::filter::linear), p); + } +}; + +} // namespace OpenSwiftUI + +#endif /* defined(__METAL_VERSION__) */ +#endif /* OPENSWIFTUI_METAL_H */ diff --git a/Sources/OpenSwiftUI_SPI/Public/module.modulemap b/Sources/OpenSwiftUI_SPI/Public/module.modulemap new file mode 100644 index 000000000..49aa20deb --- /dev/null +++ b/Sources/OpenSwiftUI_SPI/Public/module.modulemap @@ -0,0 +1,6 @@ +module OpenSwiftUICore { + umbrella header "OpenSwiftUICore.h" + textual header "OpenSwiftUI_Metal.h" + export * + module * { export * } +} diff --git a/Sources/OpenSwiftUI_SPI/module.modulemap b/Sources/OpenSwiftUI_SPI/module.modulemap index 077100c90..d5c29ddf4 100644 --- a/Sources/OpenSwiftUI_SPI/module.modulemap +++ b/Sources/OpenSwiftUI_SPI/module.modulemap @@ -67,3 +67,5 @@ module UIFoundation_Private { umbrella "Shims/UIFoundation" export * } + +extern module OpenSwiftUICore "Public/module.modulemap" From a3bf6e4a001f054f572c3944458e53b464aa2eb1 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 31 Oct 2026 12:31:57 +0800 Subject: [PATCH 3/3] test: qualify observation macros in tests --- .../Data/Binding/BindableCompatibilityTests.swift | 6 +++++- .../Combine/ObservedObjectCompatibilityTests.swift | 10 +++++++++- .../Data/Combine/StateObjectCompatibilityTests.swift | 10 +++++++++- ...ronmentKeyTransformModifierCompatibilityTests.swift | 6 +++++- .../Environment+ObservableCompatibilityTests.swift | 6 +++++- .../ObservationUtilsCompatibilityTests.swift | 6 +++++- .../Data/Observation/ObservationUtilsTests.swift | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Binding/BindableCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Binding/BindableCompatibilityTests.swift index cd956026b..5803d2289 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Binding/BindableCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Binding/BindableCompatibilityTests.swift @@ -5,7 +5,11 @@ import OpenSwiftUITestsSupport import Testing -@Observable +#if OPENSWIFTUI +@OpenObservation::Observable +#else +@Observation::Observable +#endif private final class Model { var value = 0 diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Combine/ObservedObjectCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Combine/ObservedObjectCompatibilityTests.swift index d5209d30f..228aa136d 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Combine/ObservedObjectCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Combine/ObservedObjectCompatibilityTests.swift @@ -18,10 +18,18 @@ struct ObservedObjectCompatibilityTests { var t2 = false } - @Observable + #if OPENSWIFTUI + @OpenObservation::Observable + #else + @Observation::Observable + #endif class Model2 { var t1 = false + #if OPENSWIFTUI + @OpenObservation::ObservationIgnored var t2 = false + #else @ObservationIgnored var t2 = false + #endif } struct Subview: View { diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Combine/StateObjectCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Combine/StateObjectCompatibilityTests.swift index 96ee8c828..227b65c71 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Combine/StateObjectCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Combine/StateObjectCompatibilityTests.swift @@ -18,10 +18,18 @@ struct StateObjectCompatibilityTests { var t2 = false } - @Observable + #if OPENSWIFTUI + @OpenObservation::Observable + #else + @Observation::Observable + #endif class Model2 { var t1 = false + #if OPENSWIFTUI + @OpenObservation::ObservationIgnored var t2 = false + #else @ObservationIgnored var t2 = false + #endif } struct Subview: View { diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Environment/EnvironmentKeyTransformModifierCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Environment/EnvironmentKeyTransformModifierCompatibilityTests.swift index baf3b1e0f..5351df18c 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Environment/EnvironmentKeyTransformModifierCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Environment/EnvironmentKeyTransformModifierCompatibilityTests.swift @@ -10,7 +10,11 @@ extension EnvironmentValues { @Entry fileprivate var customValue2 = 0 } -@Observable +#if OPENSWIFTUI +@OpenObservation::Observable +#else +@Observation::Observable +#endif private final class Model { var value = 0 } diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Observation/Environment+ObservableCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Observation/Environment+ObservableCompatibilityTests.swift index c4c29a54a..ac51138f7 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Observation/Environment+ObservableCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Observation/Environment+ObservableCompatibilityTests.swift @@ -7,7 +7,11 @@ import Testing @MainActor struct Environment_ObservableCompatibilityTests { - @Observable + #if OPENSWIFTUI + @OpenObservation::Observable + #else + @Observation::Observable + #endif class Model { var value: Int = 0 diff --git a/Tests/OpenSwiftUICompatibilityTests/Data/Observation/ObservationUtilsCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Data/Observation/ObservationUtilsCompatibilityTests.swift index a395970c1..4e071ef35 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Data/Observation/ObservationUtilsCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Data/Observation/ObservationUtilsCompatibilityTests.swift @@ -7,7 +7,11 @@ import Testing @MainActor struct ObservationUtilsCompatibilityTests { - @Observable + #if OPENSWIFTUI + @OpenObservation::Observable + #else + @Observation::Observable + #endif class Model { var showRed = false } diff --git a/Tests/OpenSwiftUICoreTests/Data/Observation/ObservationUtilsTests.swift b/Tests/OpenSwiftUICoreTests/Data/Observation/ObservationUtilsTests.swift index ce06c7276..0b323cb9e 100644 --- a/Tests/OpenSwiftUICoreTests/Data/Observation/ObservationUtilsTests.swift +++ b/Tests/OpenSwiftUICoreTests/Data/Observation/ObservationUtilsTests.swift @@ -13,7 +13,7 @@ import OpenSwiftUICore @Suite("ObservationUtil Tests") struct ObservationUtilTests { - @Observable + @OpenObservation::Observable final class TestModel { var value: Int = 0 var text: String = ""