Consider this very trivial code which accesses the operatingSystemVersion
property of NSProcessInfo
as documented at https://developer.apple.com/documentation/foundation/nsprocessinfo/1410906-operatingsystemversion
osversion.c
:
#include <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
fprintf(stderr, "OS version: %ld.%ld.%ld\n", osVersion.majorVersion, osVersion.minorVersion, osVersion.patchVersion);
}
Compile it:
/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks -x objective-c -o a.out -framework Foundation osversion.c
Then run it:
./a.out
It works fine and prints the OS version:
OS version: 14.6.1
Run it again and pass it some arbitrary program arguments:
./a.out foo bar
Still continues to work fine and prints the output:
OS version: 14.6.1
Now run it again and this time pass it two program arguments, the first one being -
and the second one being something of the form {x=y}
./a.out - {x=y}
This time notice how it prints a couple of warning logs from CFPropertyListCreateFromXMLData
before printing the output:
2024-10-11 11:18:03.584 a.out[61327:32412190] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2024-10-11 11:18:03.585 a.out[61327:32412190] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
OS version: 14.6.1
As far as I can see there's nothing wrong in the code nor the user inputs to the program. Is this some issue in the internal implementation of NSProcessInfo
? Should this be reported as an issue through feedback assistant (which category)?
Although this example was run on 14.6.1 of macos, the issue is reproducible on older versions too.
Should this be reported as an issue through feedback assistant … ?
No.
Well, you can report it as log noise if you like, but it’s definitely not a sign of an actual problem.
Foundation was created as part of Apple’s (well, NeXT’s) app development story. For this reason it contains a component, UserDefaults
, with some helpful, but non-obvious, behaviour: You can override specific user defaults by passing them on the command line. For example, consider this program:
import Foundation
func main() {
print(UserDefaults.standard.string(forKey: "QTest") ?? "-")
}
main()
If you run it with no arguments it gets nil
back for this default:
% ./Test766100
-
But you can supply a default as an argument:
% ./Test766100 -QTest 'Hello Cruel World!'
Hello Cruel World!
This mechanism supports all property list types. That’s super useful in some cases. For an example of that, check out this post.
This log message is being triggered by the property list parser seeing what it thinks is an old school property list and failing to parse it. That’s not a big deal. It just means that the result value isn’t going to get set it UserDefaults
.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"