React Native
How to get your React Native app into Moropo
Last updated
How to get your React Native app into Moropo
Last updated
Moropo fully supports React Native.
In this guide, we will look at how to build React Native apps ready to import into Moropo and how to add identifiers to your app to improve test accuracy.
We'll start by initialising the example React Native app.
For each of the apps, we need to ensure that they are built in release
mode. When a React Native app is built in development
mode it is dependent on the local JS server on your machine.
Remember that you need to make a new build every time that you make changes locally. If you are using Expo then you can make use of OTA updates instead to reduce the number of native builds that you need to create.
If you are currently using GitHub actions to build your app then you can pass the build straight to our GitHub Action.
Run npx react-native build-android --interactive
and select assemble
, this will create both the debug
and release
apks in the android folder.
Now take the output app-release.apk
and upload it to your app in Moropo.
cd ios
to change your working directory to the ios folder and run xcodebuild -workspace AwesomeProject.xcworkspace -configuration Release -scheme AwesomeProject -destination 'generic/platform=iOS Simulator'
.
The important parts of that command are the configuration
set to release so that the app is not dependent on your local JS server and the destination
set to Simulator so that a .app file is built ready for Moropo.
The file will be output to a special Xcode folder. For me that looked like this:
/Users/{{YOUR USERNAME}}/Library/Developer/Xcode/DerivedData/AwesomeProject-cxfaqbcfvcboddaxdadozkmshhpg/Build/Products/Release-iphonesimulator/
You will see this location output in the terminal at the end of the build.
Once you have located the file, compress it into a zip file and you're ready to upload to Moropo.
I have created 2 builds based on the default React Native app. The first app has an exciting new image component based on my favourite image placeholder site PlaceKitten.
The first build has this full-width kitten addition and I would like to click on it in Moropo.
Unfortunately, there is no unique identifier against this component so the only thing Moropo sees when you click on the image is the percentage-based coordinates.
The way we solve this problem is by providing a unique reference in the code which allows it to be uniquely identified by Moropo.
Different frameworks have different ways of providing this identifier, on React Native the way to do it is with a testID
.
I have given the image a testID
of 'kitten':
And now we have a unique ID!