Hard-coded approach (which you probably have tried); since the Application Support folder is under the Library folder:
uses System.IOUtils;
function GetApplicationSupportDir : string;
begin
Result := TPath.Combine(TPath.GetLibraryPath,'Application Support');
end;
Or, retrieving it directly from iOS or OSX: (For Delphi XE8 and higher)
uses
Macapi.Helpers,
{$IFDEF iOS}
iOSapi.Foundation,
{$ENDIF}
{$IFDEF OSX}
Macapi.Foundation,
{$ENDIF}
System.IOUtils;
function GetApplicationSupportDir : string;
var
Paths : NSArray;
Dir : NSString;
begin
// For "Application Support" under the User's Library directory:
Paths := TNSArray.Wrap(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True));
// For "Application Support" under the System Library directory:
//Paths := TNSArray.Wrap(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSSystemDomainMask, True));
Dir := TNSString.Wrap(Paths.objectAtIndex(0));
Result := NSStrToStr(Dir);
end;
For XE7, this may work:
uses
Macapi.Helpers,
{$IFDEF iOS}
iOSapi.Foundation,
{$ENDIF}
{$IFDEF OSX}
Macapi.Foundation,
{$ENDIF}
System.IOUtils;
///////////////////////////// Added since XE7:
const
_PU = '_';
libFoundation = '/System/Library/Frameworks/Foundation.framework/Foundation';
type
NSUInteger = LongWord;
NSSearchPathDirectory = NSUInteger;
NSSearchPathDomainMask = NSUInteger;
function NSSearchPathForDirectoriesInDomains(directory: NSSearchPathDirectory; domainMask: NSSearchPathDomainMask;
expandTilde: Boolean): Pointer {NSArray}; cdecl;
external libFoundation name _PU + 'NSSearchPathForDirectoriesInDomains';
/////////////////////////////
function GetApplicationSupportDir : string;
var
Paths : NSArray;
Dir : NSString;
begin
// For "Application Support" under the User's Library directory:
Paths := TNSArray.Wrap(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True));
// For "Application Support" under the System Library directory:
//Paths := TNSArray.Wrap(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSSystemDomainMask, True));
Dir := TNSString.Wrap(Paths.objectAtIndex(0));
Result := NSStrToStr(Dir);
end;