Skip to content

Commit

Permalink
Fixing folly include on RN0.63
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusmatos committed Jul 14, 2021
1 parent b4752fc commit f0d652c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
49 changes: 28 additions & 21 deletions VisionCamera.podspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

reactVersion = '0.0.0'
begin
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))["version"]
rescue
reactVersion = '0.64.0'
end

rnVersion = reactVersion.split('.')[1]
folly_name = "Folly"
if rnVersion.to_i >= 64
folly_name = "RCT-Folly"
end

folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=' + rnVersion
folly_version = '2020.01.13.00'
reactNativePackage = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))
isRN63 = reactNativePackage["version"].split('.')[1] == '63' rescue false

Pod::Spec.new do |s|
s.name = "VisionCamera"
Expand All @@ -32,10 +18,24 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
"DEFINES_MODULE" => "YES",
"USE_HEADERMAP" => "YES",
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_name}\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Public/React-hermes\" \"$(PODS_ROOT)/Headers/Public/hermes-engine\""
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
}
s.requires_arc = true

# RN 0.63 workaround
if isRN63
folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
boost_compiler_flags = '-Wno-documentation'

s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.xcconfig = {
"CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
"HEADER_SEARCH_PATHS" => "$(inherited) \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags
}
end

# All source files that should be publicly visible
# Note how this does not include headers, since those can nameclash.
s.source_files = [
Expand All @@ -58,8 +58,15 @@ Pod::Spec.new do |s|
"ios/**/*.h"
]

s.dependency "React-callinvoker"
s.dependency "React"
s.dependency "React-Core"
s.dependency "#{folly_name}"
# RN 0.63 workaround
if isRN63
s.dependency "React-callinvoker"
s.dependency "React-Core"
s.dependency "ReactCommon/turbomodule/core"
s.dependency "Folly", '2020.01.13.00'
else
s.dependency "React-callinvoker"
s.dependency "React"
s.dependency "React-Core"
end
end
2 changes: 1 addition & 1 deletion ios/React Utils/JSIUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime &runtime, const
wrapperWasCalled = YES;
};

if (RCTTurboModuleBlockCopyEnabled()) {
if (RCTTurboModuleEnabled()) {
return [callback copy];
}

Expand Down

0 comments on commit f0d652c

Please sign in to comment.