Created
August 21, 2023 19:55
-
-
Save MarcoEidinger/22feb1588c3d7be41c42853a77e52772 to your computer and use it in GitHub Desktop.
A shell script to find if any "required reason API" are used in Swift or Objective-C files within that folder or subfolders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api | |
searchTerms=( | |
# File timestamp APIs | |
"creationDate" | |
"modificationDate" | |
"fileModificationDate" | |
"contentModificationDateKey" | |
"creationDateKey" | |
"getattrlist" | |
"getattrlistbulk" | |
"fgetattrlist" | |
"stat" | |
"fstat" | |
"fstatat" | |
"lstat" | |
"getattrlistat" | |
# System boot time APIs | |
"systemUptime" | |
"mach_absolute_time" | |
# Disk space APIs | |
"volumeAvailableCapacityKey" | |
"volumeAvailableCapacityForImportantUsageKey" | |
"volumeAvailableCapacityForOpportunisticUsageKey" | |
"volumeTotalCapacityKey" | |
"systemFreeSize" | |
"systemSize" | |
"statfs" | |
"statvfs" | |
"fstatfs" | |
"fstatvfs" | |
"getattrlist" | |
"fgetattrlist" | |
"getattrlistat" | |
# Active keyboard APIs | |
"activeInputModes" | |
# User defaults APIs | |
"UserDefaults" | |
) | |
search_dir="$1" | |
if [ -z "$search_dir" ]; then | |
echo "Usage: $0 <search_dir>" | |
exit 1 | |
fi | |
for pattern in "${searchTerms[@]}"; do | |
find "$search_dir" -type f \( -name "*.swift" -o -name "*.m" \) -exec grep -H -Fw "$pattern" {} + | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please read https://blog.eidinger.info/how-to-check-if-you-use-a-required-reason-api