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

feat(all): add support new arch #37

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

ngocle2497
Copy link
Contributor

@ngocle2497 ngocle2497 commented Jul 31, 2023

Summary

Add support New Architecture Turbo module
Add support typescript by env json file:
Screenshot 2023-07-31 at 16 08 59
Screenshot 2023-07-31 at 16 09 19

  • Android:
android - IOS: android

Changelog

  • Android
  • IOS

[feat] [all] - Add support New Architecture Turbo module

Test Plan

@numandev1
Copy link
Owner

@MasonLe2497 can you also add new arch support for IOS?, so we test it on both platform for RN 0.65, 0.69 and 0.72

@ngocle2497
Copy link
Contributor Author

@numandev1 sure. I'm working on it

@ngocle2497
Copy link
Contributor Author

Hi @numandev1 , i'm trying to add support, but when run example ios, i catch this error:

fatal error: 'openssl/evp.h' file not found
#include "openssl/evp.h"

Can u helpme?

@numandev1
Copy link
Owner

numandev1 commented Aug 1, 2023

Hi @numandev1 , i'm trying to add support, but when run example ios, i catch this error:

fatal error: 'openssl/evp.h' file not found
#include "openssl/evp.h"

Can u helpme?

@MasonLe2497 i think, somehow OpenSSL-Universal pod is not installed,

s.dependency "OpenSSL-Universal"

i see you have removed react-native-keys from pod file, can you add that line and test

@ngocle2497
Copy link
Contributor Author

Hi @numandev1 , i'm trying to add support, but when run example ios, i catch this error:

fatal error: 'openssl/evp.h' file not found
#include "openssl/evp.h"

Can u helpme?

@MasonLe2497 i think, somehow OpenSSL-Universal pod is not installed,

s.dependency "OpenSSL-Universal"

i see you have removed react-native-keys from pod file, can you add that line and test

No, i just update pod file like this:

require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
Pod::Spec.new do |s|
  s.name         = "react-native-keys"
  s.version      = package["version"]
  s.summary      = package["description"]
  s.homepage     = package["homepage"]
  s.license      = package["license"]
  s.authors      = package["author"]

  s.platforms    = { :ios => "12.4" }
  s.source       = { :git => "https://github.com/numandev1/react-native-keys.git", :tag => "#{s.version}" }

  s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,c,cpp}"

  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
  if respond_to?(:install_modules_dependencies, true)
    install_modules_dependencies(s)
  else
  s.dependency "OpenSSL-Universal"
  s.dependency "React-Core"
  # Don't install the dependencies when we run `pod install` in the old architecture.
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
    s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
    s.pod_target_xcconfig    = {
        "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
        "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
        "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
    }
    s.dependency "React-Codegen"
    s.dependency "RCT-Folly"
    s.dependency "RCTRequired"
    s.dependency "RCTTypeSafety"
    s.dependency "ReactCommon/turbomodule/core"
   end
  end 
end

@numandev1
Copy link
Owner

@MasonLe2497 can you try like this

s.dependency "OpenSSL-Universal"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
  if respond_to?(:install_modules_dependencies, true)
    install_modules_dependencies(s)
  end
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
  s.pod_target_xcconfig = {
    "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
    "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
  }
  s.dependency "React-Codegen"
  s.dependency "RCT-Folly"
  s.dependency "RCTRequired"
  s.dependency "RCTTypeSafety"
  s.dependency "ReactCommon/turbomodule/core"
else
  s.dependency "React-Core"
end

@ngocle2497
Copy link
Contributor Author

@MasonLe2497 can you try like this

s.dependency "OpenSSL-Universal"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
  if respond_to?(:install_modules_dependencies, true)
    install_modules_dependencies(s)
  end
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
  s.pod_target_xcconfig = {
    "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
    "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
  }
  s.dependency "React-Codegen"
  s.dependency "RCT-Folly"
  s.dependency "RCTRequired"
  s.dependency "RCTTypeSafety"
  s.dependency "ReactCommon/turbomodule/core"
else
  s.dependency "React-Core"
end

I just move s.dependency "OpenSSL-Universal" to end file. thanks

@ngocle2497 ngocle2497 changed the title feat(all): add support new arch for android feat(all): add support new arch Aug 1, 2023
@ngocle2497
Copy link
Contributor Author

@numandev1 can u review my PR?

@numandev1
Copy link
Owner

@numandev1 can u review my PR?

it is big PR, hopefully i will review it tomorrow, sorry for delay 🙏🏻

Copy link
Owner

@numandev1 numandev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot 💖💖 for PR, you are awesome

android/androidcpp/mediator.cpp Outdated Show resolved Hide resolved
android/cpp-adapter.cpp Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
cpp/decryptor.cpp Outdated Show resolved Hide resolved
lefthook.yml Outdated Show resolved Hide resolved
react-native-keys.podspec Show resolved Hide resolved
ios/privateKey.m Outdated Show resolved Hide resolved
ios/YeetJSIUtils.mm Outdated Show resolved Hide resolved
ios/Keys.mm Outdated Show resolved Hide resolved
@ngocle2497
Copy link
Contributor Author

@numandev1 yeah. i resolved all comment. ha ha

@numandev1
Copy link
Owner

numandev1 commented Aug 2, 2023

@numandev1 yeah. i resolved all comment. ha ha

can you squash all commit to one commit? I have to check all test cases and try this code on different versions, I will let you know if I face any problems, and after that, we will release a new version with this PR

Thanks a lot, you are awesome

@ngocle2497
Copy link
Contributor Author

Yes. of cource

@ngocle2497 ngocle2497 force-pushed the feat/turbo_module branch 2 times, most recently from 6a2f467 to 8b7aaa8 Compare August 2, 2023 14:10
.gitignore Outdated Show resolved Hide resolved
example/package.json Show resolved Hide resolved
example/package.json Outdated Show resolved Hide resolved
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}
s.dependency "React-Codegen"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that this file block is not executing
you can add this puts "executing RCT_NEW_ARCH_ENABLED" line in this block to print if this block is executing or not

this command should work, currently, only this command is working but it is also not executing that block RCT_NEW_ARCH_ENABLED=1 bundle exec pod install

RCT_NEW_ARCH_ENABLED=1 && pod install

Copy link
Contributor Author

@ngocle2497 ngocle2497 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u want to remove this?

s.pod_target_xcconfig    = {
        "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
        "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
        "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
    }

Copy link
Owner

@numandev1 numandev1 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MasonLe2497 No, I see that install_modules_dependencies does not exist in 0.70 we have to just verify if RCT_NEW_ARCH_ENABLED=1 && pod install command is enabling new arch or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@numandev1 yes. it available in 0.71 and further

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
  if respond_to?(:install_modules_dependencies, true)
    install_modules_dependencies(s)
  else
  s.dependency "React-Core"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but RCT_NEW_ARCH_ENABLED=1 && pod install this command is not installing new arch, can you check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can resolve this conversation?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MasonLe2497 did you fix enabling new arch by this command cd ios && RCT_NEW_ARCH_ENABLED=1 pod install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still working as well

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keys.mp4

on my side, this cd ios && RCT_NEW_ARCH_ENABLED=1 pod install command is not picking codegen schema or artifacts but RCT_NEW_ARCH_ENABLED=1 bundle exec pod install this is picking codegen schema and artifacts correctly

Copy link
Contributor Author

@ngocle2497 ngocle2497 Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. on my side. it working
image

Result of rn info:

System:
OS: macOS 13.4.1
CPU: (8) arm64 Apple M1
Memory: 85.13 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 16.20.1
path: ~/Library/Caches/fnm_multishells/6573_1691481597947/bin/node
Yarn:
version: 1.22.19
path: /opt/homebrew/bin/yarn
npm:
version: 8.19.4
path: ~/Library/Caches/fnm_multishells/6573_1691481597947/bin/npm
Watchman:
version: 2023.07.10.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK:
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.10121639
Xcode:
version: 14.3.1/14E300c
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.20
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/ngoc.le/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: true

@ngocle2497 ngocle2497 force-pushed the feat/turbo_module branch 2 times, most recently from 7b9c49f to 3138e52 Compare August 7, 2023 01:49
Copy link
Owner

@numandev1 numandev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot ❤️. Going to release an alpha version, lets see the feedback of users

@numandev1 numandev1 merged commit 2f76010 into numandev1:master Aug 14, 2023
0 of 5 checks passed
@numandev1
Copy link
Owner

available in 0.6.0-alpha.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants