📺 Develpreneur YouTube Episode

Video + transcript

React Native Getting Started - Simulators and Hello World

2021-09-16 •Youtube

Detailed Notes

Started Using React Native For Your Mobile Applications begins our new segment on React-Native. In this introductory episode we begin our journey by looking at what React Native is and why you should consider React Native for Mobile Development. Followed by a complete hands on session covering everything you need to get started, environments setup, libraries, etc. Once we're done with the setup we jump right into what you need to begin writing your first application.

In this episode, we focus on getting your code on to a simulator.

What is React-Native

React Native is an open-source mobile application framework created by Facebook, Inc. It is used to develop applications for Android, Android TV, iOS, macOS, tvOS, Web, Windows and UWP by enabling developers to use React's framework along with native platform capabilities.

What React Native Can Do? 1. Establishes Platform Independence

React Native was initially developed by Facebook to sustain iOS. However, it now supports all the methods specific to the Android operating system. So, it’s just like building a native app with a single codebase that works on both iOS and Android platforms.

2. Readily Available Reusable Components

Built with re-usability at its core, React Native enables you to make use of plug and play like features corresponding to iOS and Android. This makes the app architecture consistent with the following features:

Responsive UI and UX Web-like style of development as compared to hybrid frameworks Look, speed and feel of the native widgets 3. Revamp Existing Code

You can apply the UI components of React Native to an app code that already exists. This is an added advantage to businesses that need to supplement an app that exists but do not want to rebuild it. Embedding React Native UI components is a quick process and does not require re-writing.

4. Fast Compilation Through Hot Reloading

JavaScript is one of the fastest programming languages. It introduces another unique concept of Hot Reloading to provide better development experience. This feature combines the small compilation time of JavaScript and other capabilities. That means, you can make edits simultaneously without having to recompile it altogether. React Native brings the speed and agility of web app to the hybrid space and with the results of a native app.

What React Native Can’t Do? 1. Not Fully Scaled for Custom Modules

React Native has not addressed all its glitches. It also has missing custom modules which may take a lot of your time to build as well as to create modules of your own. You will require a specialized developer to address the technical challenges and bugs from time to time.

2. Guarantee Certainty

Even if Facebook has a developed framework, there is an uncertainty of its permanence because it still has the rights to do away with the project at any time. However, this is not likely to occur because of the technology popularity it has gained with time.

3. Handling Complex UI and Background Processing

If your apps are more interaction-intensive, then React Native might not be able to provide the best native experience. Also, apps that require a lot of background processes to work should not be built with React Native. It is even harder to get that performance benchmark for heavier apps.

4. Mitigate Heavy CPU Usage

React Native works on the interconnected Native and JavaScript modules that combine the power of script compilation and provide a native feel to the app. This process is highly CPU intensive and is a major cause of low app performance.

When To Started Using React Native Apps React Native should only be used for apps that fit into these categories: Traditional native-like apps for cross platforms with lesser views Less Hardware API access Budget apps Apps that require short development cycle When To Build Native Apps

Native apps should be your first choice if you have a budget that supports long term app development without compromising on specific features like:

Faster and heavy calculations Multi-threaded processes Easy and parallel updates with SDKs Strongly coded app with less bugs Apps with heavy UI and a lot of animations

Additional Resources React - https://reactjs.org/ Node - https://nodejs.org/en/ Visual Studio Code - https://code.visualstudio.com/ Android Development - https://developer.android.com/studio Xcode - https://apps.apple.com/us/app/xcode/id497799835?mt=12

Transcript Text
[Music]
now if you want to test
your application on your mobile device
or on a tablet or say another computer
you'll need to install the expo app
now you can go
expo client
so you can get the expo client app from
ios or android
uh on your computers you can do it
straight from a browser and i'll show
you that a little bit later
for android you'll have to go to your
android play store and download expo
and ios you'll go to the
app store to itunes
this way because it's not for desktop
but it'll look something like this on
the app store so expo with the funky
looking a with the little
half moon there
right once you have all that installed
close some of these tabs
you'll want to install visual studio
code
and i'll be at code.vigilstudio.com
and just click the download link and
install it for your local os
now i've already done that so i will
open up my copy of visual
code
now once
visual studios
code is installed
we want to install some extensions so
that we can actually do react native
development so you click the little
package icon here the extensions
and we want to search for some
extensions so you want to search for
react
and the ones you want are going to be
react native tools this one here
and you're going to want this one here
uh
es
7 react redo graphical
and let's see what else do i have i have
this uh this one here yeah react native
so this one
uh this one
and this one
are already installed
don't see the install link next to them
there install
and react
there we go so you should have these
three
extensions installed or in order to use
react native
then
there's a couple other libraries you can
install that will make your coding
easier so you want code
formatter or printer
this is pretty cool because what it will
do is this will allow us to
format our code every time we save our
code i'll show you how to set that up in
a second and then the other one we want
is
material icon themes this guy is pretty
neat i ran across him uh when i started
doing development with react native this
allows you to have custom design icons
for your mobile application so it kind
of gives you an out of the box tool kit
that allows you to quickly design icons
for your applications
all right once your extensions are
installed
up in our search
bar here we can we need to type in
the
let's see
type in form
on save
and
it's not an actual code or extension so
it's actually in settings so we open up
settings
and over here
we want to type for
format on
save
there we go so what we want to do here
is we want to enable format on save so
this is for that printer extension
so we check that and then we save and we
close our settings
and what this will do now is every time
we save our code it will automatically
format our code so if we don't need to
worry about indenting our tabs as we're
actually coding
alright so that sets up our vigil
studios environment
so let's start by creating our first
application here
let me close visual code
minimize this and go back out here
all right so i'm going to go into my
development folder
created a react workspace here
and let's
get rid of my
hello world and we'll just recreate
all right
there we go
all right
so now we just have a couple react
projects in here but we're going to
create a new one so to do that
at the command line you type expo
init
and your project name or your
application name so in our case we're
going to use hello world
now it gives you a couple options
we can
create a template using blank
we can
create a manage workflow which sets up a
pure javascript project without native
folders for ios and android
and
their workflows allows us to set up a
project with native folders for ios or
android so we can do blank we can do tab
we can do minimal or minimal with
typescript so in this particular case
we're going to do blank
i'm going to download
the installer and then it's going to
install the javascript dependencies and
build the project for us
take just a second
okay i like took a few more seconds
there we go
now once the project is
set up it gives you the steps on what
you need to do in order to edit your
project and to run your project so first
let's go into our project directory
because we are still in the root
so we need to go cd
hello world
and in here we have our files for our
project
now
we
we don't necessarily want to do
everything from the command line
so we can type in code
dot and this will open up visual code to
our current
folder
so here we go we have hello world
and here is our project structure
so we have our assets folder here
this contains all of your images videos
uh specific files
anything that you essentially want to
wrap within your application within your
mobile app
and then our apps.js is the essentially
your running file this is what gets
kicked off when you run your app
so let's look at how we actually start
our application
by kicking off expo and then look at
configuring
our environment so that we can actually
see the app run in both ios and android
so the first thing we want to do is we
want to
go to file
uh
terminal so within xcode or within
visual code we can actually run our
terminal so we don't have to keep
jumping back and forth anymore
from
visual studio and our terminal window so
we can do all of our work now from
within
visual code
all right so we have terminal
and if we do new terminal it opens this
up right into our hello world folder so
we don't have to go digging around for
this in our environment
now in our terminal let's type mnpm
start and this will start expo
so it started our project now if we want
to look at our development tools
we can load localhost
into our browser
if i open up
edge
put in localhost 1902 so here is our
dev management tool so we can actually
see
all the what's going on with our
application within expo
come back to that
oh yeah one other thing to mention about
that so this application it
it's loaded this is actually called the
metro bundler uh over here so this is
kind of telling you what is running
within expo
uh this is the javascript bundler for
react native
now if you're on
a mac you can actually download the
debug tools
the react native debugger
and you'll see
this as well
within the app
take a minute to open
this is also responsible for compiling
all of your javascript files into a
single file
it starts the app as either ios android
or a web browser
it sends a link to test the app via
email and it allows you to publish or
republish your project so as you see
here
you have the
little qr code which you could take a
picture of on your phone and then you
could actually test this app directly
from your phone
you could run this in a web browser by
clicking the button
open up here browser
and open up a browser
and you can also kick off the ios or
android these are the same commands
that you see here
so here's our app running in a browser
now if we go back over here
to our terminal window we can hit i
to open up ios
we can go
to our
browser
you can go back into our metro here we
could also click run on ios simulator
as you can see it's doing the same thing
here opening on iphone x
and opening on iphone x so everything
you see in the terminal here
is also displayed here in your metro
bundler
now if i try to run on android we got
the error message that our android
device is not set up yet and i'll walk
you through doing that in just a second
now before we talk about android since i
am on a mac let's start by looking at
how to set up an ios simulator
now i've already done this so because i
did click start on ios we will see the
emulator start up momentarily
but
let's walk through how to actually
configure for a different
emulator
so we want to first start up xcode
now once xcode is loaded you want to go
down
to open development tools and go to
simulator
one other thing you will need not just
simulator is uh if we go back over here
to
xcode
other development tools more developer
tools
when xcode installs
out of the get go it doesn't always
install the command line tools for your
local environment so you'll have to
actually go out to the apple developer
website
and actually look for the command line
tools for xcode
you'll select the latest version for
your version of xcode
click the little plus and then click the
command line tools and download
now since xcode is only available for
mac you only need to do this if you're
on a mac
once you download it then the simulator
will work if you try to run the
simulator first xcode will fail because
it can't communicate with the simulator
without this tool here
all right so let's go back over here
xcode
simulator
now
simulator is open it's already deployed
our app but up here we can go and do
file new simulator
and we can then go pick the
device that we want to test
so we can do anything from watch tv
ipads or iphones so say i want to do an
iphone
12 pro max
and
by selecting the device it will
automatically use that device name for
your name if you don't enter in anything
and then you can also change your os
versions now by default
xcode will always be loaded with the
latest ios tv os or watch os
if you need to test your simulator on an
older version of the ios you will need
to actually download that sdk for that
particular device
so we'll create this one
as you can see i'm currently running the
iphone x so let's change this to the
iphone 12 pro max
we'll create this guy
close the iphone x
now if i do file open simulator
ios 14 3
i can select my iphone 12 pro max
and that'll take a minute to start
you
Transcript Segments
1.32

[Music]

26.48

now if you want to test

29.599

your application on your mobile device

32.399

or on a tablet or say another computer

36.16

you'll need to install the expo app

39.2

now you can go

41.12

expo client

49.68

so you can get the expo client app from

51.92

ios or android

53.92

uh on your computers you can do it

55.68

straight from a browser and i'll show

57.36

you that a little bit later

59.199

for android you'll have to go to your

61.039

android play store and download expo

64.799

and ios you'll go to the

68.56

app store to itunes

75.6

this way because it's not for desktop

78.72

but it'll look something like this on

80.72

the app store so expo with the funky

83.36

looking a with the little

85.92

half moon there

94.479

right once you have all that installed

97.28

close some of these tabs

101.04

you'll want to install visual studio

104.96

code

107.119

and i'll be at code.vigilstudio.com

111.52

and just click the download link and

113.439

install it for your local os

116.799

now i've already done that so i will

118.32

open up my copy of visual

120.479

code

127.119

now once

128.479

visual studios

130.08

code is installed

132

we want to install some extensions so

133.76

that we can actually do react native

136

development so you click the little

137.84

package icon here the extensions

143.84

and we want to search for some

145.44

extensions so you want to search for

146.959

react

148.959

and the ones you want are going to be

150.48

react native tools this one here

155.519

and you're going to want this one here

157.76

uh

159.599

es

160.959

7 react redo graphical

164.48

and let's see what else do i have i have

166.48

this uh this one here yeah react native

169.12

so this one

170.8

uh this one

172.319

and this one

174.239

are already installed

176

don't see the install link next to them

181.44

there install

185.519

and react

187.12

there we go so you should have these

188.959

three

189.84

extensions installed or in order to use

192.72

react native

194.4

then

195.28

there's a couple other libraries you can

196.959

install that will make your coding

198.48

easier so you want code

203.44

formatter or printer

205.599

this is pretty cool because what it will

207.2

do is this will allow us to

210.08

format our code every time we save our

212.319

code i'll show you how to set that up in

214.56

a second and then the other one we want

218.08

is

220

material icon themes this guy is pretty

223.12

neat i ran across him uh when i started

225.519

doing development with react native this

227.84

allows you to have custom design icons

231.44

for your mobile application so it kind

234.239

of gives you an out of the box tool kit

236.4

that allows you to quickly design icons

239.04

for your applications

242.319

all right once your extensions are

243.76

installed

244.799

up in our search

246.4

bar here we can we need to type in

250.56

the

253.36

let's see

256.079

type in form

258.56

on save

261.919

and

262.8

it's not an actual code or extension so

266.16

it's actually in settings so we open up

268.08

settings

270.08

and over here

271.68

we want to type for

277.12

format on

279.36

save

281.759

there we go so what we want to do here

284.16

is we want to enable format on save so

286.96

this is for that printer extension

290.16

so we check that and then we save and we

293.52

close our settings

296.4

and what this will do now is every time

298.4

we save our code it will automatically

300.88

format our code so if we don't need to

303.12

worry about indenting our tabs as we're

305.919

actually coding

308.4

alright so that sets up our vigil

310.639

studios environment

312.4

so let's start by creating our first

314.479

application here

316.8

let me close visual code

319.039

minimize this and go back out here

323.52

all right so i'm going to go into my

324.96

development folder

328.8

created a react workspace here

332.4

and let's

333.759

get rid of my

335.28

hello world and we'll just recreate

362.96

all right

367.52

there we go

369.28

all right

370.96

so now we just have a couple react

373.36

projects in here but we're going to

374.8

create a new one so to do that

378

at the command line you type expo

381.84

init

382.96

and your project name or your

384.8

application name so in our case we're

387.28

going to use hello world

393.52

now it gives you a couple options

398.72

we can

400.88

create a template using blank

403.36

we can

404.639

create a manage workflow which sets up a

407.12

pure javascript project without native

409.44

folders for ios and android

412.8

and

413.599

their workflows allows us to set up a

416.72

project with native folders for ios or

419.36

android so we can do blank we can do tab

423.12

we can do minimal or minimal with

425.28

typescript so in this particular case

427.36

we're going to do blank

431.68

i'm going to download

433.28

the installer and then it's going to

435.919

install the javascript dependencies and

438.24

build the project for us

443.68

take just a second

461.36

okay i like took a few more seconds

471.039

there we go

472.96

now once the project is

475.28

set up it gives you the steps on what

477.44

you need to do in order to edit your

480.16

project and to run your project so first

483.28

let's go into our project directory

485.199

because we are still in the root

487.68

so we need to go cd

489.84

hello world

496.639

and in here we have our files for our

499.039

project

504.16

now

505.039

we

506.8

we don't necessarily want to do

508.16

everything from the command line

510.24

so we can type in code

512.56

dot and this will open up visual code to

515.839

our current

517.279

folder

518.56

so here we go we have hello world

520.88

and here is our project structure

528.08

so we have our assets folder here

531.12

this contains all of your images videos

534.56

uh specific files

536.64

anything that you essentially want to

538.24

wrap within your application within your

540.959

mobile app

542.24

and then our apps.js is the essentially

545.68

your running file this is what gets

548.32

kicked off when you run your app

552

so let's look at how we actually start

553.68

our application

555.279

by kicking off expo and then look at

558.8

configuring

560.32

our environment so that we can actually

561.92

see the app run in both ios and android

566.16

so the first thing we want to do is we

568.32

want to

569.68

go to file

572.24

uh

574.839

terminal so within xcode or within

578.72

visual code we can actually run our

581.519

terminal so we don't have to keep

582.959

jumping back and forth anymore

585.04

from

586.56

visual studio and our terminal window so

589.68

we can do all of our work now from

591.6

within

592.72

visual code

594.64

all right so we have terminal

596.959

and if we do new terminal it opens this

599.279

up right into our hello world folder so

602

we don't have to go digging around for

603.44

this in our environment

606.16

now in our terminal let's type mnpm

610.72

start and this will start expo

619.12

so it started our project now if we want

621.76

to look at our development tools

624.56

we can load localhost

627.519

into our browser

631.2

if i open up

632.399

edge

636.959

put in localhost 1902 so here is our

642.16

dev management tool so we can actually

645.519

see

647.36

all the what's going on with our

649.12

application within expo

652.48

come back to that

658.24

oh yeah one other thing to mention about

660.079

that so this application it

663.36

it's loaded this is actually called the

665.44

metro bundler uh over here so this is

668.399

kind of telling you what is running

670.16

within expo

671.6

uh this is the javascript bundler for

673.519

react native

674.88

now if you're on

676.399

a mac you can actually download the

679.92

debug tools

682.56

the react native debugger

685.68

and you'll see

686.959

this as well

688.72

within the app

691.44

take a minute to open

694.48

this is also responsible for compiling

696.72

all of your javascript files into a

698.72

single file

700.32

it starts the app as either ios android

703.44

or a web browser

705.44

it sends a link to test the app via

707.839

email and it allows you to publish or

710.24

republish your project so as you see

712.959

here

714.48

you have the

715.76

little qr code which you could take a

718.16

picture of on your phone and then you

720

could actually test this app directly

721.76

from your phone

723.36

you could run this in a web browser by

725.12

clicking the button

729.279

open up here browser

732.16

and open up a browser

743.519

and you can also kick off the ios or

746

android these are the same commands

748.48

that you see here

770.88

so here's our app running in a browser

776.639

now if we go back over here

779.36

to our terminal window we can hit i

782.72

to open up ios

786.48

we can go

787.68

to our

794.56

browser

795.519

you can go back into our metro here we

798.399

could also click run on ios simulator

802.48

as you can see it's doing the same thing

804.079

here opening on iphone x

806.72

and opening on iphone x so everything

809.36

you see in the terminal here

812.24

is also displayed here in your metro

814.88

bundler

816.8

now if i try to run on android we got

819.04

the error message that our android

820.88

device is not set up yet and i'll walk

822.72

you through doing that in just a second

827.76

now before we talk about android since i

830.16

am on a mac let's start by looking at

832.32

how to set up an ios simulator

835.519

now i've already done this so because i

837.6

did click start on ios we will see the

840.32

emulator start up momentarily

842.72

but

843.6

let's walk through how to actually

844.959

configure for a different

847.279

emulator

848.639

so we want to first start up xcode

852.399

now once xcode is loaded you want to go

855.279

down

857.04

to open development tools and go to

859.76

simulator

866.56

one other thing you will need not just

868.72

simulator is uh if we go back over here

872.079

to

875.12

xcode

877.92

other development tools more developer

880.56

tools

884.16

when xcode installs

886.24

out of the get go it doesn't always

888.32

install the command line tools for your

891.36

local environment so you'll have to

892.8

actually go out to the apple developer

895.68

website

896.8

and actually look for the command line

898.56

tools for xcode

900.639

you'll select the latest version for

902.72

your version of xcode

905.68

click the little plus and then click the

908.48

command line tools and download

911.04

now since xcode is only available for

913.839

mac you only need to do this if you're

916

on a mac

917.68

once you download it then the simulator

920.079

will work if you try to run the

921.44

simulator first xcode will fail because

924.16

it can't communicate with the simulator

925.92

without this tool here

930

all right so let's go back over here

935.12

xcode

938

simulator

940.56

now

941.519

simulator is open it's already deployed

943.839

our app but up here we can go and do

947.519

file new simulator

950.8

and we can then go pick the

953.519

device that we want to test

955.92

so we can do anything from watch tv

958.8

ipads or iphones so say i want to do an

962.56

iphone

963.68

12 pro max

966.639

and

967.519

by selecting the device it will

969.12

automatically use that device name for

971.6

your name if you don't enter in anything

973.839

and then you can also change your os

976.48

versions now by default

979.04

xcode will always be loaded with the

981.44

latest ios tv os or watch os

985.36

if you need to test your simulator on an

988.079

older version of the ios you will need

990.56

to actually download that sdk for that

993.279

particular device

995.519

so we'll create this one

997.279

as you can see i'm currently running the

999.279

iphone x so let's change this to the

1001.839

iphone 12 pro max

1004.24

we'll create this guy

1007.92

close the iphone x

1011.04

now if i do file open simulator

1014.399

ios 14 3

1017.199

i can select my iphone 12 pro max

1023.68

and that'll take a minute to start

1041.919

you