Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native just reinitialize iOS or Android Project

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?

like image 713
Martin Cup Avatar asked Aug 07 '26 10:08

Martin Cup


1 Answers

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:

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

like image 191
Martin Cup Avatar answered Aug 08 '26 22:08

Martin Cup



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!