How to fix the "The file “.swiftlint.yml” couldn’t be opened because you don’t have permission to view it" issue
I started playing with Xcode 15, and I created a brand new project. Then, as usual, I added swiftlint
as build step:
But when I built the project I got following warning:
The file “.swiftlint.yml” couldn’t be opened because you don’t have permission to view it. – Falling back to default configuration
And the script returned an error because it couldn't find any files to lint:
Error: No lintable files found at paths: ''
At first I thought Xcode 15 was broken and I encountered a bug, but it turns it's a feature 😝
In Xcode 14, Apple aded a new flag ENABLE_USER_SCRIPT_SANDBOXING
that tells the build system whether to block scripts phases from accessing source files or intermediate build objects.
Back in Xcode 14 (by default) this flag was set to NO
, so everything was working fine. But in Xcode 15 this flag is now set to YES
, and the script cannot access files.
Fortunately the workaround to this issue is simple:
- Open project settings.
- Open your target.
- Select
Build Settings
. - Search for
ENABLE_USER_SCRIPT_SANDBOXING
. - Change the
User Script Sandboxing
toNO
.
Now we should be able to build the project without any issues.
Changing the value of
User Script Sandbox
flag is just a workaround and is not reccomended by Apple. If you disable the sandboxing, you do it at your own risk.