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
8 changes: 4 additions & 4 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 50 additions & 17 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ let includePath = SDKPath.appending("/usr/lib/swift")

var sharedCSettings: [CSetting] = [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.unsafeFlags(["-fmodules"]),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
.define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
]

var sharedCxxSettings: [CXXSetting] = [
.unsafeFlags(["-I", includePath], .when(platforms: .nonDarwinPlatforms)),
.unsafeFlags(["-fcxx-modules"]),
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
.define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
]
Expand Down Expand Up @@ -79,13 +87,35 @@ let bridgeFramework = Context.environment["OPENSWIFTUI_BRIDGE_FRAMEWORK"] ?? "Sw

// MARK: - Targets

let cOpenSwiftUITarget = Target.target(
name: "COpenSwiftUI",
publicHeadersPath: ".",
cSettings: sharedCSettings + [
.headerSearchPath("../OpenSwiftUI_SPI"),
],
cxxSettings: sharedCxxSettings
)
let openSwiftUISPITarget = Target.target(
name: "OpenSwiftUI_SPI",
dependencies: [
.product(name: "OpenBox", package: "OpenBox"),
],
publicHeadersPath: ".",
cSettings: sharedCSettings + [.define("_GNU_SOURCE", .when(platforms: .nonDarwinPlatforms))],
cxxSettings: sharedCxxSettings
)
let coreGraphicsShims = Target.target(
name: "CoreGraphicsShims",
swiftSettings: sharedSwiftSettings
)
// 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: [
"OpenSwiftUI_SPI",
"CoreGraphicsShims",
.product(name: "OpenGraphShims", package: "OpenGraph"),
.product(name: "OpenBoxShims", package: "OpenBox"),
],
Expand All @@ -96,6 +126,7 @@ let openSwiftUITarget = Target.target(
dependencies: [
"OpenSwiftUICore",
"COpenSwiftUI",
"CoreGraphicsShims",
.target(name: "CoreServices", condition: .when(platforms: [.iOS])),
.product(name: "OpenGraphShims", package: "OpenGraph"),
.product(name: "OpenBoxShims", package: "OpenBox"),
Expand All @@ -118,7 +149,7 @@ let openSwiftUIBridgeTarget = Target.target(
sources: ["Bridgeable.swift", bridgeFramework],
swiftSettings: sharedSwiftSettings
)
let OpenSwiftUI_SPITestTarget = Target.testTarget(
let openSwiftUISPITestTarget = Target.testTarget(
name: "OpenSwiftUI_SPITests",
dependencies: [
"OpenSwiftUI_SPI",
Expand Down Expand Up @@ -167,11 +198,22 @@ let openSwiftUIBridgeTestTarget = Target.testTarget(
// Workaround iOS CI build issue (We need to disable this on iOS CI)
let supportMultiProducts: Bool = envEnable("OPENSWIFTUI_SUPPORT_MULTI_PRODUCTS", default: true)

let libraryType: Product.Library.LibraryType?
switch Context.environment["OPENSWIFTUI_LIBRARY_TYPE"] {
case "dynamic":
libraryType = .dynamic
case "static":
libraryType = .static
default:
libraryType = nil
}

var products: [Product] = [
.library(name: "OpenSwiftUI", targets: ["OpenSwiftUI"])
.library(name: "OpenSwiftUI", type: libraryType, targets: ["OpenSwiftUI"])
]
if supportMultiProducts {
products += [
.library(name: "OpenSwiftUICore", type: libraryType, targets: ["OpenSwiftUICore"]),
.library(name: "OpenSwiftUI_SPI", targets: ["OpenSwiftUI_SPI"]),
.library(name: "OpenSwiftUIExtension", targets: ["OpenSwiftUIExtension"]),
.library(name: "OpenSwiftUIBridge", targets: ["OpenSwiftUIBridge"])
Expand All @@ -194,26 +236,17 @@ let package = Package(
.apt(["libgtk-4-dev clang"]),
]
),
.target(
name: "OpenSwiftUI_SPI",
publicHeadersPath: ".",
cSettings: sharedCSettings
),
.target(
name: "COpenSwiftUI",
publicHeadersPath: ".",
cSettings: sharedCSettings + [
.headerSearchPath("../OpenSwiftUI_SPI"),
]
),
.binaryTarget(name: "CoreServices", path: "PrivateFrameworks/CoreServices.xcframework"),
coreGraphicsShims,
cOpenSwiftUITarget,
openSwiftUISPITarget,
openSwiftUICoreTarget,
openSwiftUITarget,

openSwiftUIExtensionTarget,
openSwiftUIBridgeTarget,

OpenSwiftUI_SPITestTarget,
openSwiftUISPITestTarget,
openSwiftUICoreTestTarget,
openSwiftUITestTarget,
openSwiftUICompatibilityTestTarget,
Expand Down Expand Up @@ -274,7 +307,7 @@ if attributeGraphCondition {
openSwiftUICoreTarget.addAGSettings()
openSwiftUITarget.addAGSettings()

OpenSwiftUI_SPITestTarget.addAGSettings()
openSwiftUISPITestTarget.addAGSettings()
openSwiftUICoreTestTarget.addAGSettings()
openSwiftUITestTarget.addAGSettings()
openSwiftUICompatibilityTestTarget.addAGSettings()
Expand All @@ -291,7 +324,7 @@ if renderBoxCondition {
openSwiftUICoreTarget.addRBSettings()
openSwiftUITarget.addRBSettings()

OpenSwiftUI_SPITestTarget.addRBSettings()
openSwiftUISPITestTarget.addRBSettings()
openSwiftUICoreTestTarget.addRBSettings()
openSwiftUITestTarget.addRBSettings()
openSwiftUICompatibilityTestTarget.addRBSettings()
Expand Down
64 changes: 64 additions & 0 deletions Sources/CoreGraphicsShims/CGAffineTransform.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// CGAffineTransform.swift
// CoreGraphicsShims

#if !canImport(CoreGraphics)
public import Foundation

// FIXME: Use Silica or other implementation
public struct CGAffineTransform: Equatable {
public init() {
a = .zero
b = .zero
c = .zero
d = .zero
tx = .zero
ty = .zero
}

public init(a: Double, b: Double, c: Double, d: Double, tx: Double, ty: Double) {
self.a = a
self.b = b
self.c = c
self.d = d
self.tx = tx
self.ty = ty
}

public var a: Double
public var b: Double
public var c: Double
public var d: Double
public var tx: Double
public var ty: Double

public static let identity = CGAffineTransform(a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0)

public func concatenating(_ transform: CGAffineTransform) -> CGAffineTransform {
preconditionFailure("Unimplemented")
}

public func inverted() -> CGAffineTransform {
preconditionFailure("Unimplemented")
}
}

extension CGPoint {
public func applying(_ t: CGAffineTransform) -> CGPoint {
preconditionFailure("Unimplemented")
}
}

extension CGSize {
public func applying(_ t: CGAffineTransform) -> CGSize {
preconditionFailure("Unimplemented")
}
}

extension CGRect {
public func applying(_ t: CGAffineTransform) -> CGRect {
preconditionFailure("Unimplemented")
}
}

#endif
21 changes: 21 additions & 0 deletions Sources/CoreGraphicsShims/CGLine.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// CGLine.swift
// CoreGraphicsShims

#if !canImport(CoreGraphics)

/// Line join styles
public enum CGLineJoin: Int32, @unchecked Sendable {
case miter = 0
case round = 1
case bevel = 2
}

/// Line cap styles
public enum CGLineCap : Int32, @unchecked Sendable {
case butt = 0
case round = 1
case square = 2
}

#endif
9 changes: 9 additions & 0 deletions Sources/CoreGraphicsShims/Export.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Export.swift
// CoreGraphicsShims

#if canImport(CoreGraphics)
@_exported import CoreGraphics
#else
@_exported import CoreFoundation
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,30 @@ extension DynamicTypeSize {
}
}

extension LayoutDirection {
/// Create a direction from its UITraitEnvironmentLayoutDirection equivalent.
public init?(_ uiLayoutDirection: UITraitEnvironmentLayoutDirection) {
switch uiLayoutDirection {
case .unspecified:
return nil
case .leftToRight:
self = .leftToRight
case .rightToLeft:
self = .rightToLeft
@unknown default:
return nil
}
}
}

extension UITraitEnvironmentLayoutDirection {
/// Creates a trait environment layout direction from the specified OpenSwiftUI layout direction.
public init(_ layoutDirection: LayoutDirection) {
switch layoutDirection {
case .leftToRight: self = .leftToRight
case .rightToLeft: self = .rightToLeft
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,8 @@
// Audited for iOS 18.0
// Status: Complete

#if canImport(CoreGraphics)
package import CoreGraphics
#else
package import CoreGraphicsShims
package import Foundation
// FIXME: Use Silica or other implementation
public struct CGAffineTransform: Equatable {
public init() {
a = .zero
b = .zero
c = .zero
d = .zero
tx = .zero
ty = .zero
}

public init(a: Double, b: Double, c: Double, d: Double, tx: Double, ty: Double) {
self.a = a
self.b = b
self.c = c
self.d = d
self.tx = tx
self.ty = ty
}

public var a: Double
public var b: Double
public var c: Double
public var d: Double
public var tx: Double
public var ty: Double

public static let identity = CGAffineTransform(a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0)

public func concatenating(_ transform: CGAffineTransform) -> CGAffineTransform {
preconditionFailure("Unimplemented")
}

public func inverted() -> CGAffineTransform {
preconditionFailure("Unimplemented")
}
}
#endif

extension CGAffineTransform {
package init(rotation: Angle) {
Expand Down
Loading
Loading