@@ -121,6 +121,113 @@ issues when:
121121- Building dependent frameworks that rely on proper module boundaries
122122- Integrating with Swift Package Manager projects expecting modular headers
123123
124+ ## VFS Overlay System
125+
126+ The prebuilt XCFrameworks use Clang's Virtual File System (VFS) overlay
127+ mechanism to enable header imports without modifying the actual header file
128+ structure. This is necessary because React Native's headers are organized
129+ differently than standard framework conventions.
130+
131+ ### Overview
132+
133+ The VFS overlay creates a virtual mapping between the import paths used in code
134+ (e.g., ` #import <react/renderer/graphics/Size.h> ` ) and the actual physical
135+ locations of headers within the XCFramework. This allows the prebuilt frameworks
136+ to work seamlessly while maintaining the original import syntax.
137+
138+ ### Build-Time VFS Generation (` vfs.js ` )
139+
140+ The ` vfs.js ` script creates a VFS overlay template during the prebuild process:
141+
142+ 1 . ** Header Collection** (` headers.js ` ): Scans all podspec files in the React
143+ Native package to discover header files and their target import paths.
144+
145+ 2 . ** VFS Structure Building** : The ` buildVFSStructure() ` function creates a
146+ hierarchical directory tree representation from the header mappings. Clang's
147+ VFS overlay requires directories to contain their children in a tree
148+ structure.
149+
150+ 3 . ** YAML Generation** : The ` generateVFSOverlayYAML() ` function converts the VFS
151+ structure into Clang's expected YAML format.
152+
153+ 4 . ** Template Creation** : The generated overlay uses ` ${ROOT_PATH} ` as a
154+ placeholder for the actual installation path. This template is included in
155+ the XCFramework as ` React-VFS-template.yaml ` .
156+
157+ #### Key Functions
158+
159+ - ` createVFSOverlay(rootFolder) ` : Main entry point that generates the complete
160+ VFS overlay YAML string
161+ - ` createVFSOverlayContents(rootFolder) ` : Creates the VFS overlay object
162+ structure
163+ - ` buildVFSStructure(mappings) ` : Builds the hierarchical directory tree from
164+ flat mappings
165+ - ` resolveVFSOverlay(vfsTemplate, rootPath) ` : Replaces ` ${ROOT_PATH} ` with the
166+ actual path
167+
168+ ### Runtime VFS Processing (CocoaPods)
169+
170+ When consuming prebuilt frameworks via CocoaPods, the VFS overlay is processed
171+ at pod install time by ` rncore.rb ` :
172+
173+ #### ` process_vfs_overlay() `
174+
175+ Called during ` react_native_post_install ` , this method:
176+
177+ 1 . Reads the ` React-VFS-template.yaml ` from the XCFramework
178+ 2 . Resolves the ` ${ROOT_PATH} ` placeholder with the actual XCFramework path
179+ 3 . Writes the resolved overlay to ` $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml `
180+
181+ #### ` add_rncore_dependency(s) `
182+
183+ Adds VFS overlay compiler flags to podspecs that depend on React Native:
184+
185+ ``` ruby
186+ # For C/C++ compilation
187+ OTHER_CFLAGS += " -ivfsoverlay $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml"
188+ OTHER_CPLUSPLUSFLAGS += " -ivfsoverlay $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml"
189+
190+ # For Swift compilation (flags passed to underlying Clang)
191+ OTHER_SWIFT_FLAGS += " -Xcc -ivfsoverlay -Xcc $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml"
192+ ```
193+
194+ #### ` configure_aggregate_xcconfig(installer) `
195+
196+ Configures VFS overlay flags for:
197+
198+ - ** Aggregate targets** : Main app targets that don't go through podspec
199+ processing
200+ - ** All pod targets** : Third-party pods that don't explicitly call
201+ ` add_rncore_dependency `
202+
203+ This ensures all compilation units in the project can resolve React Native
204+ headers through the VFS overlay.
205+
206+ ### VFS Overlay Format
207+
208+ The VFS overlay uses Clang's hierarchical YAML format:
209+
210+ ``` yaml
211+ version : 0
212+ case-sensitive : false
213+ roots :
214+ - name : ' ${ROOT_PATH}/Headers'
215+ type : ' directory'
216+ contents :
217+ - name : ' react'
218+ type : ' directory'
219+ contents :
220+ - name : ' renderer'
221+ type : ' directory'
222+ contents :
223+ - name : ' Size.h'
224+ type : ' file'
225+ external-contents : ' ${ROOT_PATH}/Headers/React/react/renderer/Size.h'
226+ ` ` `
227+
228+ The structure maps virtual paths (what the compiler sees) to physical paths
229+ (where the files actually exist in the XCFramework).
230+
124231## Integrating in your project with Cocoapods
125232
126233For consuming, debugging or troubleshooting when using Cocoapods scripts, you
0 commit comments