xcode 如何将 expo 项目弹出到本机代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48843497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to eject expo project to native code
提问by Hoai Truong
I eject project from expo with command npm run eject
. It generates 2 folders ios
and android
. I tried to run the project by xcode
but it still display this error. Maybe I'm not clear how to run project after eject, can you help me run it.
I run some statements to install pod
, but cannot work https://github.com/CocoaPods/CocoaPods/issues/2303
我使用命令从博览会中弹出项目npm run eject
。它生成 2 个文件夹ios
和android
. 我试图运行该项目,xcode
但它仍然显示此错误。可能我不清楚eject后如何运行项目,你能帮我运行一下吗?我运行了一些语句来安装pod
,但无法运行https://github.com/CocoaPods/CocoaPods/issues/2303
采纳答案by Michael Cheng
So with ejecting, you should have been presented with two options:
因此,在弹出时,您应该会看到两个选项:
? How would you like to eject from create-react-native-app? (Use arrow keys)
? React Native: I'd like a regular React Native project.
ExpoKit: I'll create or log in with an Expo account to use React Native and the Expo SDK.
Cancel: I'll continue with my current project structure.
If you chose the first (React Native
), then there should have been no issues with opening up your Xcode project and running the app (there would also be no pods to install). Since your error and comment indicates otherwise, I can presume that you chose option 2: Expokit
.
如果您选择第一个 ( React Native
),那么打开 Xcode 项目并运行应用程序应该没有问题(也不会安装 pod)。由于您的错误和评论另有说明,我可以假设您选择了选项 2: Expokit
。
For that, you should have been prompted with something about making an Expo account or using an existing one:
为此,您应该会收到有关创建 Expo 帐户或使用现有帐户的提示:
? How would you like to eject from create-react-native-app?
React Native: I'd like a regular React Native project.
? ExpoKit: I'll create or log in with an Expo account to use React Native and the Expo SDK.
Cancel: I'll continue with my current project structure.
An Expo account is required to proceed.
? It appears you're already logged in to Expo as ...
After that, you'll need to follow the steps in Developing With ExpoKit. Specifically to get iOS running, you need follow all of the steps in this sectionafter running npm run eject
.
之后,您需要按照使用 ExpoKit进行开发中的步骤进行操作。具体获得的iOS运行,则必须遵循所有的步骤,在本节运行后npm run eject
。
If you've done all of that, then it should work fine when running in conjunction with Expo XDEor exp
. I've just tested both right now and it works without error. Double check your steps to make sure you didn't miss something. Otherwise, please edit your question with more details on exactly what commands you ran, what other dependencies you have, etc. as I'm unable to reproduce the error you have.
如果您已经完成了所有这些,那么在与Expo XDE或exp
. 我现在刚刚测试了两者,它可以正常工作。仔细检查您的步骤以确保您没有遗漏任何内容。否则,请编辑您的问题,详细说明您运行的命令、您拥有的其他依赖项等,因为我无法重现您遇到的错误。
回答by Pratik Khadka
If you want to download new project without expo then try run:
如果您想在没有 expo 的情况下下载新项目,请尝试运行:
react-native init ProjectNameHere
or , If you want to convert your own project without expo then try :
或者,如果您想在没有 expo 的情况下转换您自己的项目,请尝试:
1. rm -rf node_modules
2. remove expo dependencies from package.json
3. npm install
4. react-native upgrade
(Note:This following step will create new ios and android folder and you have to redo the dependencies. I was struggling with the same issue so I posted my solution)
(注意:以下步骤将创建新的 ios 和 android 文件夹,您必须重做依赖项。我遇到了同样的问题,所以我发布了我的解决方案)