Building app locally without ejecting?


#1

So, I’m trying to figure out a workflow to build my application locally without ejecting first. My goal is to build far faster than Expo can, mainly, though I general I like doing things locally when possible.

So, to start I ran react-native eject to build which produces the needed android/ios directories. I also created an index.ios.js and index.android.js file to load the main App.js.

With a normal CRNA application, this is enough to make the application build and run locally. However, with Expo, the fonts are not found during the bundling of the application. I run into errors, similar to this. As mentioned in that thread, this seems to be a result a the babel-plugin-module-resolver not being present.

Oh, and I’m using react-native start as the packager and react-native run-android to run the actual build.

So, that’s basically where I am. I have all the dependencies to run a plain react native app locally without issue - but now I’m trying to build an “Expo” app (i.e., one using the expo sdk) locally as well. Any thoughts would be much appreciated!


#2

If you want to use ExpoKit in a detached Expo Application you need to follow the steps provided in the docs here: https://docs.expo.io/versions/v19.0.0/guides/detach.html#content

I’ve recently ran through the steps and I’ve managed to detach without any issues. Let me know if you run into any problems :slight_smile:


#3

Well, as mentioned I do not want to detach/eject. I’d like to simply build my normal expo app locally. All of the above are steps I’ve taken to figure out how to build locally without expo - and while still using the ExpoSDK of course.

The ExpoSDK is the only thing causing problems at the moment.

edit: And by build, I mean locally produce an APK/IPA.


#4

Sorry I must be a little dense this morning, I misunderstood.

Have you read through the steps here? https://docs.expo.io/versions/v19.0.0/guides/building-standalone-apps.html#content


is there a way to compile your project local?
#5

You’re not being dense at all, it’s an abnormal question. Yup I did view the standalone instructions, but they focus on detaching from Expo (unless I missed the section) which is not what I want. I don’t expect there to be a solution, I am basically hacking Expo, I get that… but I figured it’d worth asking.

To try and word it differently to make my goal clear. When you type expo build:android it uploads your code to Expo’s servers and builds it, eventually giving you an APK/IPA to download. I want to build locally, not uploading to Expo.io. Of course, I can detach to achieve this, but I don’t want to detach, I want to keep using Expo - i’m not adding any native code, there is no reason (that I can see) that I should need to detach. All I want is to build my APK locally, because I already have Android Studio/etc setup.

The issues I run into are minor it seems. Mainly to due with Babel rewriting some Font locations. Hence why I was posting here hoping someone would have some experience in what I’m trying to do.

Hope I made sense :slight_smile:


#6

You can build the APK locally using the local standalone instructions. That said, it still depends on publishing your JS to our service. If you want to handle your bundle differently you’ll probably need to use ExpoKit and change the native code.


#7

Interesting! But doesn’t publishing cause the application to be built on the Expo servers?

Eg, the “local” standalone instructions you link cite the first step as being:

Publish your experience from XDE or exp. Note the published url.

Likewise, a following step refers to a URL of the published experience… what is the published experience? Isn’t this the application? Hence, it’s still built remotely, on Expo.io’s servers?

edit: Perhaps it’s just uploading the source, but not building? I need to figure out exactly what publish does, if not build… hmm.


#8

According to this publishing still uploads the source code to the cdn. I’ll need to experiment with those instructions, but if it really does build locally, it seems really strange that it builds locally - including signing - yet still uploads your source code to Expo. Is there an obvious reason I’m missing for the upload?


#9

There are a few separate concepts here (apologies for the confusing naming):

  • compiling/building your JavaScript into a minified bundle (this happens on your computer using the Expo devtools like XDE)
  • publishing/uploading your minified JS bundle to the CDN, populating the project’s entry in our database (this takes the output from the above step and uploads it, so its both local and remote)
  • building the standalone application and signing it for distribution in app stores (this can be done locally using the instructions I linked above, or it can be done using our standalone app build service)

Does that make sense?

The reason the minified bundle needs to be uploaded is to support remote updates to your application – by publishing a new JS bundle you can ship bugfixes for your application without having to rebuild a binary and resubmit to the app stores.


#10

I think local standalone instructions are not very clear. It would be great if there was a step by step guide (or better a video).


#11

@mozgul we could probably use our help to improve them, what part of docs guide is not clear? https://docs.expo.io/versions/latest/guides/building-standalone-apps.html#content I want to help improve these instructions with you.


#12

First of all, if I want to do exp build:ios, it fails because there is no ios dir.
I have to exp detach and then remove the detach info from app.json, so it works.

Second, as already stated, you can give the option of building the app locally. It’s cool to have the IPA generated for you remotely, but I do not need that.

Third, when I do exp build:android, I see in logs, ‘Building iOS bundle’ included.

I can still give you more feedback. I am currently working on an app that has iOS and Android versions, it was detached, but now I reattached it, and I am following the building-standalone-apps.html page.


#13

@nunocardoso thanks for the feedback here.


#14

I was thinking, would it make sense for us to engage in a mode that maintains all the local expo stuff, and do the eject from a local fork (of it?)? Like similar to copying to a new directory then ejecting that clone; or put in another way, would be be possible to temporarily eject for the purposes of local build then reverting all back?