为什么 create-react-native-app 没有 ios 和 android 文件了? [英] Why create-react-native-app does not has ios and android files anymore?

查看:97
本文介绍了为什么 create-react-native-app 没有 ios 和 android 文件了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 React Native.我需要访问 android 和 ios 文件,以便我可以将地图添加到我的应用程序,但我找不到它们!

I am learning react native. i need to access to android and ios files so i can add maps to my app, but i cant find them!

我尝试查看资产文件、节点模块文件.但找不到.

i tried looking inside assets file, node modules file. but could not find them.

推荐答案

您已经使用 Expo 创建了您的应用.

You’ve created your app with Expo.

Expo 抽象了原生代码,这意味着您不必处理它.因此,这意味着无论您如何仔细查看 Expo 应用程序,您都找不到任何本机代码.

Expo abstracts away the native code, meaning that you don’t have to deal with it. So this means that no matter how hard you look inside an Expo app you won’t find any native code.

如果您无法使用 Mac 进行 iOS 开发,这会很有用.这也意味着你只需要用 Javascript 编写,而不必担心用 java 或 Objective-c 编写代码.

This can be beneficial if you don’t have access to a Mac for iOS development. It also means that you only need to write in Javascript and not worry about writing code in java or objective-c.

但是,Expo 可以访问其中的地图.查看 MapView 它使用 Apple 和 Google 地图在您的应用程序中显示地图,因此您无需添加其他依赖项.https://docs.expo.io/versions/v32.0.0/sdk/map-view/

However, Expo has access to maps in it. Check out MapView it uses Apple and Google maps to display maps in your app, so you don’t need to add another dependency. https://docs.expo.io/versions/v32.0.0/sdk/map-view/

使用起来非常简单.你不必安装任何你可以从 Expo 导入的东西,这里是一个示例

It’s very straight forward to use. You don’t have to install anything you can just import from Expo here is a sample

import React from 'react';
import { MapView } from 'expo';

export default class App extends React.Component {
  render() {
     return (
      <MapView
          style={{ flex: 1 }}
          initialRegion={{
          latitude: 37.78825,
          longitude: -122.4324,
          latitudeDelta: 0.0922,
          longitudeDelta: 0.0421,
          }}
      />
    );
  }
}

如果您想访问本机代码,您必须使用 react-native init YourAppName 创建您的应用程序,或者您可以弹出您的 Expo

If you want to have access to the native code you either have to create your app using react-native init YourAppName or you can eject your Expo

要弹出您的应用程序,请在终端中运行 expo eject.

To eject your app run expo eject in the terminal.

您可以在此处阅读更多相关信息:https://docs.expo.io/versions/latest/expokit/eject/

You can read more about it here : https://docs.expo.io/versions/latest/expokit/eject/

弹出有利也有弊.但是,如果您需要访问本机代码,则必须弹出.

There are pros and cons for ejecting. But if you need access to native code then you will have to eject.

这篇关于为什么 create-react-native-app 没有 ios 和 android 文件了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆