From 60c01b4715053bccbeca2673ff1be1fca60bce9b Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Mon, 23 Jun 2025 08:13:56 -0700 Subject: [PATCH] Update RNDependencies podspec to fail fast if framework is missing (#52134) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52134 Update RNDependencies podspec to fail fast if framework is missing ## Context This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods. - Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks - Added logic in react_native_pods.rb for switching between build from source and using prebuilts - Added rncore.rb - utilities for the ReactCore prebuilts - Updated rndependencies with some extra error handling modelled after rncode.rb - Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js ## Swift: To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting. I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch. ## Changelog: [IOS] [CHANGED] - Fail fast when pod install i f using prebuild if frameworks are not present in the disk. Pull Request resolved: https://github.com/facebook/react-native/pull/52109 Test Plan: Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods) Rollback Plan: Reviewed By: cortinico Differential Revision: D76980282 Pulled By: cipolleschi fbshipit-source-id: 6ab029d0cb06e2f0a3d99ea9fc7b375865e7a966 --- .../ReactNativeDependencies.podspec | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec b/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec index c259def49c3..32ebe58e05f 100644 --- a/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec +++ b/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |spec| 'WARNING_CFLAGS' => '-Wno-comma -Wno-shorten-64-to-32', } - spec.source = source + spec.source = source spec.preserve_paths = '**/*.*' spec.vendored_frameworks = 'framework/packages/react-native/ReactNativeDependencies.xcframework' spec.header_mappings_dir = 'Headers' @@ -49,6 +49,19 @@ Pod::Spec.new do |spec| mkdir -p Headers XCFRAMEWORK_PATH=$(find "$CURRENT_PATH" -type d -name "ReactNativeDependencies.xcframework") HEADERS_PATH=$(find "$XCFRAMEWORK_PATH" -type d -name "Headers" | head -n 1) + + # Check if XCFRAMEWORK_PATH is empty + if [ -z "$XCFRAMEWORK_PATH" ]; then + echo "ERROR: XCFRAMEWORK_PATH is empty." + exit 0 + fi + + # Check if HEADERS_PATH is empty + if [ -z "$HEADERS_PATH" ]; then + echo "ERROR: HEADERS_PATH is empty." + exit 0 + fi + cp -R "$HEADERS_PATH/" Headers mkdir -p framework/packages/react-native cp -R "$XCFRAMEWORK_PATH/.." framework/packages/react-native/