How to get application version

Perhaps as discussed in the past, I would like to know how to get the version of an application on MacOS.
I know that I can easily get it using AppleScript as follows, but I don’t want to use AppleScript since 10.14, because I have to make the user OK to use it.

set a to "/Applications/Adobe InDesign 2020/Adobe InDesign" as POSIX file as alias
tell application "Finder"
    get version of a
end tell

Is there any other best way?

mdls -name kMDItemVersion /Applications/Adobe\\ InDesign\\ 2020/Adobe\\ InDesign\\

This is easy.
Is this most easy way?
Is this a way to work with other versions of Mac OS?

You need to read the plist of the app. Here is a function that uses the MBS plugin:

[code]Private Function getBundleVersion(theFolderitem as FolderItem) as String

if theFolderitem = nil then Return “0”

dim theApplication as FolderItem = theFolderitem.Child(“Contents”)
if theApplication = nil then Return “0”
theApplication = theApplication.Child(“info.plist”)
if theApplication = nil then Return “0”

dim theBinStream as BinaryStream = BinaryStream.Open(theApplication, false)
if theBinStream = nil then Return “0”
dim thePlist as String = theBinStream.Read(theBinStream.Length)
dim theObject as CFObjectMBS = NewCFObjectMBSFromXML(thePlist)
if theObject = nil then Return “0”
dim theDictionary as CFDictionaryMBS = CFDictionaryMBS(theObject)
if theDictionary = nil then Return “0”
theObject = theDictionary.Value(NewCFStringMBS(“CFBundleShortVersionString”))
dim version as String = CFStringMBS(theObject).Str
Return version
End Function[/code]

Thanks Beatrix!
As you pointed out, I think that many of the answers in my search were “Read Info.plist.” I’m sure it’s a common way.
But I don’t want to use too complicated a method just to get general information like the version.
But the method you have taught will certainly help when I want to get more information about the application.
Thank you very much.

This isn’t the complicated way but the macOS way.

Its actually somewhat simpler

Private Function getBundleVersion(theFolderitem as FolderItem) as String
  Dim item As New MDItemMBS(theFolderitem)
  Dim v As Variant = item.GetAttribute("kMDItemVersion")
  return v
end function

Thanks Norman!
It’s amazing that MBS Plugin can handle mdls too!
It can really do anything!