xcrun simctl json parse error

I am trying to test an app locally that has managed configurations, using the xcrun simctl command line tools.

I am passing my config as a json array to the com.apple.configuration.managed but continually receive the error 'Could not parse: Try single-quoting it'.

I have validated the json is correct. See redacted command below:

xcrun simctl spawn booted defaults write com.app.bunleID  com.apple.configuration.managed '{"apiKey":"xxxxxxxxx", "clientId":"xxxxxxxx", "clientSecret":"xxxxxxxx", "domainName":"xxxxxxx", "isPlaceOs":false}'

Accepted Reply

This error is coming out of the defaults command itself. To confirm that, eliminate the simulator from the equation by running defaults directly:

% defaults write com.app.bunleID  com.apple.configuration.managed '{"apiKey":"xxxxxxxxx", "clientId":"xxxxxxxx", "clientSecret":"xxxxxxxx", "domainName":"xxxxxxx", "isPlaceOs":false}'
… Could not parse: {…}.  Try single-quoting it.

The issue is that defaults doesn’t take JSON but rather the old school NeXT property list syntax. For example:

% defaults write com.app.bunleID  com.apple.configuration.managed '{"apiKey"="xxxxxxxxx"; "clientId"="xxxxxxxx"; "clientSecret"="xxxxxxxx"; "domainName"="xxxxxxx"; "isPlaceOs"=0;}' 
% # no error

Note that this syntax doesn’t support Booleans, so I’ve used 0 instead. Code that reads property lists is generally pretty tolerant of that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Perfect, this works! Great information in this reply, most appreciated.

Add a Comment

Replies

This error is coming out of the defaults command itself. To confirm that, eliminate the simulator from the equation by running defaults directly:

% defaults write com.app.bunleID  com.apple.configuration.managed '{"apiKey":"xxxxxxxxx", "clientId":"xxxxxxxx", "clientSecret":"xxxxxxxx", "domainName":"xxxxxxx", "isPlaceOs":false}'
… Could not parse: {…}.  Try single-quoting it.

The issue is that defaults doesn’t take JSON but rather the old school NeXT property list syntax. For example:

% defaults write com.app.bunleID  com.apple.configuration.managed '{"apiKey"="xxxxxxxxx"; "clientId"="xxxxxxxx"; "clientSecret"="xxxxxxxx"; "domainName"="xxxxxxx"; "isPlaceOs"=0;}' 
% # no error

Note that this syntax doesn’t support Booleans, so I’ve used 0 instead. Code that reads property lists is generally pretty tolerant of that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Perfect, this works! Great information in this reply, most appreciated.

Add a Comment