Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ Pod::Spec.new do |s|
s.module_name = "RCTSwiftUI"
s.header_dir = "RCTSwiftUI"

# [macOS] Expose the React_RCTUIKit clang module to Swift so
# RCTSwiftUIContainerView.swift can `import React_RCTUIKit` and pick up
# the ObjC `@compatibility_alias RCTUIColor → NSColor` / `RCTPlatformView`
# without re-declaring them as Swift typealiases. The dep is harmless on
# iOS (the umbrella headers are mostly typedef-only there); kept
# unconditional to preserve parity with the rest of the apple pods.
s.dependency "React-RCTUIKit"

# Swift-specific configuration
s.pod_target_xcconfig = {
"SWIFT_VERSION" => "5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
*/

import SwiftUI
// [macOS] Pull in the ObjC @compatibility_alias declarations for
// `RCTPlatformView` (UIView/NSView) and `RCTUIColor` (UIColor/NSColor)
// from RCTUIKit. Without this import the Swift file used to re-declare
// these as local `public typealias`es, which shadowed the ObjC aliases
// and forced every consumer of this module to choose between the Swift
// and ObjC name. After the React-RCTUIKit pod dep is wired in
// RCTSwiftUI.podspec, the import is the canonical source of truth.
// `RCTPlatformHostingController` stays as a Swift typealias below — it
// wraps NSHostingController / UIHostingController which are SwiftUI
// generics and not in the ObjC compat layer.
import React_RCTUIKit
#if os(macOS) // [macOS
import AppKit
#else
import UIKit
#endif // macOS]

#if os(macOS) // [macOS
public typealias RCTPlatformView = NSView
public typealias RCTUIColor = NSColor
public typealias RCTPlatformHostingController = NSHostingController
#else
public typealias RCTPlatformView = UIView
public typealias RCTUIColor = UIColor
public typealias RCTPlatformHostingController = UIHostingController
#endif // macOS]

Expand Down