Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/actions/setup-xcode/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Setup Xcode Conditionally'
description: 'Check current Xcode version and setup if different from required version (Avoid unessary sudo/password input for self hosted runner)'

inputs:
xcode-version:
description: 'Required Xcode version'
required: true

outputs:
current-version:
description: 'Current Xcode version'
value: ${{ steps.current-xcode.outputs.version }}
setup-skipped:
description: 'Whether Xcode setup was skipped'
value: ${{ steps.xcode-check.outputs.skip-setup }}

runs:
using: 'composite'
steps:
- name: Get current Xcode version
id: current-xcode
shell: bash
run: |
CURRENT_VERSION=$(xcode-select -p | grep -o '[0-9]\+\.[0-9]\+' || echo "none")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current Xcode version: $CURRENT_VERSION"

- name: Check if Xcode version matches
id: xcode-check
shell: bash
run: |
CURRENT="${{ steps.current-xcode.outputs.version }}"
REQUIRED="${{ inputs.xcode-version }}"
if [ "$CURRENT" = "$REQUIRED" ]; then
echo "skip-setup=true" >> $GITHUB_OUTPUT
echo "✅ Xcode version matches: $CURRENT = $REQUIRED, skipping setup"
else
echo "skip-setup=false" >> $GITHUB_OUTPUT
echo "❌ Xcode version mismatch: $CURRENT ≠ $REQUIRED, setup required"
fi

- name: Setup Xcode
if: steps.xcode-check.outputs.skip-setup == 'false'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ inputs.xcode-version }}
- name: Swift version
shell: bash
run: swift --version
8 changes: 2 additions & 6 deletions .github/workflows/compatibility_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down Expand Up @@ -84,11 +82,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/uitests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down Expand Up @@ -92,11 +90,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
uses: ./.github/actions/setup-xcode
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Set up build environment
run: Scripts/CI/darwin_setup_build.sh
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ open class NSHostingView<Content>: NSView, XcodeViewDebugDataProvider where Cont
preconditionFailure("init(coder:) has not been implemented")
}

deinit {
updateRemovedState()
// TODO
HostingViewRegistry.shared.remove(self)
}

/// The renderer configuration of the hosting view.
public final var _rendererConfiguration: _RendererConfiguration {
get {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for 6.5.4
// Status: Complete

#if canImport(QuartzCore)
#if os(iOS) && canImport(QuartzCore)
import QuartzCore

extension CAFrameRateRange {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "OpenSwiftUIBase.h"

#if OPENSWIFTUI_TARGET_OS_DARWIN
#if OPENSWIFTUI_TARGET_OS_IOS

#import <SymbolLocator.h>

DEFINE_SL_STUB_SLF(OpenSwiftUITestStub_CAFrameRateRangeInitInterval, SwiftUI, $sSo16CAFrameRateRangeV7SwiftUIE8intervalABSd_tcfC);
DEFINE_SL_STUB_SLF(OpenSwiftUITestStub_CAFrameRateRangeInitInterval, SwiftUICore, $sSo16CAFrameRateRangeV7SwiftUIE8intervalABSd_tcfC);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import OpenSwiftUITestsSupport

@MainActor
struct AnimationCompletionCompatibilityTests {
@Test
@Test(.disabled {
#if os(macOS)
// macOS Animation is not supported yet
true
#else
false
#endif
})
func logicalAndRemovedComplete() async throws {
@MainActor
enum Helper {
Expand All @@ -18,56 +25,29 @@ struct AnimationCompletionCompatibilityTests {
let confirmation: Confirmation
var continuation: UnsafeContinuation<Void, Never>

var body: some View {
VStack {
LogicalCompletionView(confirmation: confirmation, continuation: continuation)
RemovedCompletionView(confirmation: confirmation, continuation: continuation)
}
}

struct LogicalCompletionView: View {
@State private var showRed = false
@State private var showRed = false
@State private var scale = 1.0

let confirmation: Confirmation
var continuation: UnsafeContinuation<Void, Never>

var body: some View {
VStack {
Color(platformColor: showRed ? .red : .blue)
.onAppear {
let animation = Animation.linear(duration: 3)
.logicallyComplete(after: 1)
withAnimation(animation, completionCriteria: .logicallyComplete) {
showRed.toggle()
} completion: {
Helper.values.append(1)
confirmation()
}
}
}
}
}
struct RemovedCompletionView: View {
@State private var showRed = false

let confirmation: Confirmation
var continuation: UnsafeContinuation<Void, Never>

var body: some View {
VStack {
Color(platformColor: showRed ? .red : .blue)
.onAppear {
let animation = Animation.linear(duration: 2)
withAnimation(animation, completionCriteria: .removed) {
showRed.toggle()
} completion: {
Helper.values.append(2)
confirmation()
continuation.resume()
}
}
var body: some View {
Color(platformColor: showRed ? .red : .blue)
.frame(width: 100 * scale, height: 100 * scale)
.onAppear {
let animation = Animation.linear(duration: 5)
.logicallyComplete(after: 1)
withAnimation(animation, completionCriteria: .logicallyComplete) {
showRed.toggle()
} completion: {
Helper.values.append(1)
confirmation()
}
withAnimation(animation, completionCriteria: .removed) {
scale = 2.0
} completion: {
Helper.values.append(2)
confirmation()
continuation.resume()
}
}
}
}
}

Expand All @@ -79,5 +59,6 @@ struct AnimationCompletionCompatibilityTests {
)
)
}
#expect(Helper.values == [1, 2])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ struct AppearanceActionModifierCompatibilityTests {
)
)
}
#if os(macOS)
// FIXME: NSHostingView is not dealloc here
// See #454
#expect(Helper.result == "AAD")
#else
#expect(Helper.result == "AADD")
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CAFrameRateRangeUtilTests.swift
// OpenSwiftUICoreTests

#if canImport(QuartzCore)
#if os(iOS) && canImport(QuartzCore)
import Testing
@_spi(ForOpenSwiftUIOnly)
import OpenSwiftUICore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// CAFrameRateRangeUtilDualTests.swift
// OpenSwiftUICoreTests

#if canImport(SwiftUI, _underlyingVersion: 6.5.4)
#if os(iOS) && canImport(SwiftUI, _underlyingVersion: 6.5.4)
import QuartzCore
import Testing

// MARK: - FlexFrameLayoutTests

extension CAFrameRateRange {
@_silgen_name("SwiftUITestStub_CAFrameRateRangeInitInterval")
@_silgen_name("OpenSwiftUITestStub_CAFrameRateRangeInitInterval")
init(swiftUI_interval: Double)
}

struct CAFrameRateRnageUtilDualTests {
struct CAFrameRateRangeUtilDualTests {
@Test(arguments: [
(.zero, .default),
(0.05, .init(minimum: 20, maximum: 60, preferred: 20)), // 20
Expand Down
Loading