Mac AddressBook replacement?

It looks like AddressBook was recently deprecated, with no replacement. I’ve been searching for several days and haven’t found a replacement, other than MBS. I would purchase an MBS license if I had use for literally anything beyond one tiny AddressBook screen in my app, but unfortunately I cannot afford $120 for this one simple feature. Is there really no other way to access the Mac’s system contacts? Has anyone come up with a class that can do it in Xojo without plugins? I really appreciate anyone’s help.

Next week you may be lucky to get a license for a discounted price for Black Friday.

2 Likes

The API that AddressBook uses has been deprecated by Apple. There is a newer framework, but this requires Xojo to move resources away from their current tasks to support this new API.

Just because something is deprecated does not mean you can’t use it. I would continue to use it until Xojo supports the new framework from Apple. I am sure they will.

The other thing you could do is get good with declares! :slight_smile:

Correct, deprecated doesn’t mean deleted. But unfortunately it is now completely deleted. My app no longer compiles with Xojo 2020, so it simply cannot be used. Very unfortunate.

Really?

I have never used AddressBook and just put a couple of AddressBook commands in an app in 2020 and it compiled fine. I’m not getting any usable data out of it, but like I said I’ve never used it.

And if it doesn’t work, you can always run an earlier version of Xojo.

It looks like Xojo removed System.AddressBook which looks to be essential to getting the address book data. Maybe the pulled it b/c Apple removed the API. Apple is known to abruptly pull APIs.

You have to change a little the way you go. Before you wrote :

    Dim CeBook as AddressBook
    Dim CesContacts(-1) as AddressBookContact
    CeBook = System.AddressBook
    CesContacts = CeBook.Contacts

Now you have to write :

Dim CeBook as New AddressBook
Dim CesContacts(-1) as AddressBookContact
CesContacts = CeBook.Contacts

But I would be happy if Xojo team clarify the situation. 2 of my softwares use AddressBook but I don’t have any donations for them and I can’t spend more money with MBS for that (even if I’m sure MBS works well).
Xojo should write “Deprecated with replacement” as it is already and if not “Deprecated without replacement to come” or “Deprecated with replacement to come”

2 Likes

Thank you so much, your solution worked perfectly. Much appreciated!

We do have Contacts classes and they use the newer APIs for macOS and iOS.
See CNContactStoreMBS and CNContactMBS classes.

It seems that AdressBook doesn’t work anymore since 2022r1. The same project run with Xojo 2022r1 does not read any contacts in AdressBook, it worked in previous version :confused:

Yes I know, but it worked in previous version of Xojo on the same Mac OS system, then why doesn’t it work anymore?
Deprecated means that won’t be updated, but it supposed to work as before.

The old addressbook was simple. The new one was made by totally crazy people and is seriously complex. You need to use the MBS plugin if you want to use the addressbook.

1 Like

Thomas,
add an Info.plist to your project and Xojo 2022r1 works all right.
(Or enter the addressBook entitlement in Sam’s AppWrapper).
Edited: remove all spaces after all “<”
< ?xml version=“1.0” encoding=“UTF-8”?>
< !DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
< plist version=“1.0”>
< dict>
< key>NSContactsUsageDescription
< string>Access to Contacts is needed
< /dict>
< /plist>

2 Likes

It is deprecated until it is removed.

I added some time ago what you mention Carlo. Here is my Info.Plist :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>fr</string>
	<key>CFBundleExecutable</key>
	<string>MemoDate</string>
	<key>CFBundleIconFile</key>
	<string>App</string>
	<key>CFBundleIdentifier</key>
	<string>fr.Toroco.MemoDate</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>MemoDate</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.5.5</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleSupportedPlatforms</key>
	<array>
		<string>MacOSX</string>
	</array>
	<key>CFBundleVersion</key>
	<string>1.5.5.3.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.10.0</string>
	<key>NSAppleEventsUsageDescription</key>
	<string>Modify folder window view, Add login item, Make alias, Select item.</string>
	<key>NSContactsUsageDescription</key>
	<string>Read Contacts in your AddressBook.</string>
	<key>NSHighResolutionCapable</key>
	<true/>
	<key>NSHumanReadableCopyright</key>
	<string>©2007-2022, Th. Robisson</string>
</dict>
</plist>

Edit :
I don’t understand, I just built again my application to copy here the Info.Plist and I launched it again just to see and this time it works ??? :thinking: .
I don’t understand.

I guess your earlier post referred to launching the app in the debugger; in such case, you’d have the info.plist file dragged into the project.
But this step is not necessary if one uses AppWrapper and then launches the app.

Anyway, a few months ago MAS reviewer rejected my app because the reason I had in the plist for Contacts was not OK (i.e. it was like the one you have in your plist); then he suggested to enter something like this:
app will not collect and divulge users’s data.

It is called TCC by Apple, limiting what Applications can and cannot do. If you look in the Capabilities pane of App Wrapper, you’ll see there’s a lot of fields for entering in “Usage strings”. If you see functionality that your application needs, you need to enter in a message for that functionality.

well it seems the addressbook class is not working anymore in xojo 2023r4…
even with the NSContactsUsageDescription key in a plist file
the addressbook constructor returns an empty handle, and empty groups or contacts arrays…

edit: I dont sell to mac appstore, just want to get the local contacts and groups to print enveloppes …

@Thomas_ROBISSON : does your app still compile and work ? thanks.

here is the code

Dim book As New AddressBook
Dim groups() As AddressBookGroup
Dim contacts() As AddressBookContact
groups = book.Groups
contacts = book.Contacts

For Each g As AddressBookGroup In groups
  CLBGroups.AddRow g.Name
Next

and the plist file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSAppleEventsUsageDescription</key>
    <string>Modify folder window view, Add login item, Make alias, Select item.</string>
    <key>NSContactsUsageDescription</key>
    <string>Read Contacts in your AddressBook.</string>
</dict>
</plist>

I don’t see my compiled app in the “contacts” section of “confidentiality and security” system preference, and cannot add it manually … and anyway how do you proceed if you want to debug your app ?