一、使用Expo进行开发React Native——弹出Andr

2019-11-07  本文已影响0人  阿拉斌

我开始是使用React Native进行开发的,但是老是出现热更新的问题,很头大,所有准备使用expo进行开发下,看看效果。
expo的地址:https://expo.io/learn
现在好像最先的是 35.0.0 React Native 0.59.10
不过问题不大,照着官网来,就可以运行一个简单的APP了

image.png
我们可以看这个目录。
上面两个都是expo的一些配置文件,跟我木有关系,哈哈哈
跟传统的开发不同,我不能自己去改Android文件和IOS文件,这点很头大,我在想能不能使用高德地图了~
我在查看了官方文档,发现可以弹出使用eject来弹出Android和IOS的源码,使用cmd进行执行
官方说明:expo eject
会出现一个选项
Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding,
so you can revert the changes made by this command if necessary.

? How would you like to eject your app?
  Read more: https://docs.expo.io/versions/latest/expokit/eject/ (Use arrow keys)
> Bare: I'd like a bare React Native project.(是将要使用一个纯粹的React Native项目)
  ExpoKit: I'll create or log in with an Expo account to use React Native and the Expo SDK.(我将创建或登录一个Expo帐户来使用React Native和Expo SDK)
  Cancel: I'll continue with my current project structure.

我们先选择下第一个,看看效果(推荐使用第二个)

We have a couple of questions to ask you about how you'd like to name your app:
? What should your app appear as on a user's home screen? 示例1
? What should your Android Studio and Xcode projects be called? demo1
Writing app.json...
Wrote to app.json, please update it manually in the future
Successfully copied template native code.
Updating your package.json...
Your package.json is up to date!
Adding entry point...
Added new entry points!
Note that using `yarn start` will now require you to run Xcode and/or Android Studio to build the native code for your project.
Removing node_modules...
Installing new packages...
> yarn install
yarn install v1.12.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...

success Saved lockfile.
$ jetify
Jetifier found 1640 file(s) to forward-jetify. Using 8 workers...
Done in 32.02s.

Ejected successfully!

Before running your app on iOS, make sure you have CocoaPods installed and initialize the project:

  cd ios
  pod install

Then you can run the project:

  yarn android
  yarn ios

Warning: your app includes 1 package that requires additional setup. See the following URL for instructions.
Your app may not build/run until the additional setup for this package has been completed.

- react-native-maps: https://github.com/react-native-community/react-native-maps
image.png

这就弹出来了,我选的是第一个模式,所以在启动项目的时候,跟普通的RN项目差不多~。
所以~
换一个方式

Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding,
so you can revert the changes made by this command if necessary.

? How would you like to eject your app?
  Read more: https://docs.expo.io/versions/latest/expokit/eject/ ExpoKit
An Expo user account is required to proceed.
? How would you like to authenticate?
  Make a new Expo account
> Log in with an existing Expo account
  Cancel

要登录账号,登录之后,正常操作就是了~

这个操作很迷,跟网络有关系的~

几个问题

  1. 我的热更新有问题!!!

这个严重限制了我对RN的热爱,,,

上一篇下一篇

猜你喜欢

热点阅读