fix(expo): support Swift AppDelegate without public#1123
Merged
Conversation
🦋 Changeset detectedLatest commit: ec2fce5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Expo config plugin’s iOS AppDelegate patching to support newer Swift AppDelegate templates that omit public, and introduces a more structured/idempotent patch function with focused tests.
Changes:
- Refactors the Swift AppDelegate patch into
applyExpo53AppDelegatePatch(...)and applies it viawithAppDelegate. - Expands Expo SDK detection logic (including reading
package.json) and adds an Expo 53+ assertion helper. - Adds targeted unit tests for the AppDelegate patch behavior and a patch changeset.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react-native-app-auth/plugin/src/ios/app-delegate.ts | Introduces an Expo 53+ Swift AppDelegate patch function and adjusts plugin wiring for applying it. |
| packages/react-native-app-auth/plugin/src/expo-version.ts | Adds SDK major parsing + package.json fallback and introduces an assertion helper. |
| packages/react-native-app-auth/plugin/src/tests/app-delegate.test.ts | Adds tests validating the new Swift AppDelegate patch behavior and idempotency. |
| .changeset/fix-expo-swift-appdelegate.md | Publishes a patch-level changeset for the Swift AppDelegate template fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+30
to
39
| if (!APP_AUTH_DELEGATE_PROPERTY_PATTERN.test(contents)) { | ||
| const reactNativeFactoryPattern = | ||
| /^(\s*)(?:public\s+)?var\s+reactNativeFactory\s*:\s*RCTReactNativeFactory\?\s*$/m; | ||
| const factoryMatch = contents.match(reactNativeFactoryPattern); | ||
| if (factoryMatch) { | ||
| const indent = factoryMatch[1]; | ||
| contents = contents.replace( | ||
| replaceText3, | ||
| `${replaceText3}\n\n public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate?` | ||
| reactNativeFactoryPattern, | ||
| match => `${match}\n\n${indent}${APP_AUTH_DELEGATE_PROPERTY}` | ||
| ); |
Comment on lines
+18
to
27
| contents = contents.replace( | ||
| /^(\s*(?:public\s+)?class\s+AppDelegate\s*:\s*ExpoAppDelegate)([^{]*)(\{)/m, | ||
| (match, declaration, conformances, openingBrace) => { | ||
| const trimmedConformances = conformances.trim(); | ||
| if (trimmedConformances.includes(APP_AUTH_PROTOCOL)) { | ||
| return match; | ||
| } | ||
|
|
||
| return `${declaration}${trimmedConformances}, ${APP_AUTH_PROTOCOL} ${openingBrace}`; | ||
| } |
Comment on lines
+32
to
+35
| expect(result).toContain('class AppDelegate: ExpoAppDelegate, RNAppAuthAuthorizationFlowManager {'); | ||
| expect(result).toContain( | ||
| 'public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate?' | ||
| ); |
Comment on lines
+61
to
+64
| ` var reactNativeFactory: RCTReactNativeFactory? | ||
|
|
||
| public weak var authorizationFlowManagerDelegate: | ||
| RNAppAuthAuthorizationFlowManagerDelegate?` |
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.
Fixes #
Description
Fixes the Expo config plugin for Swift
AppDelegatetemplates that omit thepublicclass modifier, as generated by newer Expo SDKs.The plugin now applies the AppAuth Swift
AppDelegatechanges idempotently and independently:RNAppAuthAuthorizationFlowManagerprotocol conformance.authorizationFlowManagerDelegate.public class AppDelegate: ExpoAppDelegatetemplates.Also adds a patch changeset and focused tests for the AppDelegate patch behavior.
Steps to verify
Run plugin typecheck:
Run the plugin AppDelegate tests:
In an Expo SDK 56 app using
react-native-app-auth, run:Confirm generated
ios/<app>/AppDelegate.swiftincludes:Launch the iOS app and complete an auth flow. The app should no longer crash with: