From 609945fc5cbcbdea121ef4afad0e2b239de85e29 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 13 Jan 2025 13:23:29 +0100 Subject: [PATCH] Set RN version --- example/ios/Podfile.lock | 2 +- .../NitroModules.podspec | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index c0d6e9c08..8df1ee4bc 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1895,7 +1895,7 @@ SPEC CHECKSUMS: glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 1949ca944b195a8bde7cbf6316b9068e19cf53c6 NitroImage: ff97c5986ea4619abd3d6399b886eac84f5a4b65 - NitroModules: a34f99b308a3bb5d4fc37cdb532d9ea44899442c + NitroModules: 9d5bc0172f6d9b098eb29e8cd9891e16881cd4b6 RCT-Folly: 84578c8756030547307e4572ab1947de1685c599 RCTDeprecation: 063fc281b30b7dc944c98fe53a7e266dab1a8706 RCTRequired: 8eda2a5a745f6081157a4f34baac40b65fe02b31 diff --git a/packages/react-native-nitro-modules/NitroModules.podspec b/packages/react-native-nitro-modules/NitroModules.podspec index f697718a7..74e9fa8f4 100644 --- a/packages/react-native-nitro-modules/NitroModules.podspec +++ b/packages/react-native-nitro-modules/NitroModules.podspec @@ -2,7 +2,6 @@ require "json" require_relative './nitro_pod_utils' package = JSON.parse(File.read(File.join(__dir__, "package.json"))) -react_native_version = get_react_native_version() Pod::UI.puts "[NitroModules] 🔥 Your app is boosted by nitro modules!" @@ -55,6 +54,12 @@ Pod::Spec.new do |s| "ios/utils/SwiftClosure.hpp", ] + compiler_flags = "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES" + if has_react_native() + react_native_version = get_react_native_version() + compiler_flags += " HAS_REACT_NATIVE REACT_NATIVE_VERSION=#{react_native_version}" + end + s.pod_target_xcconfig = { # Use C++ 20 "CLANG_CXX_LANGUAGE_STANDARD" => "c++20", @@ -62,11 +67,17 @@ Pod::Spec.new do |s| "SWIFT_OBJC_INTEROP_MODE" => "objcxx", # Enables stricter modular headers "DEFINES_MODULE" => "YES", - # C++ compiler flags, mainly for folly. - "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES REACT_NATIVE_VERSION=#{react_native_version}" + # C++ compiler flags, mainly for RN version and folly. + "GCC_PREPROCESSOR_DEFINITIONS" => compiler_flags } - s.dependency 'React-jsi' - s.dependency 'React-callinvoker' - install_modules_dependencies(s) + if has_react_native() + # Using Nitro in react-native + s.dependency 'React-jsi' + s.dependency 'React-callinvoker' + install_modules_dependencies(s) + else + # Using Nitro somewhere else (NativeScript? Bare iOS?) + raise "Couldn't find react-native - are you trying to use Nitro outside of React Native?" + end end