Skip to content

Instantly share code, notes, and snippets.

@ManWithBear
Created November 18, 2022 02:20
Show Gist options
  • Save ManWithBear/1e3ece277725567e1d3fbd382d1409a9 to your computer and use it in GitHub Desktop.
Save ManWithBear/1e3ece277725567e1d3fbd382d1409a9 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# For each framework in current folder list all imported frameworks.
# `find_imports_directories_to_skip.txt` contains list of directories to ignore (e.g. xcodeproj)
# `find_imports_imports_to_skip.txt` contains list of imported frameworks that should be removed from output (e.g. UIKit)
DIRECTORIES_TO_SKIP=$(cat find_imports_directories_to_skip.txt)
for FORFramework in $(ls -d -- */) # itterate over all directories in current folder
do
if [[ $DIRECTORIES_TO_SKIP =~ "${FORFramework}" ]]; then
continue
fi
echo "$FORFramework:"
grep -rh "^import " "$FORFramework" `# find all lines strating with "import " in directory $FORFramework` \
| sort \
| uniq `# remove all duplicates` \
| sed "s/^import //" `# remove "import " prefix` \
| grep -vf find_imports_imports_to_skip.txt `# remove frameworks that are ignored` \
| sed "s/^/ ./" `# add indentation and "." to framework name` \
| sed "s/$/,/" # add "," in the end
done
Derived/
FORFrameworks.xcodeproj/
AVKit
AudioToolbox
Foundation
MapKit
ObjectiveC
QuartzCore
SafariServices
SystemConfiguration
UIKit
WebKit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment