Skip to content

Commit

Permalink
Merge pull request #40281 from staszekscp/ios-new-arch-hybrid
Browse files Browse the repository at this point in the history
[HybridApp] Fix new arch on iOS for HybridApp
  • Loading branch information
AndrewGable authored Apr 25, 2024
2 parents a795127 + 0b09f0f commit f5ab826
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 39 deletions.
22 changes: 17 additions & 5 deletions patches/@onfido+react-native-sdk+10.6.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,17 @@ index 0000000..3b65b7a
+@end
diff --git a/node_modules/@onfido/react-native-sdk/ios/RNOnfidoSdk.mm b/node_modules/@onfido/react-native-sdk/ios/RNOnfidoSdk.mm
new file mode 100644
index 0000000..4d21970
index 0000000..998f79b
--- /dev/null
+++ b/node_modules/@onfido/react-native-sdk/ios/RNOnfidoSdk.mm
@@ -0,0 +1,59 @@
@@ -0,0 +1,64 @@
+#import "RNOnfidoSdk.h"
+
+#ifdef USE_FRAMEWORKS
+#import <onfido_react_native_sdk/onfido_react_native_sdk-Swift.h>
+#else
+#import <onfido_react_native_sdk-Swift.h>
+#endif
+
+@implementation RNOnfidoSdk {
+ OnfidoSdk *_onfidoSdk;
Expand Down Expand Up @@ -1189,7 +1194,7 @@ index 0000000..c48f86e
+
+export default TurboModuleRegistry.getEnforcing<Spec>("RNOnfidoSdk");
diff --git a/node_modules/@onfido/react-native-sdk/js/Onfido.ts b/node_modules/@onfido/react-native-sdk/js/Onfido.ts
index db35471..8bb6a57 100644
index db35471..fa6c1ef 100644
--- a/node_modules/@onfido/react-native-sdk/js/Onfido.ts
+++ b/node_modules/@onfido/react-native-sdk/js/Onfido.ts
@@ -1,4 +1,4 @@
Expand Down Expand Up @@ -1222,7 +1227,7 @@ index db35471..8bb6a57 100644

addCustomMediaCallback(callback: (result: OnfidoMediaResult) => OnfidoMediaResult) {
diff --git a/node_modules/@onfido/react-native-sdk/onfido-react-native-sdk.podspec b/node_modules/@onfido/react-native-sdk/onfido-react-native-sdk.podspec
index a9de0d0..fcd6d14 100644
index a9de0d0..da83d9f 100644
--- a/node_modules/@onfido/react-native-sdk/onfido-react-native-sdk.podspec
+++ b/node_modules/@onfido/react-native-sdk/onfido-react-native-sdk.podspec
@@ -2,6 +2,8 @@ require "json"
Expand All @@ -1234,7 +1239,7 @@ index a9de0d0..fcd6d14 100644
Pod::Spec.new do |s|
s.name = "onfido-react-native-sdk"
s.version = package["version"]
@@ -15,10 +17,15 @@ Pod::Spec.new do |s|
@@ -15,10 +17,22 @@ Pod::Spec.new do |s|
s.platforms = { :ios => "11.0" }
s.source = { :git => "https://github.com/onfido/react-native-sdk.git", :tag => "#{s.version}" }

Expand All @@ -1246,6 +1251,13 @@ index a9de0d0..fcd6d14 100644
- s.dependency "React"
- s.dependency "Onfido", "~> 29.6.0"
+ s.dependency "Onfido", "~> 29.7.0"
+
+ if ENV['USE_FRAMEWORKS'] == '1'
+ s.pod_target_xcconfig = {
+ "OTHER_CFLAGS" => "$(inherited) -DUSE_FRAMEWORKS",
+ "OTHER_CPLUSPLUSFLAGS" => "$(inherited) -DUSE_FRAMEWORKS",
+ }
+ end
+
+ if defined?(install_modules_dependencies()) != nil
+ install_modules_dependencies(s)
Expand Down
47 changes: 38 additions & 9 deletions patches/@shopify+flash-list+1.6.3.patch

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions patches/react-native+0.73.4+014+fixPath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js b/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js
index 025f80c..d276c69 100644
--- a/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js
+++ b/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js
@@ -454,7 +454,7 @@ function findCodegenEnabledLibraries(
codegenConfigFilename,
codegenConfigKey,
) {
- const pkgJson = readPackageJSON(appRootDir);
+ const pkgJson = readPackageJSON(path.join(appRootDir, process.env.REACT_NATIVE_DIR ? 'react-native' : ''));
const dependencies = {...pkgJson.dependencies, ...pkgJson.devDependencies};
const libraries = [];

73 changes: 60 additions & 13 deletions patches/react-native-vision-camera+4.0.0-beta.13.patch
Original file line number Diff line number Diff line change
@@ -1,33 +1,77 @@
diff --git a/node_modules/react-native-vision-camera/VisionCamera.podspec b/node_modules/react-native-vision-camera/VisionCamera.podspec
index 3a0e313..357a282 100644
index 3a0e313..e983153 100644
--- a/node_modules/react-native-vision-camera/VisionCamera.podspec
+++ b/node_modules/react-native-vision-camera/VisionCamera.podspec
@@ -40,6 +40,7 @@ Pod::Spec.new do |s|
@@ -2,7 +2,13 @@ require "json"

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

-nodeModules = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
+pkgJsonPath = ENV['REACT_NATIVE_DIR'] ? '../react-native/package.json' : 'react-native/package.json'
+nodeModules = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('#{pkgJsonPath}')"`), '..')
+
+frameworks_flags = {
+ "OTHER_CFLAGS" => "$(inherited) -DUSE_FRAMEWORKS",
+ "OTHER_CPLUSPLUSFLAGS" => "$(inherited) -DUSE_FRAMEWORKS",
+}

forceDisableFrameProcessors = false
if defined?($VCDisableFrameProcessors)
@@ -15,6 +21,13 @@ workletsPath = File.join(nodeModules, "react-native-worklets-core")
hasWorklets = File.exist?(workletsPath) && !forceDisableFrameProcessors
Pod::UI.puts("[VisionCamera] react-native-worklets-core #{hasWorklets ? "found" : "not found"}, Frame Processors #{hasWorklets ? "enabled" : "disabled"}!")

+default_config = {
+ "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) SK_METAL=1 SK_GANESH=1 VISION_CAMERA_ENABLE_FRAME_PROCESSORS=#{hasWorklets}",
+ "OTHER_SWIFT_FLAGS" => "$(inherited) -DRCT_NEW_ARCH_ENABLED #{hasWorklets ? "-D VISION_CAMERA_ENABLE_FRAME_PROCESSORS" : ""}",
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/cpp/\"/** "
+}
+
Pod::Spec.new do |s|
s.name = "VisionCamera"
s.version = package["version"]
@@ -27,19 +40,13 @@ Pod::Spec.new do |s|
s.platforms = { :ios => "12.4" }
s.source = { :git => "https://github.com/mrousavy/react-native-vision-camera.git", :tag => "#{s.version}" }

- s.pod_target_xcconfig = {
- "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) SK_METAL=1 SK_GANESH=1 VISION_CAMERA_ENABLE_FRAME_PROCESSORS=#{hasWorklets}",
- "OTHER_SWIFT_FLAGS" => "$(inherited) #{hasWorklets ? "-D VISION_CAMERA_ENABLE_FRAME_PROCESSORS" : ""}",
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
- "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/cpp/\"/** "
- }
-
s.requires_arc = true

# All source files that should be publicly visible
# Note how this does not include headers, since those can nameclash.
s.source_files = [
# Core
+ "ios/VisionCamera.h",
"ios/*.{m,mm,swift}",
"ios/Core/*.{m,mm,swift}",
"ios/Extensions/*.{m,mm,swift}",
@@ -47,6 +48,7 @@ Pod::Spec.new do |s|
@@ -47,6 +54,7 @@ Pod::Spec.new do |s|
"ios/React Utils/*.{m,mm,swift}",
"ios/Types/*.{m,mm,swift}",
"ios/CameraBridge.h",
+ "ios/RNCameraView.h",

# Frame Processors
hasWorklets ? "ios/Frame Processor/*.{m,mm,swift}" : "",
@@ -66,9 +68,10 @@ Pod::Spec.new do |s|
@@ -66,9 +74,12 @@ Pod::Spec.new do |s|
"ios/**/*.h"
]

- s.dependency "React"
- s.dependency "React-Core"
- s.dependency "React-callinvoker"
+ s.pod_target_xcconfig = {
+ "OTHER_SWIFT_FLAGS" => "-DRCT_NEW_ARCH_ENABLED"
+ }
+ if ENV['USE_FRAMEWORKS'] == '1'
+ s.pod_target_xcconfig = default_config.merge(frameworks_flags)
+ else
+ s.pod_target_xcconfig = default_config
+ end
+ install_modules_dependencies(s)

if hasWorklets
Expand Down Expand Up @@ -609,8 +653,7 @@ index 0000000..56a6c3d
+include ':VisionCamera'
diff --git a/node_modules/react-native-vision-camera/android/src/main/.DS_Store b/node_modules/react-native-vision-camera/android/src/main/.DS_Store
new file mode 100644
index 0000000..63b728b
Binary files /dev/null and b/node_modules/react-native-vision-camera/android/src/main/.DS_Store differ
index 0000000..e69de29
diff --git a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt b/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt
index a7c8358..a935ef6 100644
--- a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt
Expand Down Expand Up @@ -1273,13 +1316,12 @@ index 0000000..46c2c2c
+#endif /* RCT_NEW_ARCH_ENABLED */
diff --git a/node_modules/react-native-vision-camera/ios/RNCameraView.mm b/node_modules/react-native-vision-camera/ios/RNCameraView.mm
new file mode 100644
index 0000000..63fb00f
index 0000000..019be20
--- /dev/null
+++ b/node_modules/react-native-vision-camera/ios/RNCameraView.mm
@@ -0,0 +1,373 @@
@@ -0,0 +1,377 @@
+// This guard prevent the code from being compiled in the old architecture
+#ifdef RCT_NEW_ARCH_ENABLED
+//#import "RNCameraView.h"
+#import <React/RCTViewComponentView.h>
+
+#import <react/renderer/components/RNVisionCameraSpec/ComponentDescriptors.h>
Expand All @@ -1292,7 +1334,12 @@ index 0000000..63fb00f
+#import <AVFoundation/AVCaptureVideoDataOutput.h>
+#import <React/RCTViewManager.h>
+#import <React/RCTConversions.h>
+
+#ifdef USE_FRAMEWORKS
+#import <VisionCamera/VisionCamera-Swift.h>
+#else
+#import "VisionCamera-Swift.h"
+#endif
+
+@interface RNCameraView : RCTViewComponentView <RNCameraViewDirectEventDelegate>
+@end
Expand Down
14 changes: 2 additions & 12 deletions src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {createContext, useEffect, useState} from 'react';
import React, {createContext} from 'react';
import type {ReactNode} from 'react';
import {Linking} from 'react-native';
import type {Route} from '@src/ROUTES';

/** Initial url that will be opened when NewDot is embedded into Hybrid App. */
Expand All @@ -15,16 +14,7 @@ type InitialURLContextProviderProps = {
};

function InitialURLContextProvider({children, url}: InitialURLContextProviderProps) {
const [initialURL, setInitialURL] = useState(url);
useEffect(() => {
if (initialURL) {
return;
}
Linking.getInitialURL().then((initURL) => {
setInitialURL(initURL as Route);
});
}, [initialURL]);
return <InitialURLContext.Provider value={initialURL}>{children}</InitialURLContext.Provider>;
return <InitialURLContext.Provider value={url}>{children}</InitialURLContext.Provider>;
}

InitialURLContextProvider.displayName = 'InitialURLContextProvider';
Expand Down

0 comments on commit f5ab826

Please sign in to comment.