Skip to content

fix(macos): fix compilation errors for macOS target#2868

Closed
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Saadnajmi:saad/fix-macos-porting-bugs
Closed

fix(macos): fix compilation errors for macOS target#2868
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Saadnajmi:saad/fix-macos-porting-bugs

Conversation

@Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Mar 23, 2026

Summary

Fixes several macOS compilation issues that surface when building for macOS targets (e.g. via SPM or when CocoaPods compiles both iOS and macOS source files together).

RCTLinkingManager — duplicate symbol & UIKit compilation errors

Both Libraries/LinkingIOS/RCTLinkingManager.mm (iOS) and Libraries/LinkingIOS/macos/RCTLinkingManager.mm (macOS) define @implementation RCTLinkingManager without any platform guards. When both files are compiled for macOS (which happens with SPM since the target path is Libraries/LinkingIOS/), this causes:

  1. Duplicate symbol errors — two @implementation RCTLinkingManager definitions
  2. UIKit compilation failures — the iOS file references UIApplication, UIApplicationOpenURLOptionsKey, UIApplicationLaunchOptionsURLKey, UIApplicationOpenSettingsURLString, and UIUserActivityRestoring which don't exist on macOS

Fix:

  • iOS file: wrapped with #if !TARGET_OS_OSX / #endif
  • macOS file: wrapped with #if TARGET_OS_OSX / #endif

The header (RCTLinkingManager.h) already has correct #if !TARGET_OS_OSX guards.

RCTLinkingManager (macOS) — missing TurboModule methods

The macOS implementation was missing methods required by the NativeLinkingManagerSpec TurboModule spec:

  • openSettings:resolve:reject: — opens System Preferences on macOS
  • sendIntent:extras:resolve:reject: — stub (Android-only API)
  • getTurboModule: — required for TurboModule registration

Also added:

  • NativeLinkingManagerSpec protocol conformance
  • Fixed import from "RCTLinkingManager.h" to <React/RCTLinkingManager.h> for header search path consistency
  • Added missing #import <React/RCTLog.h> for RCTLogError

RCTCursor.m — missing AppKit import

The file uses NSCursor extensively (an AppKit class) but only imported <Foundation/Foundation.h>. Added #import <AppKit/AppKit.h> inside a #if TARGET_OS_OSX guard.

RCTViewComponentView.mm — duplicate cursor check

Lines 339-347 contained an identical cursor property check twice (copy-paste error). Removed the duplicate.

Test plan

  • Build RNTester for iOS (RNTester scheme)
  • Build RNTester for macOS (RNTester-macOS scheme)
  • Build RNTester for visionOS (RNTester-visionOS scheme)
  • Verify Linking.openURL() works on macOS
  • Verify Linking.openSettings() works on macOS
  • Verify cursor rendering on macOS Fabric components

🤖 Generated with Claude Code

Saadnajmi and others added 2 commits March 21, 2026 00:26
[pull] main from microsoft:main
- RCTLinkingManager.mm: wrap iOS implementation with #if !TARGET_OS_OSX
  guard to prevent UIKit API compilation on macOS
- RCTLinkingManager.mm (macOS): wrap with #if TARGET_OS_OSX, add missing
  openSettings/sendIntent/getTurboModule methods for TurboModule spec
  conformance, fix import paths, add NativeLinkingManagerSpec protocol
- RCTCursor.m: add missing #import <AppKit/AppKit.h> for NSCursor usage
- RCTViewComponentView.mm: remove duplicate cursor property check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi requested a review from a team as a code owner March 23, 2026 03:24
@changeset-bot
Copy link

changeset-bot bot commented Mar 23, 2026

⚠️ No Changeset found

Latest commit: bff98a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Saadnajmi Saadnajmi closed this Mar 23, 2026
@Saadnajmi Saadnajmi deleted the saad/fix-macos-porting-bugs branch March 23, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant