Hello,
I'm using the 5.9.2 compiler and accompanying programs.
I tried to use plutil to look at some binary plists recently that came from an iOS 15.8 device, and the plutil utility appears buggy: It seemingly doesn't parse command-line arguments at all and always prints the usage info.
Looking at the executable's symbols I noticed that it was coded in Swift, so I assume it came with the compiler tarball.
If so, does anyone know if this issue has been fixed in 5.10? If so, I will just upgrade.
Thanks.
plutil is not part of the Swift toolchain. Apple is gradually porting all of macOS to Swift.
OK but I'm a Linux user, and the plutil that I have was written in Swift.
So, what part of the Swift project does it come from?
I'm guessing that the plutil on MacOS is based on the same source code but doesn't have this bug, because plutil is used a lot on MacOS, and a bug this basic wouldn't go unfixed very long on MacOS.
So why the discrepancy between runtime behaviors on Linux and MacOS?
It comes from the swift-corelibs-foundation
repo, which isn't built on macOS, so it may have diverged from the one on macOS. Looking at the commit log for that file, it was not changed in 5.10 or much recently in trunk either, so it has not been fixed recently.
That said, it is difficult to know what's going wrong without an example. Can you paste the output of a working command on macOS that is failing with the same input on linux?
Here you go.
$ head Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.reviews</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
$ plutil -p Info.plist
No files specified.
plutil: [command_option] [other_options] file...
The file '-' means stdin
Command options are (-lint is the default):
-help show this message and exit
-lint check the property list files for syntax errors
-convert fmt rewrite property list files in format
fmt is one of: xml1 binary1 json
-p print property list in a human-readable fashion
(not for machine parsing! this 'format' is not stable)
There are some additional optional arguments that apply to -convert
-s be silent on success
-o path specify alternate file path name for result;
the -o option is used with -convert, and is only
useful with one file argument (last file overwrites);
the path '-' means stdout
-e extension specify alternate extension for converted files
-r if writing JSON, output in human-readable form
-- specifies that all further arguments are file names
The same thing happens with binary plist files.
I found this bug when trying to look at binary plists that I fetched from my iPhone.
Looking at the source, it appears the command-line invocation it expects is $ plutil -p -- Info.plist
. That works for me.
OK, I just tried that and it works. Looking at the usage info though it doesn't say the -- is required. I don't recall that being a requirement on macOS either. Who is responsible for the plutil utility?
Looking at git blame
for that source file, it appears @Tony_Parker and @Philippe_Hausler initially added it to linux 9 years ago: maybe one of them can refresh it against the macOS version again, or assign that task to @jmschonfeld or one of the other Foundation engineers.
Indeed it looks like plutil
on macOS. doesn't require the --
, so it looks like we have a behavioral difference between the macOS one packaged with the OS and the Linux/Windows one packaged with the swift toolchain. That's something that'd likely be good to fix so that it's consistent. Feel free to open an issue against the swift-corelibs-foundation repo and one of us can take a look, or if you happen to spot the bug already we also welcome pull requests to that repo.