From fde8a4cf93d3e5a8ccfe11394883be94d08da372 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 1 Jul 2019 15:12:56 -0700 Subject: [PATCH] TM iOS: Set up CocoaPods specs for the TM specs Summary: This defines various sub specs to support building TurboModules that implement the codegen'ed specs. Reviewed By: PeteTheHeat Differential Revision: D16043221 fbshipit-source-id: 27ed532be929c11c8fe648632da8a72061cbc8b0 --- Libraries/FBLazyVector/FBLazyVector.podspec | 31 ++++++++++++ .../FBReactNativeSpec.podspec | 47 +++++++++++++++++++ Libraries/RCTRequired/RCTRequired.podspec | 31 ++++++++++++ Libraries/TypeSafety/React-TypeSafety.podspec | 45 ++++++++++++++++++ RNTester/Podfile.lock | 39 ++++++++++++++- RNTester/RNTester/AppDelegate.mm | 9 +++- .../RNTester/RNTesterTurboModuleProvider.h | 5 ++ .../RNTester/RNTesterTurboModuleProvider.mm | 4 ++ React/CoreModules/React-CoreModules.podspec | 44 +++++++++++++++++ React/React-Core.podspec | 3 +- scripts/autolink-ios.rb | 15 +++--- third-party-podspecs/Folly.podspec | 2 +- 12 files changed, 264 insertions(+), 11 deletions(-) create mode 100644 Libraries/FBLazyVector/FBLazyVector.podspec create mode 100644 Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec create mode 100644 Libraries/RCTRequired/RCTRequired.podspec create mode 100644 Libraries/TypeSafety/React-TypeSafety.podspec create mode 100644 React/CoreModules/React-CoreModules.podspec diff --git a/Libraries/FBLazyVector/FBLazyVector.podspec b/Libraries/FBLazyVector/FBLazyVector.podspec new file mode 100644 index 00000000000..84c8cf012b3 --- /dev/null +++ b/Libraries/FBLazyVector/FBLazyVector.podspec @@ -0,0 +1,31 @@ +# coding: utf-8 +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +Pod::Spec.new do |s| + s.name = "FBLazyVector" + s.version = version + s.summary = "-" # TODO + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.source = source + s.source_files = "**/*.{c,h,m,mm,cpp}" + s.header_dir = "FBLazyVector" +end diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec new file mode 100644 index 00000000000..21e53898eba --- /dev/null +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -0,0 +1,47 @@ +# coding: utf-8 +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' + +Pod::Spec.new do |s| + s.name = "FBReactNativeSpec" + s.version = version + s.summary = "-" # TODO + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.compiler_flags = folly_compiler_flags + s.source = source + s.source_files = "**/*.{c,h,m,mm,cpp}" + s.header_dir = "FBReactNativeSpec" + + s.pod_target_xcconfig = { + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/Libraries/FBReactNativeSpec\" \"$(PODS_ROOT)/Folly\"" + } + + s.dependency "Folly", folly_version + s.dependency "RCTRequired", version + s.dependency "React-Core", version + s.dependency "React-TypeSafety", version + s.dependency "React-turbomodule-core", version +end diff --git a/Libraries/RCTRequired/RCTRequired.podspec b/Libraries/RCTRequired/RCTRequired.podspec new file mode 100644 index 00000000000..26fa4c7e1a6 --- /dev/null +++ b/Libraries/RCTRequired/RCTRequired.podspec @@ -0,0 +1,31 @@ +# coding: utf-8 +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +Pod::Spec.new do |s| + s.name = "RCTRequired" + s.version = version + s.summary = "-" # TODO + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.source = source + s.source_files = "**/*.{c,h,m,mm,cpp}" + s.header_dir = "RCTRequired" +end diff --git a/Libraries/TypeSafety/React-TypeSafety.podspec b/Libraries/TypeSafety/React-TypeSafety.podspec new file mode 100644 index 00000000000..11e74980ee4 --- /dev/null +++ b/Libraries/TypeSafety/React-TypeSafety.podspec @@ -0,0 +1,45 @@ +# coding: utf-8 +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' + +Pod::Spec.new do |s| + s.name = "React-TypeSafety" + s.version = version + s.summary = "-" # TODO + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.compiler_flags = folly_compiler_flags + s.source = source + s.source_files = "**/*.{c,h,m,mm,cpp}" + s.header_dir = "React" + s.pod_target_xcconfig = { + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/Libraries/TypeSafety\" \"$(PODS_ROOT)/Folly\"" + } + + s.dependency "FBLazyVector", version + s.dependency "Folly", folly_version + s.dependency "RCTRequired", version + s.dependency "React-Core", version +end diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index 0eb7daff56c..c7b8f5ffbb2 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -1,6 +1,13 @@ PODS: - boost-for-react-native (1.63.0) - DoubleConversion (1.1.6) + - FBLazyVector (1000.0.0) + - FBReactNativeSpec (1000.0.0): + - Folly (= 2018.10.22.00) + - RCTRequired (= 1000.0.0) + - React-Core (= 1000.0.0) + - React-turbomodule-core (= 1000.0.0) + - React-TypeSafety (= 1000.0.0) - Folly (2018.10.22.00): - boost-for-react-native - DoubleConversion @@ -11,6 +18,7 @@ PODS: - DoubleConversion - glog - glog (0.3.5) + - RCTRequired (1000.0.0) - React (1000.0.0): - React-Core (= 1000.0.0) - React-DevSupport (= 1000.0.0) @@ -31,6 +39,10 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - yoga (= 1000.0.0.React) + - React-CoreModules (1000.0.0): + - FBReactNativeSpec (= 1000.0.0) + - Folly (= 2018.10.22.00) + - React-Core (= 1000.0.0) - React-cxxreact (1000.0.0): - boost-for-react-native (= 1.63.0) - DoubleConversion @@ -114,15 +126,24 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-turbomodule-core (= 1000.0.0) + - React-TypeSafety (1000.0.0): + - FBLazyVector (= 1000.0.0) + - Folly (= 2018.10.22.00) + - RCTRequired (= 1000.0.0) + - React-Core (= 1000.0.0) - yoga (1000.0.0.React) DEPENDENCIES: - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) + - FBLazyVector (from `../Libraries/FBLazyVector`) + - FBReactNativeSpec (from `../Libraries/FBReactNativeSpec`) - Folly (from `../third-party-podspecs/Folly.podspec`) - glog (from `../third-party-podspecs/glog.podspec`) + - RCTRequired (from `../Libraries/RCTRequired`) - React (from `../`) - React-ART (from `../Libraries/ART`) - React-Core (from `../React`) + - React-CoreModules (from `../React/CoreModules`) - React-cxxreact (from `../ReactCommon/cxxreact`) - React-DevSupport (from `../React`) - React-jscallinvoker (from `../ReactCommon/jscallinvoker`) @@ -143,6 +164,7 @@ DEPENDENCIES: - React-RCTWebSocket (from `../Libraries/WebSocket`) - React-turbomodule-core (from `../ReactCommon/turbomodule/core`) - React-turbomodule-samples (from `../ReactCommon/turbomodule/samples`) + - React-TypeSafety (from `../Libraries/TypeSafety`) - yoga (from `../ReactCommon/yoga`) SPEC REPOS: @@ -152,16 +174,24 @@ SPEC REPOS: EXTERNAL SOURCES: DoubleConversion: :podspec: "../third-party-podspecs/DoubleConversion.podspec" + FBLazyVector: + :path: "../Libraries/FBLazyVector" + FBReactNativeSpec: + :path: "../Libraries/FBReactNativeSpec" Folly: :podspec: "../third-party-podspecs/Folly.podspec" glog: :podspec: "../third-party-podspecs/glog.podspec" + RCTRequired: + :path: "../Libraries/RCTRequired" React: :path: "../" React-ART: :path: "../Libraries/ART" React-Core: :path: "../React" + React-CoreModules: + :path: "../React/CoreModules" React-cxxreact: :path: "../ReactCommon/cxxreact" React-DevSupport: @@ -202,17 +232,23 @@ EXTERNAL SOURCES: :path: "../ReactCommon/turbomodule/core" React-turbomodule-samples: :path: "../ReactCommon/turbomodule/samples" + React-TypeSafety: + :path: "../Libraries/TypeSafety" yoga: :path: "../ReactCommon/yoga" SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 + FBLazyVector: 34431b7e61740bed29b082ff81500b0ffafaffa0 + FBReactNativeSpec: 82b0e4bdc0cb0b1b6990b5bbbc85b4b161a6a276 Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 glog: 1f3da668190260b06b429bb211bfbee5cd790c28 + RCTRequired: 33f3b89d2d82ef01c02b9b4f8146c43762e509d8 React: 7c652b87c228731c51ab5764de68b6c17e6342be React-ART: 28f8815acbbc4816cec14866b59911a83eb780ed - React-Core: 85bf24f380e5228013f5f75d7c1b6338a003a2b2 + React-Core: 26b00da6b066d0d426a558d13c76240038aa7dc5 + React-CoreModules: 04ea22808b22232b251d462f3309ab1150e3b7dd React-cxxreact: 7e670bad16eb78fa889573d931c12bb1003a3598 React-DevSupport: f34768e3aad3e59ee9800c752a78bc6cb24d0f75 React-jscallinvoker: a477dfe11b3ebe31ee9575057ebfb57a963db636 @@ -233,6 +269,7 @@ SPEC CHECKSUMS: React-RCTWebSocket: cb5317e9a4adc37191660f819fb21d63433584ef React-turbomodule-core: 0a6e91fe8e28bbf119fe31132ecb27a4f42ea551 React-turbomodule-samples: b28927d482d6fcfc3cbe2fd25f304799d2ff9bb7 + React-TypeSafety: 1de5a1034398108f4ca866b68489734f8dbb4c44 yoga: 542cb34fe3bca476487e08eb516dd640ea996a65 PODFILE CHECKSUM: bdc86d3bfde60c2637cfa8c4ed81afeaa2aaf6a3 diff --git a/RNTester/RNTester/AppDelegate.mm b/RNTester/RNTester/AppDelegate.mm index 44a7ceda3ca..9b8aca0fe0a 100644 --- a/RNTester/RNTester/AppDelegate.mm +++ b/RNTester/RNTester/AppDelegate.mm @@ -132,17 +132,22 @@ #ifdef RN_TURBO_MODULE_ENABLED +- (Class)getModuleClassFromName:(const char *)name +{ + return facebook::react::RNTesterTurboModuleClassProvider(name); +} + - (std::shared_ptr)getTurboModule:(const std::string &)name jsInvoker:(std::shared_ptr)jsInvoker { - return RNTesterTurboModuleProvider(name, jsInvoker); + return facebook::react::RNTesterTurboModuleProvider(name, jsInvoker); } - (std::shared_ptr)getTurboModule:(const std::string &)name instance:(id)instance jsInvoker:(std::shared_ptr)jsInvoker { - return RNTesterTurboModuleProvider(name, instance, jsInvoker); + return facebook::react::RNTesterTurboModuleProvider(name, instance, jsInvoker); } - (id)getModuleInstanceFromClass:(Class)moduleClass diff --git a/RNTester/RNTester/RNTesterTurboModuleProvider.h b/RNTester/RNTester/RNTesterTurboModuleProvider.h index d55c415bc6b..6a6a0ab3bc2 100644 --- a/RNTester/RNTester/RNTesterTurboModuleProvider.h +++ b/RNTester/RNTester/RNTesterTurboModuleProvider.h @@ -13,6 +13,11 @@ namespace facebook { namespace react { +/** + * Provide the TurboModule class for the given name. + */ +Class RNTesterTurboModuleClassProvider(const char *name); + /** * Provide a pure C++ instance of a TurboModule, specific to this app. */ diff --git a/RNTester/RNTester/RNTesterTurboModuleProvider.mm b/RNTester/RNTester/RNTesterTurboModuleProvider.mm index fd4b7726f05..81ecb0cb340 100644 --- a/RNTester/RNTester/RNTesterTurboModuleProvider.mm +++ b/RNTester/RNTester/RNTesterTurboModuleProvider.mm @@ -18,6 +18,10 @@ namespace facebook { namespace react { +Class RNTesterTurboModuleClassProvider(const char *name) { + return nil; +} + std::shared_ptr RNTesterTurboModuleProvider(const std::string &name, std::shared_ptr jsInvoker) { if (name == "SampleTurboCxxModule") { return std::make_shared(jsInvoker); diff --git a/React/CoreModules/React-CoreModules.podspec b/React/CoreModules/React-CoreModules.podspec new file mode 100644 index 00000000000..e8545e091d4 --- /dev/null +++ b/React/CoreModules/React-CoreModules.podspec @@ -0,0 +1,44 @@ +# coding: utf-8 +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' + +Pod::Spec.new do |s| + s.name = "React-CoreModules" + s.version = version + s.summary = "-" # TODO + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.compiler_flags = folly_compiler_flags + s.source = source + s.source_files = "**/*.{c,h,m,mm,cpp}" + s.header_dir = "React" + s.pod_target_xcconfig = { + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/React/CoreModules\" \"$(PODS_ROOT)/Folly\"" + } + + s.dependency "FBReactNativeSpec", version + s.dependency "Folly", folly_version + s.dependency "React-Core", version +end diff --git a/React/React-Core.podspec b/React/React-Core.podspec index 07b250db4c6..6f6bc68009a 100644 --- a/React/React-Core.podspec +++ b/React/React-Core.podspec @@ -31,7 +31,8 @@ Pod::Spec.new do |s| s.platforms = { :ios => "9.0", :tvos => "9.2" } s.source = source s.source_files = "**/*.{c,h,m,mm,S,cpp}" - s.exclude_files = "DevSupport/**/*", + s.exclude_files = "CoreModules/**/*", + "DevSupport/**/*", "Fabric/**/*", "Inspector/**/*" s.ios.exclude_files = "**/RCTTV*.*" diff --git a/scripts/autolink-ios.rb b/scripts/autolink-ios.rb index fde0d55bdba..3560a35246a 100644 --- a/scripts/autolink-ios.rb +++ b/scripts/autolink-ios.rb @@ -2,10 +2,10 @@ def use_react_native! (options={}) # The prefix to the react-native prefix = options[:path] ||= "../node_modules/react-native" - + # Include Fabric dependencies fabric_enabled = options[:fabric_enabled] ||= false - + # Include Turbo Modules dependencies turbo_modules_enabled = options[:turbo_modules_enabled] ||= false @@ -13,8 +13,12 @@ def use_react_native! (options={}) production = options[:production] ||= false # The Pods which should be included in all projects + pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector" + pod 'FBReactNativeSpec', :path => "#{prefix}/Libraries/FBReactNativeSpec" + pod 'RCTRequired', :path => "#{prefix}/Libraries/RCTRequired" pod 'React', :path => "#{prefix}/" pod 'React-Core', :path => "#{prefix}/React" + pod 'React-CoreModules', :path => "#{prefix}/React/CoreModules" pod 'React-RCTActionSheet', :path => "#{prefix}/Libraries/ActionSheetIOS" pod 'React-RCTAnimation', :path => "#{prefix}/Libraries/NativeAnimation" pod 'React-RCTBlob', :path => "#{prefix}/Libraries/Blob" @@ -25,6 +29,7 @@ def use_react_native! (options={}) pod 'React-RCTText', :path => "#{prefix}/Libraries/Text" pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration" pod 'React-RCTWebSocket', :path => "#{prefix}/Libraries/WebSocket" + pod 'React-TypeSafety', :path => "#{prefix}/Libraries/TypeSafety" unless production pod 'React-DevSupport', :path => "#{prefix}/React" @@ -35,6 +40,7 @@ def use_react_native! (options={}) pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi" pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor" pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector" + pod 'React-turbomodule-core', :path => "#{prefix}/ReactCommon/turbomodule/core" pod 'yoga', :path => "#{prefix}/ReactCommon/yoga" pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec" @@ -48,8 +54,5 @@ def use_react_native! (options={}) pod 'React-RCTFabric', :path => "#{prefix}/React" pod 'Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/Folly.podspec" end - - if turbo_modules_enabled - pod 'React-turbomodule-core', :path => "#{prefix}/ReactCommon/turbomodule/core" - end + end diff --git a/third-party-podspecs/Folly.podspec b/third-party-podspecs/Folly.podspec index e601da88b6d..937404bab27 100644 --- a/third-party-podspecs/Folly.podspec +++ b/third-party-podspecs/Folly.podspec @@ -72,4 +72,4 @@ Pod::Spec.new do |spec| # Pinning to the same version as React.podspec. spec.platforms = { :ios => "9.0", :tvos => "9.2" } -end \ No newline at end of file +end