React Native iOS and Android folders not present
Asked Answered
S

16

106

I'm new to react native, and I've been having some trouble understanding the folder structure of the app which should supposedly be present in the project folder on creation. Basically, when creating the project with npm, I get some starting files (App.js etc.) and a node_modules folder. I've got it up and running with expo, which created the .expo folder as well.

However, when I go to react's official documentation or look into plugins/addons on git they talk several times about an android and an iOS folder in the project root. But they are nowhere to be seen. I then got some hints that I could install and run react-native-upgrade-git, which allegedly would generate these missing folders. But that didn't work either.

So what have I missed? Where are those folders located?

Edit: Here is a screen dump from a Youtube tutorial showing the project structure I'm looking for:

enter image description here

Samarasamarang answered 30/5, 2017 at 19:34 Comment(0)
M
66

One of the points of Expo on top of React Native is that you don't go down to android or ios code. Expo deals with those folders for you, you don't need to interact with them. Is there a reason you need those folders? if so, you will have to eject. Here's the documentation to do so: Ejecting with ExpoKit

Mahdi answered 30/5, 2017 at 19:54 Comment(8)
The reason I'm uncertain has to do, amongst other things, with the following addon: github.com/auth0/react-native-lock. When reading the readme provided it seems like I need to access the folders and do some shenanigans. Or is the npm install line enough? Thanks for the answer.Samarasamarang
After you npm install the library. You're supposed to enter into your terminal "react-native link react-native-lock". If i'm correct, Expo will not let you do that unless you detach your project to Expokit. Check out the link in my answer.Mahdi
to connect ar with react-nativeImidazole
How would I get apk from react native without android files?Update
The link is broken.Leal
@BhargavThanki Thank you for telling me. The link is now fixed! :)Mahdi
try this--https://mcmap.net/q/204967/-execution-failed-for-task-39-app-compiledebugjavawithjavac-39-react-nativeHigherup
if I need to add the firebase auth to my app? It says I need itJolo
N
37

You can get to that project structure by running:

npm run eject

However, it removes the app from the Expo framework, which adds a lot of nice benefits and abstraction from the Android/iOS code.

Nonflammable answered 19/7, 2017 at 0:40 Comment(1)
after that what to do? xcode is not running properly @Danny SullivanHeroine
C
36

Check this Expo document Adding custom native code

In general,

  • to generate ios folder: npx expo run:ios
  • to generate android folder: npx expo run:android
Chimney answered 17/3, 2022 at 8:58 Comment(1)
This is the most up-to-date answer for adding custom native code in ios and android folders. You do not need to eject anymore > Eject to ExpoKit, where you get the native projects along with ExpoKit. This option is deprecated and support for ExpoKit was removed after SDK 38.Mistrial
C
20

i think if you want to develop app with ReactNative you start follow this : Getting Started use React Native.

If you create project with ReactNative just write on your terminal like:

react-native init YourProjectName
cd YourProjectName
react-native run-ios //for iOS

I hope my answer helping you to create project with ReactNative. thanks..

Cheriecherilyn answered 19/7, 2017 at 4:6 Comment(2)
This answer should get a lot more attention than it does. I strongly suggest you edit this answer to explain a bit more that the other cli from facebook has expo built in which the whole point is to not have to edit native code. This way allows you to dive deeper using the ios and android directory. I know this myself and still had to search for the correct cli just now setting up my new computer. I was about to answer this myself when I noticed your answer. Thanks! I think if you add more to this people will end up finding this and upvoting it more.Tengler
Totally agreed. This answer should get more attention indeed.Honoria
S
12

Try this to generate the Android and iOS folder

react-native eject

react-native link
Sihon answered 31/7, 2018 at 12:28 Comment(1)
"expo eject" worked for me..it created both android and IOS folderOutstare
A
11

To add to Funk Soul Ninja's answer after following his directions (thank you! :) ), for those who started with an Expo project:

expo run:ios

did the trick for me.

The command creates the ios folder that contains the project that can be edited and built in Xcode.

I did not do this step, but I believe expo run:android does exactly the analogous thing for Android; but I would suggest checking out Expo documentation on adding custom native code.

Athalia answered 20/8, 2021 at 17:38 Comment(0)
C
6

I think I am little late but follow this steps if you don't want to read any document.

android and ios folder are not present when react native project is created with expo. so you have to detach expo from your project to create android and ios folder.

first add required package name in app.json file

    ios: {
       bundleIdentifier: "com.yourcompany.yourappname",
    },
    android: {
       package: "com.yourcompany.yourappname",
    }

then run below command in terminal

exp detach

after command is successfully executed you will find android and ios folder

Ceiling answered 31/1, 2018 at 11:22 Comment(1)
I have not had luck with the Android bundle identifier and the ejected path. It doesn't create the yourcompany directory. Have you had luck with this? See #48526951Cp
B
3

Delete folders android and ios

npm i react-native-eject
react-native eject
Barmaid answered 8/8, 2020 at 19:23 Comment(0)
A
3

Expo is updated their command to eject,

To eject and use your custom model

npx expo prebuild

This command ejects your Android and ios folder for further updation

To Run on android device

npx expo run:android

To Run on IOS Device

npx expo run:ios

For more detail https://docs.expo.dev/workflow/prebuild/

Aurelio answered 27/6, 2023 at 11:17 Comment(0)
B
2

run this in the root directory

expo eject 
Boutique answered 12/9, 2022 at 4:37 Comment(0)
L
1

I had to run expo eject. The story behind why I didn't have the folders is had to downgrade my react-native application because of some broken dependencies and then I got build failures. So I deleted the ios and android folders then ran expo eject and got all the build issues fixed. Note that I used expo command line via a script in package json so that the versions would match the version my project was using.

Luthanen answered 12/10, 2020 at 3:1 Comment(0)
F
0

in the begining install react native, after run expo init YourProject , choose minimal (Typescript) . after that go to YourProject directory and do not run npm start. but run npm run android. hope this help

Fungi answered 8/8, 2019 at 8:44 Comment(1)
Welcome to SO! Please fix the formatting to make your answer better readable! See stackoverflow.com/help/how-to-answerGnathic
L
0

This worked for me: Go to Setting and remove both entries "android" and "ios" from "Files:Exclude". Don't forget both environments - User and Workspace.

Removing entries on Workspace: Remove entries "android" & "ios" from Workspace and...

... same for User:

...remove from User

Lottie answered 13/3, 2020 at 13:39 Comment(0)
P
0

If you created the project with Expo you will have the Expo folder instead of ios and android folders

Pimentel answered 25/7, 2022 at 11:12 Comment(0)
L
0

If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:

npm uninstall -g react-native-cli @react-native-community/cli

then create a new project again:

npx react-native init DemoApp
Lukewarm answered 19/12, 2022 at 8:49 Comment(0)
G
-6

The simplest way I know

1) Take your app name from your current app.json, let's say the name is "mynativeapp"

2) make a new folder somewhere outside of your current project folder

3) start in it:

react-native init mynativeapp

4) the command above will make android and ios folders internally compatible by name with your project

5) copy android/ios folders into your project folder

Now you can try to start your native project. I checked that for Android:

react-native run-android

enjoy!

P.S. "react": "16.9.0", "react-native": "0.61.4"

Glasswort answered 7/11, 2019 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.