Last active
December 17, 2015 20:12
-
-
Save kristopherjohnson/ea3d40232fb31daa61c6 to your computer and use it in GitHub Desktop.
Swift script to retrieve the info.plist dictionary for an executable
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
| #!/usr/bin/swift | |
| // Gets the info.plist data for executables specified on command line | |
| import Foundation | |
| if Process.argc < 2 { | |
| print("usage: get-info-dictionary EXECUTABLE...") | |
| } | |
| else { | |
| for i in 1..<Int(Process.argc) { | |
| let arg = Process.arguments[i] | |
| let url = NSURL(fileURLWithPath: arg) | |
| let cfdictref = CFBundleCopyInfoDictionaryForURL(url) | |
| if cfdictref != nil { | |
| let infoDictionary = cfdictref as NSDictionary | |
| print("\(arg):\n\(infoDictionary)") | |
| } | |
| else { | |
| print("\(arg): no info dictionary") | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: