最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swift - SwiftLint (SPM) Auto-correction for Trailing Whitespace Not Working Due to Sandbox Restrictions - Stack Overflow

programmeradmin2浏览0评论

I am using SwiftLint via Swift Package Manager (SPM) in my Xcode project and would like to enable automatic correction for removing whitespace in empty lines.

I have added the following configuration to my .swiftlint.yml file:

correctable_rules:
  - trailing_whitespace

My run script:

export PATH="$PATH:/opt/homebrew/bin"

if which swiftlint > /dev/null; then
  swiftlint --fix && swiftlint
else
  echo "warning: SwiftLint not installed, download from ;
fi

I have installed SwiftLint via Homebrew also to be able run autocorrection.

However, when I build the project or try to run swiftlint --fix, I get the following errors related to Sandbox restrictions:

error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/.swiftlint.yml (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUpUITests (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUpTests (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUp.xcodeproj (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUp (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/fastlane (in target 'FollowMeUp' from project 'FollowMeUp')
error: Sandbox: swiftlint(25883) deny(1) file-read-data /Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/.git (in target 'FollowMeUp' from project 'FollowMeUp')
warning: The file “.swiftlint.yml” couldn’t be opened because you don’t have permission to view it. – Falling back to default configuration
Correcting Swift files in current working directory
Error: No lintable files found at paths: ''

Running swiftlint --fix via terminal seems autocorrect files:

Correcting Swift files in current working directory
Correcting 'FollowMeUpUITests.swift' (1/5)
Correcting 'FollowMeUpUITestsLaunchTests.swift' (2/5)
Correcting 'Item.swift' (4/5)
Correcting 'FollowMeUpTests.swift' (3/5)
Correcting 'FollowMeUpApp.swift' (5/5)
/Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUp/FollowMeUpApp.swift: Corrected Trailing Whitespace
… (other corrected files printed here)
/Users/oleksandrmatrosov/Documents/Projects/FollowMeUp/FollowMeUp/FollowMeUpApp.swift: Corrected Trailing Whitespace
Done correcting 5 files!

What I've Tried: Checking file permissions

chmod 644 .swiftlint.yml

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论