Skip to content

Commit

Permalink
Update OpenSwiftUI_SPI (#147)
Browse files Browse the repository at this point in the history
* Add COpenSwiftUICoreTests Shims Tests

* Fix Mac Catalyst build issue

* Update DYLD and CoreFoundation private API

* Update COpenSwiftUI and COpenSwiftUICore to OpenSwiftUI_SPI

* Update CoreColor API

* Update header layout

* Rename CoreColor API to avoid conflict with SwiftUI

* Fix objc_autoreleaseReturnValue crash issue

* Fix build issue
  • Loading branch information
Kyle-Ye authored Oct 28, 2024
1 parent 8ca3584 commit c9a742f
Show file tree
Hide file tree
Showing 66 changed files with 618 additions and 270 deletions.
11 changes: 10 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "b56337b3dd1894393ef8978297a221dd102010b985af35ef055a726c560435e6",
"originHash" : "6ae2798ced7417c65233e0130814db449aa933d9f98ec74d935b06b494949ef9",
"pins" : [
{
"identity" : "opengraph",
Expand All @@ -9,6 +9,15 @@
"branch" : "main",
"revision" : "93e713f1357fc04ca917635d09460dbf42b663b6"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
}
],
"version" : 3
Expand Down
43 changes: 26 additions & 17 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ default:
}

var sharedSwiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("AccessLevelOnImport"),
.enableUpcomingFeature("BareSlashRegexLiterals"),
// .enableUpcomingFeature("InternalImportsByDefault"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
.define("OPENSWIFTUI_RELEASE_\(releaseVersion)"),
.swiftLanguageMode(.v5),
.enableUpcomingFeature("BareSlashRegexLiterals"),
]

if releaseVersion >= 2021 {
Expand All @@ -86,18 +86,20 @@ if warningsAsErrorsCondition {
sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
}

// NOTE:
// In macOS: Mac Catalyst App will use macOS-varient build of SwiftUI.framework in /System/Library/Framework and iOS varient of SwiftUI.framework in /System/iOSSupport/System/Library/Framework
// Add `|| Mac Catalyst` check everywhere in `OpenSwiftUICore` and `OpenSwiftUI_SPI`.
let openSwiftUICoreTarget = Target.target(
name: "OpenSwiftUICore",
dependencies: [
"COpenSwiftUICore",
"OpenSwiftUI_SPI",
.product(name: "OpenGraphShims", package: "OpenGraph"),
],
swiftSettings: sharedSwiftSettings
)
let openSwiftUITarget = Target.target(
name: "OpenSwiftUI",
dependencies: [
"COpenSwiftUI",
"OpenSwiftUICore",
.target(name: "CoreServices", condition: .when(platforms: [.iOS])),
.product(name: "OpenGraphShims", package: "OpenGraph"),
Expand All @@ -111,6 +113,17 @@ let openSwiftUIExtensionTarget = Target.target(
],
swiftSettings: sharedSwiftSettings
)
let OpenSwiftUI_SPITestTarget = Target.testTarget(
name: "OpenSwiftUI_SPITests",
dependencies: [
"OpenSwiftUI_SPI",
// For ProtocolDescriptor symbol linking
"OpenSwiftUI",
.product(name: "Numerics", package: "swift-numerics")
],
exclude: ["README.md"],
swiftSettings: sharedSwiftSettings
)
let openSwiftUICoreTestTarget = Target.testTarget(
name: "OpenSwiftUICoreTests",
dependencies: [
Expand Down Expand Up @@ -144,7 +157,10 @@ let package = Package(
products: [
.library(name: "OpenSwiftUI", targets: ["OpenSwiftUI", "OpenSwiftUIExtension"]),
// FIXME: This will block xcodebuild build(iOS CI) somehow
// .library(name: "COpenSwiftUI", targets: ["COpenSwiftUI"]),
// .library(name: "OpenSwiftUI_SPI", targets: ["OpenSwiftUI_SPI"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-numerics.git", from: "1.0.2"),
],
targets: [
// TODO: Add SwiftGTK as an backend alternative for UIKit/AppKit on Linux and macOS
Expand All @@ -157,18 +173,8 @@ let package = Package(
]
),
.target(
name: "COpenSwiftUI",
dependencies: [
"COpenSwiftUICore",
],
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
.define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
]
),
.target(
name: "COpenSwiftUICore",
name: "OpenSwiftUI_SPI",
publicHeadersPath: ".",
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
Expand All @@ -180,6 +186,7 @@ let package = Package(
openSwiftUITarget,
openSwiftUIExtensionTarget,

OpenSwiftUI_SPITestTarget,
openSwiftUICoreTestTarget,
openSwiftUITestTarget,
openSwiftUICompatibilityTestTarget,
Expand Down Expand Up @@ -227,6 +234,8 @@ extension Target {
if attributeGraphCondition {
openSwiftUICoreTarget.addAGSettings()
openSwiftUITarget.addAGSettings()

OpenSwiftUI_SPITestTarget.addAGSettings()
openSwiftUICoreTestTarget.addAGSettings()
openSwiftUITestTarget.addAGSettings()
openSwiftUICompatibilityTestTarget.addAGSettings()
Expand Down
22 changes: 6 additions & 16 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ default:
}

var sharedSwiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableExperimentalFeature("AccessLevelOnImport"),
// .enableUpcomingFeature("InternalImportsByDefault"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
.define("OPENSWIFTUI_RELEASE_\(releaseVersion)"),
.enableUpcomingFeature("BareSlashRegexLiterals"),
]

if releaseVersion >= 2021 {
Expand All @@ -85,15 +86,14 @@ if warningsAsErrorsCondition {
let openSwiftUICoreTarget = Target.target(
name: "OpenSwiftUICore",
dependencies: [
"COpenSwiftUICore",
"OpenSwiftUI_SPI",
.product(name: "OpenGraphShims", package: "OpenGraph"),
],
swiftSettings: sharedSwiftSettings
)
let openSwiftUITarget = Target.target(
name: "OpenSwiftUI",
dependencies: [
"COpenSwiftUI",
"OpenSwiftUICore",
.target(name: "CoreServices", condition: .when(platforms: [.iOS])),
.product(name: "OpenGraphShims", package: "OpenGraph"),
Expand Down Expand Up @@ -140,7 +140,7 @@ let package = Package(
products: [
.library(name: "OpenSwiftUI", targets: ["OpenSwiftUI", "OpenSwiftUIExtension"]),
// FIXME: This will block xcodebuild build(iOS CI) somehow
// .library(name: "COpenSwiftUI", targets: ["COpenSwiftUI"]),
// .library(name: "OpenSwiftUI_SPI", targets: ["OpenSwiftUI_SPI"]),
],
targets: [
// TODO: Add SwiftGTK as an backend alternative for UIKit/AppKit on Linux and macOS
Expand All @@ -153,18 +153,8 @@ let package = Package(
]
),
.target(
name: "COpenSwiftUI",
dependencies: [
"COpenSwiftUICore",
],
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
.define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
]
),
.target(
name: "COpenSwiftUICore",
name: "OpenSwiftUI_SPI",
publicHeadersPath: ".",
cSettings: [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
Expand Down
1 change: 0 additions & 1 deletion Sources/COpenSwiftUI/empty.c

This file was deleted.

1 change: 0 additions & 1 deletion Sources/COpenSwiftUI/include/empty.h

This file was deleted.

16 changes: 0 additions & 16 deletions Sources/COpenSwiftUICore/Shims/CoreFoundation_Private.c

This file was deleted.

27 changes: 0 additions & 27 deletions Sources/COpenSwiftUICore/include/dyld_Private.h

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Integration/UIKit/UIGraphicsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: Complete

#if os(iOS)
internal import COpenSwiftUI
internal import OpenSwiftUI_SPI
import UIKit

class _UIGraphicsView: UIView {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Test/_PerformanceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
import AppKit
#endif

internal import COpenSwiftUI
internal import OpenSwiftUI_SPI

public protocol _PerformanceTest: _Test {
var name: String { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: Complete
// ID: 6C985860B64B768EC9A2691B5DBA71A0

internal import COpenSwiftUI
internal import OpenSwiftUI_SPI

extension View {
func buttonDefaultRenderingMode() -> some View {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#if canImport(Darwin)
#if os(iOS) || os(tvOS)
import UIKit
#if os(iOS)
#if os(iOS) && !targetEnvironment(macCatalyst)
private import CoreServices
#endif
#elseif os(macOS)
Expand Down Expand Up @@ -37,7 +37,7 @@ struct OpenSensitiveURLActionKey: EnvironmentKey {

static let defaultValue = OpenURLAction(
handler: .system { url, completion in
#if os(iOS)
#if os(iOS) && !targetEnvironment(macCatalyst)
let config = _LSOpenConfiguration()
config.isSensitive = true
let selector = Selector(("_currentOpenApplicationEndpoint"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if OPENSWIFTUI_RELEASE_2021

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

package extension LockedPointer {
@_transparent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if OPENSWIFTUI_RELEASE_2021

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

package struct UnsafeAtomicLazy<Data>: Destroyable {
@UnsafeLockedPointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if OPENSWIFTUI_RELEASE_2021

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

@propertyWrapper
package struct UnsafeLockedPointer<Data>: Destroyable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/Property/PropertyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ID: 2B32D570B0B3D2A55DA9D4BFC1584D20 (RELEASE_2021)
// ID: D64CE6C88E7413721C59A34C0C940F2C (RELEASE_2024)

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI
internal import OpenGraphShims

// MARK: - PropertyList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OpenCombine
#else
import Combine
#endif
internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

struct ObservableObjectLocation<Root, Value>: Location where Root: ObservableObject {
let base: Root
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/State/StoredLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ID: 4F21368B1C1680817451AC25B55A8D48 (RELEASE_2024)

internal import OpenGraphShims
internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

package class StoredLocationBase<Value>: AnyLocation<Value>, Location, @unchecked Sendable {
private struct Data {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ID: B2543BCA257433E04979186A1DC2B6BC

internal import OpenGraphShims
internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

/// The context of the current state-processing update.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ID: EA173074DA35FA471DC70643259B7E74 (RELEASE_2021)
// ID: 61534957AEEC2EDC447ABDC13B4D426F (RELEASE_2024)

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI
internal import OpenGraphShims
import Foundation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: WIP

import Foundation
internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

protocol ContentResponder {
func contains(points: [CGPoint], size: CGSize) -> BitVector64
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Graph/GraphHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// ID: 30C09FF16BC95EC5173809B57186CAC3 (RELEASE_2021)
// ID: F9F204BD2F8DB167A76F17F3FB1B3335 (RELEASE_2024)

internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI
package import OpenGraphShims
import Foundation

Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: WIP

import Foundation
internal import COpenSwiftUICore
internal import OpenSwiftUI_SPI

// MARK: - Color.Resolved

Expand Down Expand Up @@ -322,7 +322,7 @@ extension Color.Resolved {
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
let result = CoreColorPlatformColorGetComponents(isAppKitBased(), platformColor, &red, &green, &blue, &alpha)
let result = OpenSwiftUICoreColorPlatformColorGetComponents(isAppKitBased(), platformColor, &red, &green, &blue, &alpha)
if result {
self.init(red: Float(red), green: Float(green), blue: Float(blue), opacity: Float(alpha))
} else {
Expand All @@ -332,7 +332,7 @@ extension Color.Resolved {

// ID: 4330A474F53D66045762501ED6F8A749
private static let cache: ObjectCache<Color.Resolved, NSObject> = ObjectCache { resolved in
CoreColor.platformColor(resolvedColor: resolved)!
OpenSwiftUICoreColor.platformColor(resolvedColor: resolved)!
}

package var kitColor: NSObject {
Expand Down
Loading

0 comments on commit c9a742f

Please sign in to comment.