From 1d97e63d422e949ca577dfb0c629bf7b50e2ed2e Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Mon, 5 May 2025 15:19:34 +0200 Subject: [PATCH] fix: add static frameworks support (#8) --- .../ReactNativeVideo.podspec | 37 +++++++++---------- .../ios/view/fabric/VideoView.mm | 5 +++ .../ios/view/paper/VideoView.mm | 5 +++ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/packages/react-native-video/ReactNativeVideo.podspec b/packages/react-native-video/ReactNativeVideo.podspec index ef49a2d4..26122a61 100644 --- a/packages/react-native-video/ReactNativeVideo.podspec +++ b/packages/react-native-video/ReactNativeVideo.podspec @@ -32,31 +32,28 @@ Pod::Spec.new do |s| # Cxx to Swift bridging helpers s.public_header_files = ["ios/Video-Bridging-Header.h"] - # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. - # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79. - if respond_to?(:install_modules_dependencies, true) - install_modules_dependencies(s) - else + s.pod_target_xcconfig = { + "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES FOLLY_MOBILE" + } + + # Try to manually add the dependencies + # because they are not automatically added by expo + # when USE_FRAMEWORKS is true + if ENV["USE_FRAMEWORKS"] s.dependency "React-Core" - # Don't install the dependencies when we run `pod install` in the old architecture. - if fabric_enabled then - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", - "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" - } - s.dependency "React-RCTFabric" - s.dependency "React-Codegen" - s.dependency "RCT-Folly" - s.dependency "RCTRequired" - s.dependency "RCTTypeSafety" - s.dependency "ReactCommon/turbomodule/core" - end + puts "[ReactNativeVideo] Detected USE_FRAMEWORKS, adding required dependencies..." + + add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern") + add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency") + + # @KrzysztofMoch Note: We need to add this as well for newer versions of React Native, but it's not available in older versions + # add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing') end # Add all files generated by Nitrogen load 'nitrogen/generated/ios/ReactNativeVideo+autolinking.rb' add_nitrogen_files(s) + + install_modules_dependencies(s) end diff --git a/packages/react-native-video/ios/view/fabric/VideoView.mm b/packages/react-native-video/ios/view/fabric/VideoView.mm index 2b7a250b..745f295c 100644 --- a/packages/react-native-video/ios/view/fabric/VideoView.mm +++ b/packages/react-native-video/ios/view/fabric/VideoView.mm @@ -8,7 +8,12 @@ #import "RCTFabricComponentsPlugins.h" #import "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" + +#if __has_include("ReactNativeVideo/ReactNativeVideo-Swift.h") +#import "ReactNativeVideo/ReactNativeVideo-Swift.h" +#else #import "ReactNativeVideo-Swift.h" +#endif using namespace facebook::react; diff --git a/packages/react-native-video/ios/view/paper/VideoView.mm b/packages/react-native-video/ios/view/paper/VideoView.mm index ad797cdc..c40a664f 100644 --- a/packages/react-native-video/ios/view/paper/VideoView.mm +++ b/packages/react-native-video/ios/view/paper/VideoView.mm @@ -1,7 +1,12 @@ #import "VideoView.h" #import "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" + +#if __has_include("ReactNativeVideo/ReactNativeVideo-Swift.h") +#import "ReactNativeVideo/ReactNativeVideo-Swift.h" +#else #import "ReactNativeVideo-Swift.h" +#endif @implementation VideoView { VideoComponentView* _view;