Errno::ENOENT fix for Flutter iOS

While developing our TestFairy Flutter Plugin, I noticed an unusual bug happening during iOS builds, described as Errno::ENOENT - No such file or directory @ rb_sysopen.

Apparently, the latest Flutter builds sometimes misconfigured its Pods project which may cause this error.

Below are the instructions for the fix.

The Culprit

When you build an iOS app with Flutter for the first time or on a cleaned build state, Flutter creates a new Xcode workspace set up with an automatically generated Podfile. A Podfile is a script that declares 3rd party iOS dependencies written in Swift or Objective-C. If you are using cocoapods version 1.8.0 or greater, it is likely that your builds will fail with a similar error to this.

Errno::ENOENT - No such file or directory @ rb_sysopen

The solution is temporarily reverting back to cocoapods 1.7.5 and recreating the Xcode project from scratch. This is a one time operation if you don’t clean your Xcode projects that often.


Create a backup of your project first. Then clean it with the following commands.

flutter clean

rm -rf ios/Podfile ios/Podfile.lock pubspec.lock ios/Pods ios/Runner.xcworkspace

Temporarily revert back to cocoapods 1.7.5.

gem uninstall cocoapods; gem install cocoapods -v 1.7.5

Try rebuilding the app, knowing that it will fail.

flutter build ios --simulator

Open up you Xcode project and configure your provisioning and signing profile. Make sure you target iOS 9.0 or greater.

Edit ios/Podfile by adding these to the beginning of the file.

# Beginning of file

# The rest of the file contents
# ...

Install iOS dependencies with pods.

pod repo update; cd ios; pod install; cd ..

Rebuild your project.

flutter build ios --simulator

Fixing it in CI

You can go back to the latest cocoapods once your builds start succeeding. If you ever need to clean the project, you must repeat these steps to fix the issue again. For fixing this in your CI script, we have a boilerplate bash drop-in for your convenience. Edit the folder names (example) with your setup and adapt it to your favorite CI platform.