Skip to content

Commit

Permalink
Make bridgeless build with Static frameworks
Browse files Browse the repository at this point in the history
Summary:
This changes allow React Native to build with Static Frameworks on iOS.

The major problem we encountered was that objective-c headers should not import C++ files. C++ headers must only be used by `.mm` files.

## Changelog:
[iOS][Fixed] - Make bridgeless works with static frameworks

Differential Revision: D47023664

fbshipit-source-id: 80496f5aa1cacdd66c74e529374e999bfb5f00b7
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Jun 29, 2023
1 parent 46e1b22 commit aa97683
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxBridge/NSDataBigString.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <Foundation/Foundation.h>

#include <cxxreact/JSBigString.h>
Expand Down Expand Up @@ -38,3 +39,4 @@ class NSDataBigString : public JSBigString {
};

} // namespace facebook::react
#endif
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxBridge/RCTCxxBridgeDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#include <memory>

#import <React/RCTBridgeDelegate.h>
Expand All @@ -29,3 +30,4 @@ class JSExecutorFactory;
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge;

@end
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#ifdef __cplusplus
#include <jsireact/JSIExecutor.h>

namespace facebook::react {
Expand All @@ -19,3 +20,4 @@ JSIExecutor::RuntimeInstaller RCTJSIExecutorRuntimeInstaller(
JSIExecutor::RuntimeInstaller runtimeInstallerToWrap);

} // namespace facebook::react
#endif
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxBridge/RCTMessageThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <memory>
#import <string>

Expand Down Expand Up @@ -37,3 +38,4 @@ class RCTMessageThread : public MessageQueueThread,
};

} // namespace facebook::react
#endif
3 changes: 2 additions & 1 deletion packages/react-native/React/CxxBridge/RCTObjcExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#include <functional>
#include <memory>

Expand All @@ -29,3 +29,4 @@ class RCTObjcExecutorFactory : public JSExecutorFactory {
};

} // namespace facebook::react
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#include <glog/logging.h>

#include <React/RCTLog.h>
Expand Down Expand Up @@ -43,3 +43,4 @@ class DispatchMessageQueueThread : public MessageQueueThread {
};

} // namespace facebook::react
#endif
3 changes: 2 additions & 1 deletion packages/react-native/React/CxxModule/RCTCxxMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <Foundation/Foundation.h>

#import <React/RCTBridgeMethod.h>
Expand All @@ -15,3 +15,4 @@
- (instancetype)initWithCxxMethod:(const facebook::xplat::module::CxxModule::Method &)cxxMethod;

@end
#endif
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxModule/RCTCxxModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <memory>

#import <Foundation/Foundation.h>
Expand All @@ -27,3 +28,4 @@ class CxxModule;
- (std::unique_ptr<facebook::xplat::module::CxxModule>)createModule;

@end
#endif
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxModule/RCTCxxUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#include <functional>
#include <memory>

Expand All @@ -25,3 +26,4 @@ NSError *tryAndReturnError(const std::function<void()> &func);
NSString *deriveSourceURL(NSURL *url);

} // namespace facebook::react
#endif
2 changes: 2 additions & 0 deletions packages/react-native/React/CxxModule/RCTNativeModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <React/RCTModuleData.h>
#import <cxxreact/NativeModule.h>

Expand All @@ -30,3 +31,4 @@ class RCTNativeModule : public NativeModule {
};

} // namespace facebook::react
#endif
3 changes: 3 additions & 0 deletions packages/react-native/React/CxxUtils/RCTFollyConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef __cplusplus
#import <Foundation/Foundation.h>

#include <folly/dynamic.h>
Expand All @@ -15,3 +16,5 @@ folly::dynamic convertIdToFollyDynamic(id json);
id convertFollyDynamicToId(const folly::dynamic &dyn);

} // namespace facebook::react

#endif
2 changes: 1 addition & 1 deletion packages/react-native/scripts/cocoapods/fabric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def setup_fabric!(react_native_path: "../node_modules/react-native", new_arch_en
pod 'React-graphics', :path => "#{react_native_path}/ReactCommon/react/renderer/graphics"
pod 'React-RCTFabric', :path => "#{react_native_path}/React", :modular_headers => true
pod 'React-ImageManager', :path => "#{react_native_path}/ReactCommon/react/renderer/imagemanager/platform/ios"
pod 'RCT-Folly/Fabric', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec"
pod 'RCT-Folly/Fabric', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true
pod 'React-FabricImage', :path => "#{react_native_path}/ReactCommon"
end

0 comments on commit aa97683

Please sign in to comment.