fix(macos): fix compilation errors for macOS target#2868
Closed
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Closed
fix(macos): fix compilation errors for macOS target#2868Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Conversation
[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>
|
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andLibraries/LinkingIOS/macos/RCTLinkingManager.mm(macOS) define@implementation RCTLinkingManagerwithout any platform guards. When both files are compiled for macOS (which happens with SPM since the target path isLibraries/LinkingIOS/), this causes:@implementation RCTLinkingManagerdefinitionsUIApplication,UIApplicationOpenURLOptionsKey,UIApplicationLaunchOptionsURLKey,UIApplicationOpenSettingsURLString, andUIUserActivityRestoringwhich don't exist on macOSFix:
#if !TARGET_OS_OSX/#endif#if TARGET_OS_OSX/#endifThe header (
RCTLinkingManager.h) already has correct#if !TARGET_OS_OSXguards.RCTLinkingManager (macOS) — missing TurboModule methods
The macOS implementation was missing methods required by the
NativeLinkingManagerSpecTurboModule spec:openSettings:resolve:reject:— opens System Preferences on macOSsendIntent:extras:resolve:reject:— stub (Android-only API)getTurboModule:— required for TurboModule registrationAlso added:
NativeLinkingManagerSpecprotocol conformance"RCTLinkingManager.h"to<React/RCTLinkingManager.h>for header search path consistency#import <React/RCTLog.h>forRCTLogErrorRCTCursor.m — missing AppKit import
The file uses
NSCursorextensively (an AppKit class) but only imported<Foundation/Foundation.h>. Added#import <AppKit/AppKit.h>inside a#if TARGET_OS_OSXguard.RCTViewComponentView.mm — duplicate cursor check
Lines 339-347 contained an identical cursor property check twice (copy-paste error). Removed the duplicate.
Test plan
RNTesterscheme)RNTester-macOSscheme)RNTester-visionOSscheme)Linking.openURL()works on macOSLinking.openSettings()works on macOS🤖 Generated with Claude Code