Skip to content

Objective-C app targets: React Native headers by bare name, C++ standard - #35

Merged
WillyAntunez merged 16 commits into
mainfrom
fix/bare-rn-includes
Nov 6, 2026
Merged

WillyAntunez merged 16 commits into
mainfrom
fix/bare-rn-includes

Conversation

@WillyAntunez

@WillyAntunez WillyAntunez commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Objective-C app targets: React Native headers by bare name

Follow-up to #33 and #34. With its headers copied, a bare React Native 0.85 app with an Objective-C app target failed at the first line of its AppDelegate.h, #import <RCTAppDelegate.h>, with 'RCTAppDelegate.h' file not found; its AppDelegate.mm also does #import <AppAuth/AppAuth.h>, as react-native-app-auth's README asks. With CocoaPods both spellings work because the app target's HEADER_SEARCH_PATHS lists every pod's public header directory. rn-xtool's App target saw only the root of the React Native headers farm (<React/RCTAppDelegate.h> resolved, <RCTAppDelegate.h> did not) and nothing of the scaffold's rn-spm-pod-headers forwards. Not a release: the notes stay under [Unreleased].

What users get

  • React Native's public headers are importable by their bare name from a bare app's Objective-C and bridging header, as with CocoaPods. After the app's own include/ forwards and its HEADER_SEARCH_PATHS, the App target's clang flags and the bridging header's -Xcc flags get ReactHeadersTarget/include/React and the per-module folders of ReactNativeHeaders.xcframework (read from the device slice's module.modulemap, in its order: CoreModules, RCTAnimation, RCTBlob, RCTDeprecation, RCTImage, RCTSettings, RCTSwiftUIWrapper, RCTText, RCTVibration, ReactCommon, React_RCTAppDelegate, reactperflogger, yoga on 0.86 and 0.88). On 0.85 and 0.86 RCTAppDelegate.h exists only under React_RCTAppDelegate/, so the per-module folders are what makes <RCTAppDelegate.h> resolve there. An app header with the same name still wins.
  • The pod table's forwardHeaders spellings reach the app. Each autolinked library's rn-spm-pod-headers folder is on the same path, so #import <AppAuth/AppAuth.h> resolves from AppDelegate.mm as it does inside react-native-app-auth.
  • Objective-C++ and C++ files of the app target compile with the project's C++ standard. Swift Build does not apply the package's cxxLanguageStandard to a mixed-language target, so an AppDelegate.mm that imports <RCTAppDelegate.h> (which pulls in Fabric's C++ headers on 0.85) compiled with clang's default (gnu++17) and failed in react/utils/hash_combine.h with unknown type name 'Hashable'. The App target's cxxSettings (not cSettings) now carry -std= from CLANG_CXX_LANGUAGE_STANDARD, mapped the same way as the package-level cxxLanguageStandard (gnu++20 → -std=gnu++20, c++2a → -std=c++20, unset or unknown → -std=c++20), as the scaffolder already does for mixed libraries. Reference apps never hit it because their only Objective-C file was a .m.
  • Pod header forwarders compile in Objective-C++. The scaffold's rn-spm-pod-headers/AppAuth/AppAuth.h held @import AppAuthCore; and @import AppAuth;. Swift Build compiles .mm files with -fmodules -fno-cxx-modules, as Xcode does by default, so once AppDelegate.mm reached the forwarder it stopped with use of '@import' when modules are disabled; it had only worked because react-native-app-auth's own RNAppAuth.m is Objective-C. The forwarder now #imports the pod's public headers, by their paths under the public header directories of its SwiftPM targets, which every importer has on its include path. In a .m file such an #import still loads the module. pods.<pod>.forwardHeaders changes format to match: a forwarded header maps to a list of headers, and a module name (the old form) is refused with a message that names the entry and says to list the pod's public headers. rn-xtool's AppAuth entry lists what AppAuth-iOS 3.0.0's umbrella Sources/AppAuth.h includes: 26 headers from Sources/AppAuthCore, then the 5 of its TARGET_OS_IOS || TARGET_OS_MACCATALYST branch, as iOS/OIDAuthState+IOS.h and so on. Those 5 headers already wrap themselves in that same condition, so the forwarder lists them without its own #if. The scaffold revision goes to 5, so a scaffold copy in node_modules from 0.1.0-alpha.6 is regenerated by itself, and a persisted scaffold patch gets the existing "older rn-xtool scaffolder (revision 4, now 5)" warning.
  • A library that was also built for Android gets its scaffold persisted. patch-package diffs the whole installed package against a clean copy, and Gradle builds an Android library in place under node_modules/<lib>/android/build (and .cxx), so those outputs went into the scaffold patch and the binary-file guard refused it at every build. The scaffold result now lists the files it wrote under the library (Package.swift, Package@swift-6.5.swift, the prefix header, the include/ stubs, the module map, rn-spm-swift/, rn-spm-react-headers/, rn-spm-pod-headers/, and package.json when it records swiftpmConfig.name), the driver passes the list through its results file, and rn-xtool runs patch-package with --include set to those paths plus every path the library's existing patches hold (each anchored and escaped), so a hand fix in a user's patch stays and nothing else enters it; --exclude is unchanged. Past 200 paths, the directories the scaffolder owns whole collapse to a prefix. When an existing patch's diff --git headers cannot be read, the result lists no files, or the list would not fit in one argument, it diffs the whole package as before and says so in one ℹ line. The binary guard stays as the last check. What a scaffold writes is unchanged, so the scaffold revision stays 5; both 0.88 patches carry the scaffolder change. Docs: docs/how-it-works.md, the persist guard entry in docs/troubleshooting.md, and a CHANGELOG line under ### Fixed.
  • The podspec reader evaluates Ruby locals and conditions, and refuses what it cannot read in a source glob. react-native-screens 4.24.0 builds source_files from source_files_exts = new_arch_enabled ? '…' : '…', source_files = ["ios/**/*.#{source_files_exts}"], a conditional .push and an if/else around exclude_files; the reader left #{source_files_exts} in the glob, so the scaffolded RNScreens target held only the common subspec's C++ and no Objective-C class, and the app crashed at start. The regex reader's constants pass becomes a side-effect-free evaluator (scaffolder fix 28) that runs the podspec's statements in order: locals (=, +=, ||=), strings with #{…}, arrays and %w[], ENV['…']/ENV.fetch (RCT_NEW_ARCH_ENABLED and RCT_HERMES_V1_ENABLED are 1, every other variable unset, the shell never read), ==, !=, !, &&, ||, ternaries, +, join, if/elsif/else/unless blocks and modifiers, and push/<</concat on a local array. A branch its condition rules out is blanked; both branches of a condition it cannot evaluate (respond_to?(…), vision-camera's enableFrameProcessors) stay visible, as before. A source_files/exclude_files value that uses an unknown identifier or a method call fails that library's scaffold (Scaffolding <lib> failed: <podspec>: `s.source_files = <expr>` cannot be evaluated: …), so a future podspec idiom stops the build instead of crashing the app; name resolution and header search paths read the model as before. screens 4.24.0 now scaffolds 195 sources (147 under ios/), ios/gamma excluded and ios/stubs kept, as one clang-only target (all its Swift is under ios/gamma), with ios/bridging/Swift-Bridging.h left out of its module map. Output changes elsewhere: react-native-svg 15.16.0 no longer excludes apple/Utils/RNSVGFabricConversions.h (only its old-architecture else did), so that header joins its sources and its module map is no longer written; dead-else dependencies (React-Core, React-jsc) drop out of models. Any other ENV[...] now reads as unset instead of not at all (fix 19's test changes accordingly). The reader also models the library's own package.json (JSON.parse(File.read(File.join(__dir__, "package.json"))), also File.dirname(__FILE__), any key), hashes and symbols, keeps a string with an interpolation it cannot compute as a partial string with that #{…} as written (so fix 8 still gives REACT_NATIVE_MINOR_VERSION=#{…} the installed React Native's minor), and keeps a local set under an unevaluable condition for the rest of that branch. name, module_name and version stay literal-only (evaluating s.name = package['name'] would rename react-native-app-auth's and react-native-webview's targets). Besides the globs, an unevaluable compiler_flags, header_dir, header_mappings_dir, frameworks or libraries value fails the scaffold the same way; an unevaluable part of an xcconfig value the scaffolder reads (OTHER_CFLAGS, GCC_PREPROCESSOR_DEFINITIONS, HEADER_SEARCH_PATHS, SWIFT_ACTIVE_COMPILATION_CONDITIONS) is left out with a warning naming it (Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, …) rather than refused, because worklets, reanimated, vision-camera and gesture-handler put configuration-driven flags there that only CocoaPods computes, and they built and ran with them left out. The scaffold revision goes to 7, so scaffolds persisted with this branch's revisions 5 and 6 (the partial screens one, a worklets one without its defines) get the older-scaffolder warning. Both 0.88 patches are regenerated, and rn-xtool-edits.patch's read-podspec hunk header moved with the file.
  • A check that every class React Native's codegen providers name is in the packed app. After xtool-build (after the binary-pod checks), and in install/run on the app xtool builds before it installs (xtool builds first, as for binary pods, only when the providers name classes), every NSClassFromString(@"…") (or [X class]) of ios/build/generated/ios/ReactCodegen/RCTThirdPartyComponentsProvider.mm and every provider class of RCTModuleProviders.mm must be an _OBJC_CLASS_$_ symbol of the App binary or of a framework under App.app/Frameworks (Module.Class names map to Swift's _TtC… runtime name). A missing one removes the app and its .ipa and stops with React Native's codegen names classes the packed app does not define, so rn-xtool removed it and does not install it:, one line per class with its component or module and its library (the provider line's comment, else the library's codegenConfig.ios, else "a library"), the crash it would cause (+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents] throws NSInvalidArgumentException), or for a module that React Native would log it missing, and what to check (the library's Package.swift, a scaffold persisted by an older rn-xtool). A binary set with no ObjC class symbol at all is not refused: one ℹ line says nothing could be checked.
  • Expo projects' flags are unchanged.
  • Docs: the Mixed Swift + Objective-C/C++ section of docs/bare-react-native.md, a troubleshooting entry keyed by 'RCTAppDelegate.h' file not found (with 'AppAuth/AppAuth.h' file not found as a sibling symptom), and a CHANGELOG line under [Unreleased] → ### Fixed. For the forwarders: the forwardHeaders description in "Libraries that depend on CocoaPods pods", a troubleshooting entry keyed by use of '@import' when modules are disabled, the revision 5 warning entry, docs/how-it-works.md, fix 13 in docs/upstream/react-native-scaffolder.md, and CHANGELOG entries under ### Upgrading from 0.1.0-alpha.6, ### Changed and ### Fixed.

Verified

  • Layout per slot, on disk and in the code: stageReactHeadersTarget copies React.framework/Headers to a flat ReactHeadersTarget/include/React; on 0.88.1 React/RCTAppDelegate.h is a one-line forward to <React_RCTAppDelegate/RCTAppDelegate.h>; on 0.85.0 and 0.86.3 (VFS templates and the adapted 0.86 tree) React/ has no RCTAppDelegate.h at all.

  • Unit tests, written failing first: a bare mixed app's cSettings/cxxSettings and bridging-header flags carry React Native's bare-name folders after the app's own, then the libraries' rn-spm-pod-headers folders; an Expo app's manifest is byte-identical.

  • Imports of the real app resolved as files against the generated 0.88 trees with the new paths: <RCTAppDelegate.h>, <AppAuth/AppAuth.h> (missing before, found after); <React/RCTBundleURLProvider.h>, <ReactAppDependencyProvider/RCTAppDependencyProvider.h>, <RNAppAuth.h>, <React/RCTLinkingManager.h>, <React/RCTBridgeModule.h> (found before and after). A local clang with -fmodules compiles a header imported both by bare name and by module name, in either order, on stand-in headers.

  • Real build: the app's build with Objective-C app targets: every header the project references #34 stopped at 'RCTAppDelegate.h' file not found, which this addresses. A build with the bare-name paths got past every header and stopped on C++ errors in AppDelegate.mm (hash_combine.h, unknown type name 'Hashable'): its clang command line carried no -std=, which the C++ standard change addresses. No build with that change yet.

  • Real build, forwarders: the build with the C++ standard change compiled AppDelegate.mm up to #import <AppAuth/AppAuth.h> and stopped in the forwarder with use of '@import' when modules are disabled, which the textual forwarder addresses. The app's compile line carries -I for both AppAuth-iOS public header directories (Sources/AppAuthCore and Sources/AppAuth), which is where the forwarder's paths resolve. No build with this change yet.

  • Forwarders, unit tests written failing first: the written forwarder holds the banner and one #import <…> per listed header and no @import; a module name in the list is refused with its message, in the scaffolder and in the config check; malformed headers (.., absolute, a space, a > that would end the #import) are refused. Both 0.88 patches were regenerated from the vendored scaffolder and the byte-identity, upstream dry-run and "carry the patch" tests pass, none skipped. The header list was checked against AppAuth-iOS 3.0.0's tarball: every entry exists under Sources/AppAuthCore or Sources/AppAuth, the publicHeadersPath: "" of the AppAuthCore and AppAuth targets in its Package.swift.

  • C++ standard, unit tests written failing first: a mixed App with gnu++20 gets -std=gnu++20 in cxxSettings only (cSettings unchanged, one -std= in the manifest); unset and c++2a give -std=c++20; a Swift-only bare app and an Expo app render no C-family settings and no -std=. Rendered manifests before and after: Expo and Swift-only bare byte-identical, mixed bare differs by the one cxxSettings line.

  • Persisting, the real build: a bare React Native 0.85 app that had also been built for Android printed ⚠ Did not persist react-native-linear-gradient's scaffold: the patch would contain a binary file (node_modules/react-native-linear-gradient/android/build/…/BuildConfig.dex) and scaffolded the library again at every build. No build with this change yet.

  • Persisting, unit tests written failing first: the include argument anchors and escapes each path (include/Foo+Bar/Foo+Bar.h) and lists the existing patch's paths; with a fake patch-package that keeps what --include/--exclude select, a library whose android/build/…/BuildConfig.dex and android/.cxx differ is persisted and its patch holds no android path; an existing patch's ios/Foo.m stays in; an unreadable existing patch, a result without files and an over-long list each fall back to the whole package with their ℹ line. The scaffolder's results list exactly the files each scaffold created or changed, on the vendored copy and on React Native 0.88.1 with the bundled patch. Both 0.88 patches were regenerated from the pristine 0.88.0 tarball (identical, as the test requires) and apply to 0.88.1 with -F0.

  • Podspec reader, the real app: the bare React Native 0.85 app built and installed, then crashed at JS start with NSInvalidArgumentException in +[RCTThirdPartyComponentsProvider thirdPartyFabricComponents] (-[__NSPlaceholderDictionary initWithObjects:forKeys:count:], a nil class). The 20 react-native-screens 4.24.0 Fabric classes the provider expects (RNSScreenView, RNSScreenStackView, RNSFullWindowOverlay, RNSModalScreen, …) were absent from the App binary, RNScreens.o held no Objective-C class, and the scaffolded Package.swift listed 49 sources, all under common/cpp/ and cpp/. No build with this change yet.

  • Podspec reader, tests written failing first: on a minimal screens 4.24.0 fixture (its podspec and package.json, empty files at the paths the globs must match), the scaffold lacked every ios/ source before and has ios/*.mm, ios/bridging/*.mm and ios/stubs/*.mm after, nothing under ios/gamma, the common subspec's C++, a clang-only manifest and a module map that leaves out the gamma headers and bridging/Swift-Bridging.h; a synthetic podspec covers ternaries on locals, !, ENV, if/elsif/else, unless, modifiers, push and <<; single quotes do not interpolate and the last assignment wins; an unknown identifier, a method call, an interpolated call, a local built from a call and a local set under an unevaluable condition each fail the scaffold naming the podspec, the field and the expression, with no Package.swift written. The real 4.24.0 tarball scaffolds 195 sources (147 under ios/, 67 .mm, none under ios/gamma, no Swift). Every podspec under the workspace's reference apps (bare 0.86, 0.87, 0.88; Expo SDK 57 and 58) was read with the old and the new reader: no library is refused, and the models differ only by what dead else branches declared (react-native-svg, react-native-webview, @react-native-community/datetimepicker, expo-modules-core). The golden scaffold of the reference libraries, rebuilt from a replica, differs only in react-native-svg (the header and the module map above). Both 0.88 patches were regenerated; the byte-identity, upstream dry-run and "carry the patch" tests pass, none skipped; the golden test is skipped without the reference app.

  • Codegen class check: unit tests on generated-provider fixtures and a fake llvm-nm: present classes (in the App binary, in an embedded framework, a Swift Module.Class) pass and keep the app; the 10 react-native-screens classes absent give the exact message and remove the app and its .ipa; a module provider and a library from codegenConfig or "a library" are named; no providers means no llvm-nm run; a stripped binary set gives the ℹ line. build runs it after xtool-build and leaves the build unrecorded when it throws; install builds first and does not reach xtool dev run when it throws. Run with the real llvm-nm against copies of three device-tested packed apps from the workspace (a bare app with 63 components and a module, the reference Expo app with 32, an Expo SDK 57 app with none): no class reported missing.

  • Regression found on the real app's rebuild, fixed: with the first version of the evaluator, react-native-worklets 0.8.3 stopped in Common/cpp/worklets/Tools/WorkletsVersion.cpp:19 with use of undeclared identifier 'WORKLETS_VERSION_STRING': its compile line had -DHERMES_V1_ENABLED -DRCT_NEW_ARCH_ENABLED=1 and neither -DWORKLETS_VERSION=… nor -DREACT_NATIVE_MINOR_VERSION=…. version_flags interpolates $worklets_config[…], which the evaluator could not compute, so the whole string was unknown and the flag was dropped without a word. A test on the worklets 0.8.3 fixture (its podspec, scripts/worklets_utils.rb, package.json, empty sources) failed first and now finds .define("WORKLETS_VERSION", to: "0.8.3") and .define("REACT_NATIVE_MINOR_VERSION", to: "86") (the harness's React Native 0.86.3) in cxxSettings, plus the two named Left out of warnings; refusal tests cover a method call in compiler_flags and an unknown local as header_dir.

  • Regression sweep: the 15 libraries of the real app (from their npm tarballs), the workspace apps' scaffolded libraries (masked-view, screens 4.30.0 and 4.24.0, datetimepicker, gesture-handler 3.3.0, svg, webview, pager-view 9.0.7) and every podspec fixture were scaffolded with the scaffolder before this PR's reader change and with this one, and the full outputs compared (sources, defines, flags, header search paths, frameworks, module maps). Every difference: react-native-screens 4.24.0 gets its ios/ sources (the fix); react-native-svg gets apple/Utils/RNSVGFabricConversions.h and no module map (only its old-architecture else excluded it); react-native-webview, @react-native-async-storage/async-storage 1.24.0, react-native-keychain, react-native-video and @aws-amplify/react-native get -Wno-comma -Wno-shorten-64-to-32 from folly_compiler_flags, which is now read (its FOLLY_* defines stay dropped, with the existing warning); dead-else dependencies drop out of the models. Defines and header search paths are otherwise identical, worklets' and reanimated's version defines included. New warnings name what was already left out silently before: worklets' #{feature_flags} and #{fetch_preview_flag}, reanimated's feature flags, example and compilation-database flags, vision-camera's frame processor define and its location and frame processor Swift conditions, gesture-handler 3.3.0's #{worklets_flag}.

Checks

  • npm test (2442 passed, 6 skipped) and npm run lint pass.
  • npm run scan:private is clean on every commit.

@WillyAntunez WillyAntunez changed the title Objective-C app targets: React Native headers by bare name Objective-C app targets: React Native headers by bare name, C++ standard Nov 6, 2026
@WillyAntunez
WillyAntunez merged commit 8545c56 into main Nov 6, 2026
1 check passed
@WillyAntunez WillyAntunez mentioned this pull request Nov 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.

1 participant