简体   繁体   中英

"Error: EMFILE: too many open files" using Xcode to archive React Native App

I know there are a lot of similar questions out there, but my issue seems to be unique, and the solutions suggested aren't solving it:

I'm trying to build an archive of a React Native App from Xcode and, since updating to macOS 11.3.1 and Xcode 12.5, I get "Error: EMFILE: too many open files" when Xcode is trying to run the node bundle command.

I've already installed and updated watchman via homebrew, and have also increased my system's maximum open files and open files per process to unreasonably high values.

Oddly enough, I can do a debug build from Xcode with no issues, and running the node bundle command that Xcode's archive fails on from the command line completes without any issues. I'm able to run and debug the App with no issues, it's just when Xcode is trying to bundle the js for an archive that it seems to fail.

It's almost like Xcode is not using watchman (while the terminal is) and/or it's process has a limit on the number of open files that is different from what I get in the terminal.

I had the same problem and here's how I fixed it.

I believe this error is happening due to the bundle for iOS is missing so it's trying to build the bundle when Xcode is building the app (it shouldnt fail but no idea why it does)

I fixed it by first adding this command to my package.json to build the iOS bundle manually.

"bundle:ios": "react-native bundle --entry-file='index.js' --bundle output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'",

I ran npm run bundle:ios first, and then I proceeded to add the bundle file in Xcode, under Build Phases => Copy Bundle Resources

在此处输入图像描述

I cleaned my project in Xcode and the build works after.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM