I am trying out the new react-native Turbo feature.
The calls to the cpp code works as the documentation mentions.
Is there a way to add external C++ libraries like cryptopp.
I have my github repo here RNTurbo.
Try to build your library with https://github.com/callstack/react-native-builder-bob - with interactive CLI you can generate a proper project structure with c++ libraries support for both platforms ios and android
Related
I want to implement this library into my expo project, however I'm having difficulties even getting an example up. Is this library compatible?
npm package link: https://www.npmjs.com/package/react-native-video
You can use Custom Development Client to use this library in an Expo Managed Project.
If you don't want to change anything in your project and use it as it is, you can try Expo AV. This provides a Video Component which you can use.
my question might be a little bit silly or ambiguous since I am fairly new to react native.
I'm trying to use the following repository for my react-native project https://github.com/smekalka/react-native-universal-pedometer. I have noticed that the repo is implemented in .java with platform folder unlike the regular .js or .ts files I used to see. Is this repository considered native module as react native doc describe?
Or in general how I can tell the whatever lib I am using is a native module.
The project is previously tested are under the support of expo-cli. I experienced the error null is not n object while using this repo. If so, I am probably going to eject the expo-cli and rewrite my code so I can use and even create own native-module for full control, some core implementations that written in other languages or expo-cli does not support.
Yes, the android and ios directories in the repository contain the 'native' code used to implement the platform-specific hooks that the Javascript will be able to pick up. Expo is not able to use these native modules or native code so your assumption is correct; you will need to eject your app in order to use this module.
If your app is below version 0.60 of React Native, after installing the module you will need to run react-native link react-native-universal-pedometer to link the native code to the Javascript runtime. If you're above 0.60, it will link automatically when installed.
I understand that react-native link (see post) is an automatic way to install native dependencies. The post above explain how to use the link command but lacking the detail of when to use it. Should it be used after adding a component, every code change or after introducing new module to the app?
Why we use react-native-link??
In this post, I will explain why we use react native link command and when we need to use this command or not?
First, we will understand what is native module??
Native Modules
Native modules are usually distributed as npm packages, apart from the typical javascript files and resources they will contain an Android and ios library project.
React Native provides an impressive amount of native modules that give you direct access to core platform APIs on both Android and IOS.
For example react-native-maps, react-native-firebase, react-native-socketio etc.
These modules or packages contained both platform (Android and Ios) code.
Now coming on to the react native link
Those libraries which are use native code, in that case you'll have to add these files to your app. For linking those library with react native code need to run react-native-link
Here are the few steps to link your libraries that contain native code
Automatic linking
Step 1
Install a library with native dependencies:
$ npm install --save
Step 2
Link your native dependencies:
$ react-native link
Done! All libraries with native dependencies should be successfully linked to your iOS/Android project.
Where we don't use react-native-link??
Those components which are only written in javascript they are not using any native code (Android and Ios). There is no need to run react-native-link.
For example rn-modal-picker, react-native-check-box etc.
You should check out this other answer: The use of react-native-link command?
You only need to run react-native link NAME_OF_PACKAGE when you install a new package that has a native codebase, or without arguments if you want to do it for multiple of them.
Can you use libraries like https://github.com/tolu360/react-native-google-places in an Expo project? I assume any npm library is ok to add, but what about libraries like this google places picker that requires post install steps to link the native projects. Are they supported with Expo?
Regular Expo projects are written only in JavaScript and don't support npm packages that contain Objective-C or Java. However, Expo provides an advanced SDK called ExpoKit for when you absolutely need to use custom native code. From the Expo docs:
Normally, Expo apps are written in pure JS and never “drop down”
to the native iOS or Android layer. This is core to the Expo
philosophy and it’s part of what makes Expo fast and powerful to
use.
However, there are some cases where advanced developers need native
capabilities outside of what Expo offers out-of-the-box. The most
common situation is when a project requires a specific Native Module
which is not supported by React Native Core or the Expo SDK.
You could "detach" your Expo project to create Xcode and Android Studio projects that contain ExpoKit. Then you would add custom Objective-C or Java the same way as with any other Xcode or Android Studio project.
However, the Expo docs also warn about some of the downsides of writing custom native code; many features often can be implemented well in JS, allowing you to retain all of the benefits of a standard Expo project.
Warning: We discourage most of our developers from taking this route,
as we believe almost everything you need to do is better accomplished
in a cross-platform way with JS.
Writing in JS enables you to best take advantage of over-the-air code
deployment and benefit from ongoing updates and support from Expo.
You should only do this if you have a particular demand from native
code which Expo won’t do a good job supporting, such as (for
example) specialized CPU-intensive video processing that must happen
locally on the device.
I am evaluating to switch from CoronaSDK to Cocos2D for cross platform development.
The main requirement is that I need to be able to include native libraries for iOS and Android. I have come across How To Integrate a 3rd party SDK into Plugin-X, but I am not sure if and how this would apply to Cocos2D-JS.
How can native 3rd party libraries (like ad network SDKs) be integrated into a Cocos2D-JS project, that will get compiled into native iOS and Android apps? Anybody with experiences or best practices?
That would work like normal native lib integration. For example. You want to integrate Firebase for Android platform.
What you will do is open the Android cocos project into your favorite Android editor and write native code, you can make calls to Java functions you have defined by using JSB which is a mechanism provided by Cocos2d-JS to call native functions from JS code.
When you build for Android, your lib for Firebase and code will get compiled perfectly.
Same is the case if you want to do for iOS.
Cocos2d also has support for SDKBox which has many third-party services SDK already implemented for you for both iOS and Android.