Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iOS Fabric-related files to compile on OSS #29810

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ package-lock.json

# react-native-codegen
/packages/react-native-codegen/lib
/ReactCommon/fabric/components/rncore/
/ReactCommon/react/renderer/components/rncore/
/schema-native-modules.json
/schema-rncore.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import <react/renderer/components/rncore/EventEmitters.h>
#import <react/renderer/components/rncore/Props.h>

#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Class<RCTComponentViewProtocol> RCTParagraphCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTTextInputCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTInputAccessoryCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTViewCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTImageCls(void) __attribute__((used));

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{"TextInput", RCTTextInputCls},
{"InputAccessoryView", RCTInputAccessoryCls},
{"View", RCTViewCls},
{"Image",RCTImageCls},
};

auto p = sFabricComponentsClassMap.find(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <React/RCTUtils.h>
#import <react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h>
#import <react/renderer/components/safeareaview/SafeAreaViewState.h>
#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"
#import "RCTConversions.h"
#import "RCTFabricComponentsPlugins.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import <React/RCTRefreshableProtocol.h>
#import <React/RCTScrollViewComponentView.h>

#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import <react/renderer/components/rncore/Props.h>
#import <react/renderer/components/slider/SliderComponentDescriptor.h>

#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#import <react/renderer/components/rncore/Props.h>
#import <react/renderer/components/rncore/RCTComponentViewHelpers.h>

#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import <React/RCTConversions.h>

#import "FBRCTFabricComponentsPlugins.h"
#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

Expand Down
3 changes: 1 addition & 2 deletions React/Fabric/Mounting/RCTComponentViewFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ + (RCTComponentViewFactory *)standardComponentViewFactory
[componentViewFactory registerComponentViewClass:[RCTParagraphComponentView class]];
[componentViewFactory registerComponentViewClass:[RCTTextInputComponentView class]];

Class<RCTComponentViewProtocol> imageClass = RCTComponentViewClassWithName("Image");
hramos marked this conversation as resolved.
Show resolved Hide resolved
[componentViewFactory registerComponentViewClass:imageClass];
[componentViewFactory registerComponentViewClass:[RCTImageComponentView class]];

auto providerRegistry = &componentViewFactory->_providerRegistry;

Expand Down
11 changes: 8 additions & 3 deletions React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Pod::Spec.new do |s|
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "10.0" }
s.source = source
s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}",
"Tests/**/*.{mm}"
s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}"
s.exclude_files = "**/tests/*",
"**/android/*",
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
Expand All @@ -45,5 +44,11 @@ Pod::Spec.new do |s|
s.dependency "React-Core", version
s.dependency "React-Fabric", version
s.dependency "React-RCTImage", version
s.dependency "Folly/Fabric", folly_version
s.dependency "RCT-Folly/Fabric", folly_version

s.test_spec 'Tests' do |test_spec|
test_spec.source_files = "Tests/**/*.{mm}"
test_spec.framework = "XCTest"
end

end
139 changes: 92 additions & 47 deletions ReactCommon/React-Fabric.podspec

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions ReactCommon/react/renderer/graphics/React-graphics.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

require "json"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json")))
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "package.json")))
version = package['version']

source = { :git => 'https://github.com/facebook/react-native.git' }
Expand Down Expand Up @@ -35,8 +35,8 @@ Pod::Spec.new do |s|
s.exclude_files = "**/tests/*",
"**/android/*",
"**/cxx/*"
s.header_dir = "react/graphics"
s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" }
s.header_dir = "react/renderer/graphics"
s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/../../../\" \"$(PODS_ROOT)/RCT-Folly\"" }

s.dependency "Folly/Fabric", folly_version
s.dependency "RCT-Folly/Fabric", folly_version
end
2 changes: 1 addition & 1 deletion ReactCommon/yoga/Yoga.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Pod::Spec.new do |spec|
source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
spec.source_files = source_files

header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGNode,YGStyle,YGValue}.h'
header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
spec.public_header_files = header_files
end
17 changes: 13 additions & 4 deletions packages/rn-tester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ def pods()

# Enable TurboModule
prefix_path = "../.."
use_react_native!(path:prefix_path)
fabric_enabled = false

# To use fabric: set the environment variable `USE_FABRIC` to 1, like below
# $ USE_FABRIC=1 bundle exec pod install
# or
# $ export USE_FABRIC=1
# $ bundle exec pod install
if ENV['USE_FABRIC'] == '1'
puts "Building RNTester with Fabric enabled."
fabric_enabled = true
end

use_react_native!(path:prefix_path, fabric_enabled: fabric_enabled)
pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon"

# Additional Pods which aren't included in the default Podfile
pod 'React-RCTPushNotification', :path => "#{prefix_path}/Libraries/PushNotificationIOS"
pod 'Yoga',:path => "#{prefix_path}/ReactCommon/yoga", :modular_headers => true
# Additional Pods which are classed as unstable
#
# To use fabric: add `fabric_enabled` option to the use_react_native method above, like below
# use_react_native!(path: "..", fabric_enabled: true)
end

target 'RNTester' do
Expand Down
53 changes: 53 additions & 0 deletions scripts/generate-rncore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';

const path = require('path');
const fs = require('fs');
const glob = require('glob');
const RNCodegen = require('react-native-codegen/lib/generators/RNCodegen');
const combine = require('react-native-codegen/lib/cli/combine/combine-js-to-schema');

function generate(schema, outputDirectory) {
fs.mkdirSync(outputDirectory, {recursive: true});

RNCodegen.generate(
{
libraryName: 'rncore',
schema,
outputDirectory,
},
{generators: ['descriptors', 'events', 'props', 'shadow-nodes']},
);
}

function main() {
const rnDir = path.resolve(__dirname, '..');
const outputDirectory = path.resolve(
rnDir,
'ReactCommon',
'react',
'renderer',
'components',
'rncore',
);

const files = glob.sync('Libraries/**/*NativeComponent.js', {
cwd: path.resolve(__dirname, '..'),
});

const schema = combine(
files.map(file => path.resolve(__dirname, '..', file)),
);

generate(schema, outputDirectory);
}

main();
14 changes: 0 additions & 14 deletions scripts/generate-rncore.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def use_react_native! (options={})

if fabric_enabled
pod 'React-Fabric', :path => "#{prefix}/ReactCommon"
pod 'React-graphics', :path => "#{prefix}/ReactCommon/fabric/graphics"
pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics"
pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-RCTFabric', :path => "#{prefix}/React"
pod 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
Expand Down