如何在 React Native 项目中重新生成 ios 文件夹? [英] How can I regenerate ios folder in React Native project?

查看:101
本文介绍了如何在 React Native 项目中重新生成 ios 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以不久前我删除了我的本机应用程序中的/ios 目录(我们称之为 X).我一直在使用 android 模拟器进行开发和测试,但现在我想确保它可以在带有 xcode 模拟器等的 ios 上运行.

So a while ago I deleted the /ios directory in my react native app (let's call it X). I've been developing and testing using the android emulator but now I'd like to make sure it works on ios with xcode simulator etc.

所以我现在的想法是用 ios 文件夹创建一个新的 react native 裸项目(我们称之为 Y),然后按照 这些步骤重命名 Y 使其具有 X 的名称,然后将/ios 目录从 Y 移动到 X 并尝试 run-ios.

So my current idea is to create a new react native bare project (let's call it Y) with ios folder, then follow these steps to rename Y so that it has the name of X and then moving the /ios directory from Y into X and trying to run-ios.

我会在这里更新进展情况,但我想知道是否有更好的方法,以前没有人遇到过这种情况吗?

I'll update here how that goes, but I wondered if there is a better way and has nobody been in this situation before?

我在谷歌上搜索了很多东西重新生成 ios 文件夹"删除 ios 文件夹"将 ios 文件夹添加到现有......",但没有任何帮助.也许我的 googlefu 不够好,但如果有人有任何建议,非常感谢.

I've googled lots of things 'regenerate ios folder' 'deleted ios folder' 'add ios folder to existing..' and nothing helpful. Maybe my googlefu isn't good enough but if anyone has any suggestions, much appreciated.

第 2 步将确保它由于依赖项和其他东西而编译,但现在我的目标是将/ios 文件夹恢复到项目中并使 React Native 意识到它的存在(它具有所有必要的配置).

Step 2 will be making sure it compiles because of dependencies and stuff but for now my goal is to just get the /ios folder back in the project and for React Native to be aware of it's existence (it has all the necessary config).

谢谢

推荐答案

您需要遵循的过程与重命名 React Native 应用程序非常相似.基本上你只需要在你的项目根目录中运行 react-native upgrade .有关更多信息,您可以在此处查看另一个问题.下面的说明解释了如何基于具有新名称的复制项目创建另一个 React Native 项目.

The process you need to follow is so similar to renaming a react native app. Basically you just need to run react-native upgrade in your root project directory. For further info you can check another question here. The instructions below explains how to create another react native project based on a copied one with a new name.

  • 首先复制您要更改名称的应用程序所在的目录.然后转到您新克隆的目录.
  • 更改 index.ios/android.js 文件中的名称,该文件作为参数提供给 AppRegistry.
  • package.json
  • 上相应地更改名称和版本
  • 删除旧应用中剩余的 /ios/android 文件夹.
  • 运行 $react-native upgrade 再次生成 /ios/android 文件夹.
  • 为任何本机依赖项运行 $react-native link.
  • 最后运行 $react-native run-ios 或任何你想要的.
  • First copy the directory which your to-be-name-changed application exists. And go to your newly cloned directory.
  • Change the name at index.ios/android.js file which is given as a parameter to AppRegistry.
  • Change the name and version accordingly on package.json
  • Delete /ios and /android folders which are remaining from your older app.
  • Run $react-native upgrade to generate /ios and /android folders again.
  • Run $react-native link for any native dependency.
  • Finally run $react-native run-ios or anything you want.

这篇关于如何在 React Native 项目中重新生成 ios 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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