The FMX code below was copied and pasted from a source long ago.
The FMX code below was copied and pasted from a source long ago.
Compiled with earlier versions of Delphi, it is working fine in the field.
However, if compiled and run with Delphi 10.2, Update 2, CFStr after the first line is nil, causing a crash on the CFStringGetLength call.
How can one reliably read the current version of an app on OSX (Sierra, 10.12.4)
function GetVersionFromExe: String;
var
CFStr: CFStringRef;
Range: CFRange;
begin
CFStr := CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle, kCFBundleVersionKey);
Range.location := 0;
Range.length := CFStringGetLength(CFStr);
SetLength(Result, Range.length);
CFStringGetCharacters(CFStr, Range, PChar(Result));
end;
Compiled with earlier versions of Delphi, it is working fine in the field.
However, if compiled and run with Delphi 10.2, Update 2, CFStr after the first line is nil, causing a crash on the CFStringGetLength call.
How can one reliably read the current version of an app on OSX (Sierra, 10.12.4)
function GetVersionFromExe: String;
var
CFStr: CFStringRef;
Range: CFRange;
begin
CFStr := CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle, kCFBundleVersionKey);
Range.location := 0;
Range.length := CFStringGetLength(CFStr);
SetLength(Result, Range.length);
CFStringGetCharacters(CFStr, Range, PChar(Result));
end;
Chris Rolliston You gave on Delphi's OS X support? That's worrying, considering you literally wrote the book on it!
ReplyDeleteJoseph Mitzen Chris' profile picture depicts that very moment ;-)
ReplyDeleteChris Rolliston Thanks, Chris. You were right. Somehow my project had lost all of the plist Key-Value items from the grid on the Project, Options, Version Info screen. :-( I rolled back to .dproj file that was intact.
ReplyDeleteThanks to others for their code samples and suggestions.