Skip to content

Commit f312e5b

Browse files
empyricalfacebook-github-bot
authored andcommitted
Update iOS Fabric-related files to compile on OSS (facebook#29810)
Summary: Original PR contents: This pull request updates the Podspecs and associated build scripts, and some source files so they build on OSS. RNTester now compiles with `fabric_enabled` again. The following changes have been made: * Various spots that were pointing to the old `ReactCommon/fabric` location have now been updated to `ReactCommon/react/renderer` * Files that were attempting to use internal FB header `FBRCTFabricComponentsPlugins.h` were changed to use `RCTFabricComponentsPlugins.h` * `RCTFabricComponentsPlugins` in OSS was updated to include the `Image` fabric component (thanks tsapeta) * Replaced old `generate-rncore.sh` build script with new `generate-rncore.js` script which does not require `flow-node` and uses the `react-native-codegen` API directly, so there is no longer any need for an interim `schema-rncore.json` file. * Updated Yoga podspec which wasn't fully synced with changes from the main Yoga repo * Updated Fabric podspec with additional needed subspecs Additions to PR by hramos: * Replaced use of generate-rncore scripts with the original generate-native-modules-specs.sh script, which is now generate-specs.sh and supports both codegen for Native Modules and Components now (TurboModules/Fabric). * Codegen now runs at build time as part of the Xcode build pipeline instead of as part of `pod install`. The build script is injected by the FBReactNativeSpec pod, as the pod is part of both Fabric and non-Fabric builds. ## Changelog [General] [Fixed] - RNTester compiles with `fabric_enabled` again Pull Request resolved: facebook#29810 Test Plan: RNTester now compiles and runs in the simulator again when `fabric_enabled` is set to `true`. ``` cd xplat/js/react-native-github/packages/rn-tester USE_FABRIC=1 pod install open RNTesterPods.xcworkspace # Build and run ``` Reviewed By: fkgozali Differential Revision: D24058507 Pulled By: hramos fbshipit-source-id: 8b2ea3694e6cb9aa23f83f087e2995fd4320e2bb
1 parent 86ffbd0 commit f312e5b

File tree

23 files changed

+209
-150
lines changed

23 files changed

+209
-150
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ package-lock.json
102102
# react-native-codegen
103103
/Libraries/FBReactNativeSpec/FBReactNativeSpec
104104
/packages/react-native-codegen/lib
105-
/ReactCommon/fabric/components/rncore/
106-
/schema-rncore.json
105+
/ReactCommon/react/renderer/components/rncore/
107106

108107
# Visual studio
109108
.vscode

Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@ end
2020

2121
react_native_path = File.join(__dir__, "..", "..")
2222
srcs_dir = File.join(__dir__, "..")
23-
codegen_script_path = File.join(react_native_path, "scripts", "generate-native-modules-specs.sh")
23+
codegen_script_path = File.join(react_native_path, "scripts", "generate-specs.sh")
2424
codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen")
25-
output_dir = File.join(__dir__, "FBReactNativeSpec")
26-
generated_files = [File.join(output_dir, "FBReactNativeSpec.h"), File.join(output_dir, "FBReactNativeSpec-generated.mm")]
2725
codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\""
26+
modules_output_dir = File.join(__dir__, "FBReactNativeSpec")
27+
components_output_dir = File.join(react_native_path, "ReactCommon", "react", "renderer", "components", "rncore")
28+
generated_filenames = [ "FBReactNativeSpec.h", "FBReactNativeSpec-generated.mm" ]
29+
generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) }
30+
31+
if ENV['USE_FABRIC'] == '1'
32+
components_generated_filenames = [
33+
"ComponentDescriptors.h",
34+
"EventEmitters.cpp",
35+
"EventEmitters.h",
36+
"Props.cpp",
37+
"Props.h",
38+
"RCTComponentViewHelpers.h",
39+
"ShadowNodes.cpp",
40+
"ShadowNodes.h"
41+
]
42+
generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) })
43+
end
2844

2945
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
3046
folly_version = '2020.01.13.00'
@@ -40,6 +56,7 @@ Pod::Spec.new do |s|
4056
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
4157
s.source = source
4258
s.source_files = "**/*.{c,h,m,mm,cpp}"
59+
s.exclude_files = "jni"
4360
s.header_dir = "FBReactNativeSpec"
4461

4562
s.pod_target_xcconfig = {
@@ -55,11 +72,11 @@ Pod::Spec.new do |s|
5572
s.dependency "React-jsi", version
5673
s.dependency "ReactCommon/turbomodule/core", version
5774

58-
s.prepare_command = "mkdir -p #{output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}"
75+
s.prepare_command = "mkdir -p #{modules_output_dir} #{components_output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}"
5976
s.script_phase = {
60-
:name => 'Generate Native Modules Code',
77+
:name => 'Generate Specs',
6178
:input_files => [srcs_dir],
62-
:output_files => ["$(DERIVED_FILE_DIR)/FBReactNativeSpec-codegen.log"],
79+
:output_files => ["$(DERIVED_FILE_DIR)/codegen.log"],
6380
:script => codegen_command,
6481
:execution_position => :before_compile
6582
}

React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import <react/renderer/components/rncore/EventEmitters.h>
1414
#import <react/renderer/components/rncore/Props.h>
1515

16-
#import "FBRCTFabricComponentsPlugins.h"
16+
#import "RCTFabricComponentsPlugins.h"
1717

1818
using namespace facebook::react;
1919

React/Fabric/Mounting/ComponentViews/Picker/RCTPickerComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#import <react/renderer/components/iospicker/PickerProps.h>
1616
#import <react/renderer/textlayoutmanager/RCTAttributedTextUtils.h>
1717

18-
#import "FBRCTFabricComponentsPlugins.h"
1918
#import "RCTConversions.h"
19+
#import "RCTFabricComponentsPlugins.h"
2020

2121
using namespace facebook::react;
2222

React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Class<RCTComponentViewProtocol> RCTParagraphCls(void) __attribute__((used));
4141
Class<RCTComponentViewProtocol> RCTTextInputCls(void) __attribute__((used));
4242
Class<RCTComponentViewProtocol> RCTInputAccessoryCls(void) __attribute__((used));
4343
Class<RCTComponentViewProtocol> RCTViewCls(void) __attribute__((used));
44+
Class<RCTComponentViewProtocol> RCTImageCls(void) __attribute__((used));
4445

4546
#ifdef __cplusplus
4647
}

React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
{"TextInput", RCTTextInputCls},
3131
{"InputAccessoryView", RCTInputAccessoryCls},
3232
{"View", RCTViewCls},
33+
{"Image", RCTImageCls},
3334
};
3435

3536
auto p = sFabricComponentsClassMap.find(name);

React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import <React/RCTUtils.h>
1111
#import <react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h>
1212
#import <react/renderer/components/safeareaview/SafeAreaViewState.h>
13-
#import "FBRCTFabricComponentsPlugins.h"
1413
#import "RCTConversions.h"
1514
#import "RCTFabricComponentsPlugins.h"
1615

React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#import <React/RCTRefreshableProtocol.h>
1717
#import <React/RCTScrollViewComponentView.h>
1818

19-
#import "FBRCTFabricComponentsPlugins.h"
19+
#import "RCTFabricComponentsPlugins.h"
2020

2121
using namespace facebook::react;
2222

React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#import <react/renderer/components/rncore/Props.h>
1616
#import <react/renderer/components/slider/SliderComponentDescriptor.h>
1717

18-
#import "FBRCTFabricComponentsPlugins.h"
18+
#import "RCTFabricComponentsPlugins.h"
1919

2020
using namespace facebook::react;
2121

React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import <react/renderer/components/rncore/Props.h>
1515
#import <react/renderer/components/rncore/RCTComponentViewHelpers.h>
1616

17-
#import "FBRCTFabricComponentsPlugins.h"
17+
#import "RCTFabricComponentsPlugins.h"
1818

1919
using namespace facebook::react;
2020

0 commit comments

Comments
 (0)