React Native只需重新初始化iOS或Android Project

时间:2022-12-15 15:31:37

I want to start again building my React Native app with iOS because I messed up the XCode Project and can't make it build. How can I just reinitialize the iOS project or in other cases the Android Project in my existing React Native app?

我想重新开始使用iOS构建我的React Native应用程序,因为我搞砸了XCode项目并且无法构建它。如何在我现有的React Native应用程序中重新初始化iOS项目或其他情况下的Android项目?

2 个解决方案

#1


2  

It seems that this functionality was once implemented in react-native with the command react-native ios or react-native android, which are no longer implemented. But I found a solution for Android here which is also working for iOS:

似乎这个功能曾经在反应原生中实现,命令是react-native ios或react-native android,它们已经不再实现了。但是我在这里找到了Android的解决方案,它也适用于iOS:

const fs = require('fs');
const generate = require('react-native/local-cli/generate/generate.js');

generate([
  '--platform', 'ios', //or android
  '--project-path', process.cwd(),
  '--project-name', JSON.parse(
    fs.readFileSync('package.json', 'utf8')
  ).name,
]);

Credit

信用

Just put this code in a script and run it with node script-name.js

只需将此代码放在脚本中,然后使用node script-name.js运行它

#2


0  

There isn't any built in way to "reset" the native projects. When i've had to do this in the past i've just created a new project with the same name and replaced the ios and android folders in the project directory.

没有任何内置的方法来“重置”本机项目。当我不得不这样做时,我刚刚创建了一个具有相同名称的新项目,并替换了项目目录中的ios和android文件夹。

#1


2  

It seems that this functionality was once implemented in react-native with the command react-native ios or react-native android, which are no longer implemented. But I found a solution for Android here which is also working for iOS:

似乎这个功能曾经在反应原生中实现,命令是react-native ios或react-native android,它们已经不再实现了。但是我在这里找到了Android的解决方案,它也适用于iOS:

const fs = require('fs');
const generate = require('react-native/local-cli/generate/generate.js');

generate([
  '--platform', 'ios', //or android
  '--project-path', process.cwd(),
  '--project-name', JSON.parse(
    fs.readFileSync('package.json', 'utf8')
  ).name,
]);

Credit

信用

Just put this code in a script and run it with node script-name.js

只需将此代码放在脚本中,然后使用node script-name.js运行它

#2


0  

There isn't any built in way to "reset" the native projects. When i've had to do this in the past i've just created a new project with the same name and replaced the ios and android folders in the project directory.

没有任何内置的方法来“重置”本机项目。当我不得不这样做时,我刚刚创建了一个具有相同名称的新项目,并替换了项目目录中的ios和android文件夹。