Skip to content

fix(expo): support Swift AppDelegate without public#1123

Merged
zibs merged 5 commits into
mainfrom
fix/expo56
Jul 6, 2026
Merged

fix(expo): support Swift AppDelegate without public#1123
zibs merged 5 commits into
mainfrom
fix/expo56

Conversation

@zibs

@zibs zibs commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #

Description

Fixes the Expo config plugin for Swift AppDelegate templates that omit the public class modifier, as generated by newer Expo SDKs.

The plugin now applies the AppAuth Swift AppDelegate changes idempotently and independently:

  • Adds RNAppAuthAuthorizationFlowManager protocol conformance.
  • Adds authorizationFlowManagerDelegate.
  • Adds the URL resume block for external auth flows.
  • Preserves older public class AppDelegate: ExpoAppDelegate templates.
  • Preserves existing protocol conformances.

Also adds a patch changeset and focused tests for the AppDelegate patch behavior.

Steps to verify

  • Run plugin typecheck:

    yarn workspace react-native-app-auth build
  • Run the plugin AppDelegate tests:

    yarn workspace react-native-app-auth test:plugin
  • In an Expo SDK 56 app using react-native-app-auth, run:

    npx expo prebuild --platform ios

    Confirm generated ios/<app>/AppDelegate.swift includes:

    class AppDelegate: ExpoAppDelegate, RNAppAuthAuthorizationFlowManager
  • Launch the iOS app and complete an auth flow. The app should no longer crash with:

    RNAppAuth Missing protocol conformance
    

@zibs zibs requested a review from Copilot July 2, 2026 20:58
@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec2fce5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-native-app-auth Patch

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

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-app-auth Ready Ready Preview, Comment Jul 6, 2026 3:48pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via withAppDelegate.
  • 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.

Comment thread packages/react-native-app-auth/plugin/src/ios/app-delegate.ts Outdated
Comment thread packages/react-native-app-auth/plugin/src/ios/app-delegate.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread packages/react-native-app-auth/plugin/src/expo-version.ts
zibs and others added 2 commits July 3, 2026 10:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

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?`
@zibs zibs merged commit c0b9d46 into main Jul 6, 2026
3 checks passed
@zibs zibs deleted the fix/expo56 branch July 6, 2026 15:54
@github-actions github-actions Bot mentioned this pull request Jul 6, 2026
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.

2 participants