Skip to content

RU-T50 Build fix#244

Open
ucswift wants to merge 1 commit into
masterfrom
develop
Open

RU-T50 Build fix#244
ucswift wants to merge 1 commit into
masterfrom
develop

Conversation

@ucswift
Copy link
Copy Markdown
Member

@ucswift ucswift commented May 13, 2026

Summary by CodeRabbit

Bug Fixes

  • Resolved iOS build failures on Xcode 26+ that were caused by module import resolution conflicts, allowing applications to compile successfully.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

The PR enhances the WebRTC framework fix plugin by adding a new patching phase that automatically injects the RNFBAppModule header import into the RNFBMessaging+AppDelegate.h file, resolving iOS module resolution issues. The plugin documentation is updated to reflect this third error class fix alongside the existing two Podfile and post-install hook patches.

Changes

iOS Build Error Fix Enhancement

Layer / File(s) Summary
RNFBMessaging header import patch
plugins/withWebRTCFrameworkFix.js
Plugin documentation is expanded to describe three Xcode 26+ error fixes. A new implementation block patches @react-native-firebase/messaging's RNFBMessaging+AppDelegate.h by locating the file, checking for #import <RNFBApp/RNFBAppModule.h>, and inserting it after the last #import line if absent before writing the file back to disk.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Resgrid/Unit#241: Both PRs modify plugins/withWebRTCFrameworkFix.js to adjust iOS build settings for Xcode 26+ compatibility with framework configuration and Podfile patching logic.
  • Resgrid/Unit#243: Both PRs extend plugins/withWebRTCFrameworkFix.js with framework patching logic; this PR adds the RNFBMessaging header import patch as a third error fix phase.
  • Resgrid/Unit#242: Both PRs update plugins/withWebRTCFrameworkFix.js for iOS Xcode 26+ build error handling, with this PR adding an additional RNFBMessaging header import patching phase.

Poem

🐇 A rabbit hops through framework files with glee,
Patching headers where imports ought to be,
From Xcode's maze, three errors now are fixed,
With modular headers and imports well-mixed! 🏗️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'RU-T50 Build fix' is vague and lacks specificity about the actual changes made to the WebRTC plugin and the iOS build issues being resolved. Consider using a more descriptive title that explains the specific build fix, such as 'Fix RNFBMessaging iOS build errors by adding RNFBAppModule import' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
plugins/withWebRTCFrameworkFix.js (2)

93-107: ⚡ Quick win

Consider logging or warning when file doesn't exist for consistency.

The first two fix phases throw explicit errors when they can't apply their patches (e.g., lines 55 and 72-75), but this third phase silently skips if the file doesn't exist. While this might be intentional if the dependency is optional, it creates an inconsistency in error handling that could make debugging harder.

Consider adding a console warning or logging when the file is not found, so developers know whether the patch was applied.

📢 Proposed enhancement to add logging
       if (fs.existsSync(appDelegatePath)) {
         let appDelegate = fs.readFileSync(appDelegatePath, 'utf-8');
         const rnfbImport = '#import <RNFBApp/RNFBAppModule.h>';
         if (!appDelegate.includes(rnfbImport)) {
           // Insert after the last `#import` line.
           const lastImportIdx = appDelegate.lastIndexOf('#import');
           const endOfLine = appDelegate.indexOf('\n', lastImportIdx);
           appDelegate =
             appDelegate.slice(0, endOfLine + 1) +
             rnfbImport +
             '\n' +
             appDelegate.slice(endOfLine + 1);
           fs.writeFileSync(appDelegatePath, appDelegate);
         }
+      } else {
+        console.warn(
+          '[withWebRTCFrameworkFix] RNFBMessaging+AppDelegate.h not found — skipping phase 3 patch'
+        );
       }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/withWebRTCFrameworkFix.js` around lines 93 - 107, The code currently
silently skips patching when fs.existsSync(appDelegatePath) is false; add a
warning in the else branch to make this consistent with earlier phases: after
the existing if (fs.existsSync(appDelegatePath)) { ... } block add an else {
console.warn(`withWebRTCFrameworkFix: appDelegate file not found at
${appDelegatePath}, skipping RNFBApp import patch`); } so developers see when
appDelegatePath could not be patched (reference symbols: fs.existsSync,
appDelegatePath, rnfbImport).

1-115: 💤 Low value

Filename uses camelCase instead of kebab-case per coding guidelines.

The coding guidelines specify that directory and file names should be lowercase and hyphenated (e.g., user-profile, chat-screen). This file is named withWebRTCFrameworkFix.js using camelCase.

However, it's worth noting that this naming pattern (withX) is idiomatic for Expo config plugins and aligns with ecosystem conventions. Consider whether project-level consistency or ecosystem conventions should take precedence. As per coding guidelines, the pattern **/* requires lowercase and hyphenated names.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/withWebRTCFrameworkFix.js` around lines 1 - 115, The file name uses
camelCase (withWebRTCFrameworkFix.js) but our guidelines require lowercase
kebab-case; rename the file to with-webrtc-framework-fix.js and update any
imports/requires that reference this module (look for require/import of
withWebRTCFrameworkFix and the module.exports = withWebRTCFrameworkFix line to
ensure callers point to the new filename), and verify any Expo config plugin
registration or package.json/plugin lists are updated to the new kebab-case path
so the exported function withWebRTCFrameworkFix continues to be resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/withWebRTCFrameworkFix.js`:
- Around line 98-104: The code assumes lastImportIdx =
appDelegate.lastIndexOf('#import') is found; add validation so if lastImportIdx
=== -1 you choose a safe insertion point (e.g., set endOfLine to the index of
the first newline or 0 to prepend the import) instead of using indexOf with -1;
also guard the computed endOfLine (from appDelegate.indexOf('\n',
lastImportIdx)) so if endOfLine === -1 set it to appDelegate.length - 1 (or 0
for prepend) before building the new string; update the logic around
lastImportIdx, endOfLine, appDelegate and rnfbImport to use these validated
values to avoid duplicating or corrupting the file.

---

Nitpick comments:
In `@plugins/withWebRTCFrameworkFix.js`:
- Around line 93-107: The code currently silently skips patching when
fs.existsSync(appDelegatePath) is false; add a warning in the else branch to
make this consistent with earlier phases: after the existing if
(fs.existsSync(appDelegatePath)) { ... } block add an else {
console.warn(`withWebRTCFrameworkFix: appDelegate file not found at
${appDelegatePath}, skipping RNFBApp import patch`); } so developers see when
appDelegatePath could not be patched (reference symbols: fs.existsSync,
appDelegatePath, rnfbImport).
- Around line 1-115: The file name uses camelCase (withWebRTCFrameworkFix.js)
but our guidelines require lowercase kebab-case; rename the file to
with-webrtc-framework-fix.js and update any imports/requires that reference this
module (look for require/import of withWebRTCFrameworkFix and the module.exports
= withWebRTCFrameworkFix line to ensure callers point to the new filename), and
verify any Expo config plugin registration or package.json/plugin lists are
updated to the new kebab-case path so the exported function
withWebRTCFrameworkFix continues to be resolved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a45a1119-49d3-4766-ac44-0128015091f3

📥 Commits

Reviewing files that changed from the base of the PR and between 6582984 and 8ed2f51.

📒 Files selected for processing (1)
  • plugins/withWebRTCFrameworkFix.js

Comment on lines +98 to +104
const lastImportIdx = appDelegate.lastIndexOf('#import');
const endOfLine = appDelegate.indexOf('\n', lastImportIdx);
appDelegate =
appDelegate.slice(0, endOfLine + 1) +
rnfbImport +
'\n' +
appDelegate.slice(endOfLine + 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add validation for missing #import statements to prevent file corruption.

The code assumes lastIndexOf('#import') will find an import, but if the file contains no #import statements, lastImportIdx will be -1. When passed to indexOf('\n', -1), JavaScript's indexOf treats negative positions as 0, causing endOfLine to reference the first newline in the file rather than a position after an import. This results in inserting the new import at an incorrect location, potentially corrupting the header file.

Additionally, if endOfLine is -1 (no newline found after the last import), the slice(endOfLine + 1) becomes slice(0), which would duplicate the entire file content.

🛡️ Proposed fix to add validation
       if (!appDelegate.includes(rnfbImport)) {
         // Insert after the last `#import` line.
         const lastImportIdx = appDelegate.lastIndexOf('#import');
+        if (lastImportIdx === -1) {
+          throw new Error(
+            '[withWebRTCFrameworkFix] No `#import` statements found in RNFBMessaging+AppDelegate.h'
+          );
+        }
         const endOfLine = appDelegate.indexOf('\n', lastImportIdx);
+        if (endOfLine === -1) {
+          throw new Error(
+            '[withWebRTCFrameworkFix] No newline found after last `#import` in RNFBMessaging+AppDelegate.h'
+          );
+        }
         appDelegate =
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const lastImportIdx = appDelegate.lastIndexOf('#import');
const endOfLine = appDelegate.indexOf('\n', lastImportIdx);
appDelegate =
appDelegate.slice(0, endOfLine + 1) +
rnfbImport +
'\n' +
appDelegate.slice(endOfLine + 1);
const lastImportIdx = appDelegate.lastIndexOf('#import');
if (lastImportIdx === -1) {
throw new Error(
'[withWebRTCFrameworkFix] No `#import` statements found in RNFBMessaging+AppDelegate.h'
);
}
const endOfLine = appDelegate.indexOf('\n', lastImportIdx);
if (endOfLine === -1) {
throw new Error(
'[withWebRTCFrameworkFix] No newline found after last `#import` in RNFBMessaging+AppDelegate.h'
);
}
appDelegate =
appDelegate.slice(0, endOfLine + 1) +
rnfbImport +
'\n' +
appDelegate.slice(endOfLine + 1);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/withWebRTCFrameworkFix.js` around lines 98 - 104, The code assumes
lastImportIdx = appDelegate.lastIndexOf('#import') is found; add validation so
if lastImportIdx === -1 you choose a safe insertion point (e.g., set endOfLine
to the index of the first newline or 0 to prepend the import) instead of using
indexOf with -1; also guard the computed endOfLine (from
appDelegate.indexOf('\n', lastImportIdx)) so if endOfLine === -1 set it to
appDelegate.length - 1 (or 0 for prepend) before building the new string; update
the logic around lastImportIdx, endOfLine, appDelegate and rnfbImport to use
these validated values to avoid duplicating or corrupting the file.

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