Skip to content

paulmaxgithub/swift-scripts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

Unused

unused.rb Searches for unused swift functions, and variable at specified path

Usage

cd <path-to-the-project>
<path-to-unused.sh>/unused.rb 

Output

 Item< func loadWebViewTos [private] from:File.swift:23:0>
Total items to be checked 4276
Total unique items to be checked 1697
Starting searching globally it can take a while
 Item< func applicationHasUnitTestTargetInjected [] from:AnotherFile.swift:31:0>
 Item< func getSelectedIds [] from: AnotherFile.swift:82:0>

Xcode integration

To integrate this into Xcode, simply add a "New Run Script Phase" and use the following code:

file="unused.rb"
if [ -f "$file" ]
then
echo "$file found."
ruby unused.rb xcode
else
echo "unused.rb doesn't exist"
fi

Xcode ~/project/Build Phases:

Screenshot 2024-02-08 at 12 05 28

Code Example:

Known issues:

  • Fully text search (no fancy stuff)
  • A lot of false-positives (protocols, functions, objc interoop, System delegate methods)
  • A lot of false-negatives (text search, yep)

About

Some useful scripts for swift developers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%