-
Notifications
You must be signed in to change notification settings - Fork 49
docs(react-native): update deep link setup instructions #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
victoreronmosele
wants to merge
3
commits into
kinde-oss:main
Choose a base branch
from
victoreronmosele:chore/upgrade-react-native-sdk-setup-instructions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+135
−139
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3470996
docs(react-native): update deep link setup for iOS (Objective-C)
victoreronmosele 5f1821c
docs(react-native): update deep link setup for iOS (Swift)
victoreronmosele 5643ca8
docs(react-native) update deep linking iOS set-up instructions
victoreronmosele File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
#import <React/RCTLinkingManager.h>in the bridging header — build will fail.AppDelegate+RNAppAuth.honly importsRNAppAuthAuthorizationFlowManager.h, butRCTLinkingManageris called directly in both the custom-scheme and universal-link Swift methods added in Step 3. Without exposing that header to Swift, the project won't compile.React Native App Auth's own docs note that a bridging header is needed to bridge the Objective-C code the package uses, and
AppDelegate+RNAppAuth.his the file to create. That file must also include every header you'll be referring to from Swift code — for React Native, the fundamental headers come from the React static library and need to be explicitly listed, including#import <React/RCTLinkingManager.h>.Additionally, Step 2 instructs developers to replace the Objective-C Bridging Header setting with this new file. Projects that already have a bridging header configured (common in customised RN projects) will lose those imports. The instructions should clarify: if a bridging header already exists, add the import(s) to that existing file instead of creating a new one and changing the path.
🐛 Proposed fix for the bridging header content
```objc title="AppDelegate+RNAppAuth.h" + `#import` <React/RCTLinkingManager.h> `#import` "RNAppAuthAuthorizationFlowManager.h"Verify each finding against the current code and only fix it if needed.
In
@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdxaroundlines 186 - 202, The bridging header guidance is incomplete: ensure
AppDelegate+RNAppAuth.h (or your existing Objective-C Bridging Header) also
imports RCTLinkingManager so Swift can call RCTLinkingManager methods used by
RNAppAuth; add
#import<React/RCTLinkingManager.h> alongside the existingRNAppAuthAuthorizationFlowManager import, and update Step 2 to instruct
developers to add these imports to their existing bridging header instead of
replacing it if one already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project does compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
To use
RCTLinkingManagerfrom Swift, you typically don’t import it in Swift directly—you expose the Objective‑C header to Swift via an Objective‑C bridging header, then call it fromAppDelegate.swift.1) Add
RCTLinkingManagerto your bridging headerCreate (or edit)
ios/<YourApp>/<YourApp>-Bridging-Header.hand add:This is a common React Native Swift bridging-header pattern and explicitly includes
RCTLinkingManagerfor Swift visibility. [1]Also make sure Xcode is pointing at the file:
Build Settings → Swift Compiler - General → Objective-C Bridging Header (set the relative path). [2]
2) Forward deep links in
AppDelegate.swiftIn your
AppDelegate.swift, forward URL opens to React Native:This is the standard Swift equivalent of the Objective‑C
openURLforwarding. [3]Universal Links (optional)
[4]
Notes / common gotchas
openURL, you must combine the handlers into oneopenURLmethod (iOS only allows one). [5]Sources: [1] [2] [3] [4] [5]
🌐 Web query:
💡 Result:
To use
RCTLinkingManagerfrom Swift in a React Native 0.70 iOS app, you have two workable paths:Option A (most common): Use a Bridging Header (no Swift
import Reactneeded)Create/ensure you have an Objective‑C bridging header (e.g.
YourApp-Bridging-Header.h).Add:
(RN’s Swift/native-module docs call out that Swift↔ObjC interop requires a bridging header that imports the React headers you need.) [1]
In
AppDelegate.swift, callRCTLinkingManagernormally (noimport Reactrequired).A common gotcha: make sure the
#import <React/RCTLinkingManager.h>is actually compiled via the bridging header / correct target settings; otherwise Xcode will complain it can’t find the header. [2]Option B: Enable an auto-generated module map so Swift can
import ReactIf your goal is specifically “Swift automatic import” (i.e.
import React), you need the React pods to define modules (generate module maps). CocoaPods’ standard fix is to enable modular headers:ios/Podfileadd one of:use_modular_headers!(global), or:modular_headers => truefor specific podsThis is the documented CocoaPods approach when Swift pods (or Swift code) need module maps for dependencies that “do not define modules.” [3]
Then run:
cd ios rm -rf Pods Podfile.lock pod installWhich should you pick?
RCTLinkingManagerin the app delegate, Option A is usually simplest.import Reactin Swift across the app (and avoid bridging-header imports), use Option B.Sources: React Native Swift/bridging-header guidance [1],
RCTLinkingManagerheader import workaround [2], CocoaPods modular-headers/module-map requirement explanation [3].@victoreronmosele, thank you for the clarification! I stand corrected. If the project compiles successfully without explicitly importingRCTLinkingManagerin the bridging header, then my concern was unfounded.It's possible that React Native's build configuration or module maps are making
RCTLinkingManageravailable to Swift through other mechanisms (such as modular headers via CocoaPods). Since you've tested this and confirmed it works, the documentation as written should be fine.I appreciate you taking the time to verify and correct my review comment!
🧠 Learnings used