# binary plist files

**URL:** <https://forum.xojo.com/t/binary-plist-files/35857>\
**Category:** macOS\
**Created:** [February 1, 2017, 7:39pm UTC](https://forum.xojo.com/t/binary-plist-files/35857 "2017-02-01T19:39:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChristopheDV](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@ChristopheDV](https://forum.xojo.com/u/ChristopheDV)\
**Post date:** [February 1, 2017, 7:39pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/1 "2017-02-01T19:39:49Z")

</div>

Most plist files found in the users/library/preferences/ are files that are binary.  
When read with a plain text reader it always start with bplist00

Is there a way to ‘decode’ your own plist file too so it created a valid binary plist file?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 1, 2017, 7:42pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/2 "2017-02-01T19:42:07Z")

</div>

You can access plist data through MBS I’m pretty sure.

---

<div class="post-metadata">

**Author:** ![Harrie\_Westphal](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/7feea3/32.png) [@Harrie\_Westphal](https://forum.xojo.com/u/Harrie_Westphal)\
**Post date:** [February 1, 2017, 7:53pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/3 "2017-02-01T19:53:19Z")

</div>

You can use the plutil command in a shell to convert XML formatted plists to binary format or binary format to XML format. The following article shows the format of the plutil commands to do it.

[http://osxdaily.com/2016/03/10/convert-plist-file-xml-binary-mac-os-x-plutil/](http://osxdaily.com/2016/03/10/convert-plist-file-xml-binary-mac-os-x-plutil/)

Edit: Fixed the URL.

---

<div class="post-metadata">

**Author:** ![scott\_boss](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@scott\_boss](https://forum.xojo.com/u/scott_boss)\
**Post date:** [February 1, 2017, 7:54pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/4 "2017-02-01T19:54:55Z")

</div>

check out [https://github.com/macoslib/macoslib](https://github.com/macoslib/macoslib) I think there is some code in there to read/write plist files.

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [February 1, 2017, 7:55pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/5 "2017-02-01T19:55:23Z")

</div>

and I believe Xcode can translate them to XML for you as well

---

<div class="post-metadata">

**Author:** ![Harrie\_Westphal](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/7feea3/32.png) [@Harrie\_Westphal](https://forum.xojo.com/u/Harrie_Westphal)\
**Post date:** [February 1, 2017, 7:56pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/6 "2017-02-01T19:56:27Z")

</div>

Not sure why, but when I click on the above some idiotic page appears. If I copy the text and paste it in to the browser URL field it works fine.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 1, 2017, 7:57pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/7 "2017-02-01T19:57:49Z")

</div>

When you post a link, if you’re going to post the full url you don’t need to click the Link button 🙂  
If you click the Link button make sure that the `url=` part is the URL and the stuff between the tags becomes the link text.

---

<div class="post-metadata">

**Author:** ![ChristopheDV](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@ChristopheDV](https://forum.xojo.com/u/ChristopheDV)\
**Post date:** [February 1, 2017, 8:11pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/8 "2017-02-01T20:11:33Z")

</div>

Thanks for the replies. Will take a look at the MBS plugins (didn’t found it at first glance though).

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [February 1, 2017, 8:15pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/9 "2017-02-01T20:15:11Z")

</div>

e.g. NewCFObjectMBSFromXML to parse  
[http://www.monkeybreadsoftware.net/corefoundation-corefoundation-new-method.shtml#15](http://www.monkeybreadsoftware.net/corefoundation-corefoundation-new-method.shtml#15)

and CFObjectMBS.XML to get back XML.

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [February 1, 2017, 11:04pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/10 "2017-02-01T23:04:33Z")

</div>

NSDictionary has a function for reading and writing plist files. As does NSArray. No conversion required.

Although to read data in preference files, you should be using NSDefaults and not directly interacting with the preference files. This has been an Apple guideline since Mac OS X 10.0, Mac OS X 10.9 was the first OS version that I’m aware of which caches the preferences and manually editing the files (even deleting them) can result in weird things happening to the application.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [February 1, 2017, 11:08pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/11 "2017-02-01T23:08:12Z")

</div>

and there is code in macoslib to do that  
I’m sure its in AppleLib etc as well

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [February 2, 2017, 12:35am UTC](https://forum.xojo.com/t/binary-plist-files/35857/12 "2017-02-02T00:35:40Z")

</div>

[quote=313276:@Norman Palardy]and there is code in macoslib to do that  
I’m sure its in AppleLib etc as well[/quote]  
Am sure, I don’t know which implementation has what, the function you want is.

For writing, the function is:

`- (BOOL)writeToURL:(NSURL *)url 
        atomically:(BOOL)atomically;`

For reading a plist file you want:

```auto
+ (NSDictionary<KeyType,ObjectType> *)dictionaryWithContentsOfURL:(NSURL *)url;
```

---

<div class="post-metadata">

**Author:** ![ChristopheDV](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@ChristopheDV](https://forum.xojo.com/u/ChristopheDV)\
**Post date:** [February 4, 2017, 9:59am UTC](https://forum.xojo.com/t/binary-plist-files/35857/13 "2017-02-04T09:59:21Z")

</div>

In the end what I needed was CFPreferences.  
This is the only API that makes it possible to create valid encoded plist files and use a plist filename not related to the bundle ID.

MBS plugins has this class. macosLib does not have it atm.

BTW NSDictionary does write plist files, but they are ASCII files (not binary).

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [February 4, 2017, 4:45pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/14 "2017-02-04T16:45:32Z")

</div>

CFPreferences is definitely in [macOSLib](https://github.com/macoslib/macoslib)

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [February 5, 2017, 6:49am UTC](https://forum.xojo.com/t/binary-plist-files/35857/15 "2017-02-05T06:49:50Z")

</div>

> [@313706:@Christoph De Vocht](#):
>
> BTW NSDictionary does write plist files, but they are ASCII files (not binary).

I see, using the convenience method then yeah, it can read plist files in any format but you are at Apple’s whim on what format it creates.

For more control you need to look at either “NSPropertyListSerialization” or “NSKeyedArchiver”, I’ve used the second and it’s pretty easy.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [February 5, 2017, 10:56am UTC](https://forum.xojo.com/t/binary-plist-files/35857/16 "2017-02-05T10:56:38Z")

</div>

For CFDictionaryMBS class, I also have read/write methods:

[http://www.monkeybreadsoftware.net/class-cfdictionarymbs.shtml](http://www.monkeybreadsoftware.net/class-cfdictionarymbs.shtml)

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:38pm UTC](https://forum.xojo.com/t/binary-plist-files/35857/17 "2020-10-29T18:38:17Z")

</div>


