AddressBook Mojave

I have two applications which read AddressBook, they worked fine under El Capitan. I’m now under Mojave and I have to rebuild one of them.
They were in System Preferences : Security & Privacy : Privacy : Contacts .
I changed the Bundle Identifier, I don’t know if it the problem or not. But now, my App is not in System Preferences : Security & Privacy : Privacy : Contacts . And when I launch it and go to the menu which is suppose to read AddressBook, I have no AlertBox saying “App XXX try to access AddressBook. Allow ?”. My App read anything.
I tried to drag&drop my App in in System Preferences : Security & Privacy : Privacy : Contacts but I can’t.

CeBook = System.AddressBook CesGroupes = CeBook.Groups NbContacts = Ubound(CesGroupes) MsgBox "NbContacts = " + str(NbContacts)
NbContacts is -1 but I have Groups

I didn’t have any problem under El Capitan and I rebuild my application many times.

You have the usage strings in your info.plist?

And if you do code signing, you have the entitlement file included?

Thank you for your answer, but I’m not sure to understand the question.
Here is my info.plist :

[code]<?xml version="1.0" encoding="UTF-8"?>

CFBundleExecutable ToroNess CFBundleName ToroNess CFBundleIdentifier fr.Toroco.ToroNess CFBundleInfoDictionaryVersion 6.0 CFBundleVersion 1.0.3.0.0 CFBundleDevelopmentRegion en CFBundlePackageType APPL CFBundleSignature ???? NSHumanReadableCopyright ©2017-2019, Th. Robisson CFBundleShortVersionString 1.0.3 CFBundleIconFile App LSMinimumSystemVersion 10.10.0 NSHighResolutionCapable CFBundleSupportedPlatformsMacOSX [/code]

The BundleIdentifier was (in previous build) fr.ThROB.ToroNess .

NSContactsUsageDescription is missing.

see
https://www.mbsplugins.de/archive/2019-03-31/Required_keys_for_infoplist_fi

Ok, thank you very much Christian.
I added at the end (before the :

<key>NSContactsUsageDescription</key> <string></string>
But I have now to understand how to add it automatically when I build my app. I will read again the link you gave me.

@Thomas ROBISSON — Copy the Info.plist file you have edited into the folder containing your source code, then drag&drop it into your project. That’s it

Be careful though, I am not sure it will work if you specify an empty string as you did.

Thank you, I insert a Script BuildStep inspired from the exemple Christian gave in his webpage. At the same time, I search to resolve the problem of some of my applications which use AppleScript, and I found the answer in other thread (NSAppleEventsUsageDescription).
Then my script is :

If (CurrentBuildTarget = 7) or (CurrentBuildTarget = 16) Then ' Mac OS 32bit ou Mac OS 64bit
  Dim TpTextA, TpTextB, TpTxtErr as String ' https://www.mbsplugins.de/archive/2019-03-31/Required_keys_for_infoplist_fi
  
  TpTextA = CurrentBuildLocation + "/" + CurrentBuildAppName + ".app"
  
  TpTxtErr = ""
  
  ' Disable if no need
  TpTextB = DoShellCommand("/usr/bin/defaults write " + TpTextA + "/Contents/Info ""NSAppleEventsUsageDescription"" ""Modify folder window view, Add login item, Make alias, Select item.""")
  If not(TpTextB = "") Then
    If TpTxtErr = "" Then
      TpTxtErr = TpTextB
    Else
      TpTxtErr = TpTxtErr + EndOfLine + TpTextB
    End If
  End If
  
  ' Disable if no need
  TpTextB = DoShellCommand("/usr/bin/defaults write " + TpTextA + "/Contents/Info ""NSContactsUsageDescription"" ""Read Contacts in your AddressBook.""")
  If not(TpTextB = "") Then
    If TpTxtErr = "" Then
      TpTxtErr = TpTextB
    Else
      TpTxtErr = TpTxtErr + EndOfLine + TpTextB
    End If
  End If
  
  If not(TpTxtErr = "") Then Print(TpTxtErr)
End If

I don’t think I need CurrentBuildTarget = but in the other BuildStep Script I did, I wrote it because I found an exemple using it (long time ago).

the build script works but you could just edit a text file that is a plist and add it to your project and it will be incorporated

see http://documentation.xojo.com/topics/application_structure/mobile/using_a_plist.html

in your case the file might look like

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<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>

Or if you use App Wrapper, you can just add the string on the Privacy pane, with the Xojo integration in App Wrapper, this is also set for debugging.