The instruction assumes that you have the following tools installed and you have set environment variables properly:
- npm or yarn
- react-native-cli
Steps:
- Create a new project:
react-native init AwesomeProject --version 0.60.5
- Go to the project directory
- Add Magic Script Components ReactNative library to the project:
yarn add magic-script-components-react-native
- Add Magic Script Components library to the project:
yarn add magic-script-components
- Execute
react-native link
in order to link the libraries, - In the main project directory add
proxy_mobile
folder from https://github.com/magic-script/magic-script-components-catalog
The instruction assumes that you have the following tools installed and you have set environment variables properly:
- npm or yarn
- react-native-cli
- Android Studio (or a standalone Android SDK)
- Java JDK
Steps:
-
In the
./android/build.gradle
file setminSdkVersion
to 24 -
Open
android/app/src/main/AndroidManifest.xml
file and add the following between the<application>
tags:<meta-data android:name="com.google.ar.core" android:value="required" />
Add the permission to use the Camera:
<uses-permission android:name="android.permission.CAMERA" />
And optionally this above the
<application>
tag:<uses-feature android:name="android.hardware.camera.ar" android:required="true" />
*This tag indicates that this application requires ARCore. This results in the application only being visible in the Google Play Store on devices that support ARCore)
You can compare your AndroidManifest file with this one
The instruction assumes that you have the following tools installed and you have set environment variables properly:
- npm or yarn
- react-native-cli
- XCode version > 10
- CocoaPods version > 1.7.5
- Create Empty.swift file inside project and
Create bridging header file
- In Podfile file update
platform :ios, ‘9.0’
toplatform :ios, ‘12.0’
- Declare
Privacy - Camera Usage Description
in Info.plist - Declare
Privacy - Location When In Use Usage Description
in Info.plist - Open terminal, navigate to
./ios
directory and executepod install
in order to install necessary Pods
Steps
-
Run
yarn
ornpm install
to install the dependencies -
Replace App.js content with the following:
import React from 'react'; import { View, Text } from 'magic-script-components'; class MyApp extends React.Component { render() { return ( <View> <Text localPosition={[0, 0, 0]} alignment={'center-center'}>Welcome in AR!</Text> </View> ); } } export default MyApp
-
Replace
index.js
content with the following:import React from 'react'; import { MagicScript } from './proxy_mobile'; import MyApp from './App'; MagicScript.registerApp('AwesomeProject', <MyApp />, false);
-
In order to build & install the application on Android or iOS device, execute one of the following in root directory:
react-native run-android
orreact-native run-ios