nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.63k stars 623 forks source link

Really strange permission problem #1663

Closed everlof closed 3 months ago

everlof commented 3 months ago

I get this with the installation below:

The file “.swiftformat” couldn’t be opened because you don’t have permission to view it.

I have no reason what the issue might be - perhaps not even related to swiftformat? Because swiftformat runs fine in other projects. But this project is pretty new and really simple setup..

Xcode: Version 15.3 (15E204a) macOS: 14.4 (23E214)

Installation in Xcode project:

unset SDKROOT

if [[ "$(uname -m)" == arm64 ]]; then
    export PATH="/opt/homebrew/bin:$PATH"
else
    export PATH="/usr/local/bin:$PATH"
fi

if ! which mint > /dev/null; then
    echo "error: \`mint\` is not installed - install it using \`brew install mint\`"
    exit 1
fi

mint run nicklockwood/SwiftFormat@0.53.5 . || exit 1

My .swiftformat:

--exclude DerivedData

I've tried changing permissions of the .swiftformat file as well, but no success:

$ ll -la .swiftformat 
-rw-r--r--  1 david  staff  22 Apr  1 09:32 .swiftformat

$ chmod 777 .swiftformat 

$ ll -la .swiftformat 
-rwxrwxrwx  1 david  staff  22 Apr  1 09:32 .swiftformat

If I remove the .swiftformat file and just do:

mint run nicklockwood/SwiftFormat@0.53.5 URLDrop || exit 1

I get:

Screenshot 2024-04-01 at 09 48 55

Is it something related to Xcode sandboxing the run-phase?

everlof commented 3 months ago

Solved by changing: ENABLE_USER_SCRIPT_SANDBOXING = NO to YES