Skip to content

Instantly share code, notes, and snippets.

@kastiglione
Created December 27, 2017 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastiglione/6e13255bb787742a56be81ece123f2e0 to your computer and use it in GitHub Desktop.
Save kastiglione/6e13255bb787742a56be81ece123f2e0 to your computer and use it in GitHub Desktop.
Get the module that matches a given header
# Examples:
# hdrtomod objc/runtime.h
# hdrtomod mach-o/dyld.h
# hdrtomod Foundation/Foundation.h
hdrtomod() {
readonly header=$1
echo "#import <$header>" \
| clang -fmodules -fsyntax-only -x objective-c -Xclang -ast-dump - \
| grep ImportDecl \
| egrep -o 'implicit \S+'
}
@kastiglione
Copy link
Author

Note you may want to change clang to xcrun -sdk ... clang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment