How can I regenerate ios folder in React Native project?

后端 未结 13 671
忘掉有多难
忘掉有多难 2020-11-29 20:13

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

相关标签:
13条回答
  • 2020-11-29 20:54

    This is too late, but for anyone who is still having same issue and have a detached react native app, what i did for me I just run exp detach over my detached app and it created ios folder!

    0 讨论(0)
  • 2020-11-29 20:58

    Remove the ios folder first

     react-native eject 
     cd ios/ 
     pod init 
     pod install 
     cd .. 
     react-native link 
     cd ios 
     open *.xcworkspace/
    
    0 讨论(0)
  • 2020-11-29 20:59

    Note as of react-native 0.60.x you can use the following to regenerate ios/android directories:

    react-native upgrade --legacy true
    

    Credit here: https://github.com/facebook/react-native/issues/25526

    0 讨论(0)
  • 2020-11-29 20:59

    i faced the same issue in react native .63 version. I tried above all methods but didn't worked. So, I tried like this deleted android/ios folders in my old project tree and initiated a new project with similar name in another folder, later copied android/ios folders from new project to old project and reset cache using react-native start --reset-cache and run react-native run-android and my attempt was successfull.

    0 讨论(0)
  • 2020-11-29 21:02

    react-native eject

    error Unrecognized command "eject". info Run "react-native --help" to see a list of all available commands.

    react-native upgrade --legacy true

    error: unknown option `--legacy'

    You can init a new project that's named the same in another folder and copy ios dir over:

    inside YourProjectName directory

    npx react-native init YourProjectName
    mv YourProjectName/ios ios
    rm -rf YourProjectName
    

    Make sure you have clean git history before doing so, in case you need to revert

    0 讨论(0)
  • 2020-11-29 21:03

    Simply remove/delete android and ios (keep backup android and ios folder) and run following command:

      react-native eject
    
    Supported version : 
        react-native <= 0.59.10
        react-native-cli <= 1.3.0 
    
    
    
       react-native upgrade --legacy true
    
    Supported version : 
            react-native >= 0.60.0
            react-native-cli >= 2.1.0 
    

    Ref : link

    0 讨论(0)
提交回复
热议问题