With declares (Add constant “FoundationLib = Foundation.framework”):
Function getAppVersion() As Text
declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr
declare function mainBundle lib FoundationLib selector "mainBundle" (clsRef as ptr) as ptr
declare function objectForInfoDictionaryKey lib FoundationLib selector "objectForInfoDictionaryKey:" _
(obj_id as ptr, key as CFStringRef) as CFStringRef
Return objectForInfoDictionaryKey(mainBundle(NSClassFromString("NSBundle")), "CFBundleShortVersionString")
End Function
[code]
Function getAppVersion() As Text
declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr
declare function mainBundle lib FoundationLib selector “mainBundle” (clsRef as ptr) as ptr
declare function objectForInfoDictionaryKey lib FoundationLib selector “objectForInfoDictionaryKey:” _
(obj_id as ptr, key as CFStringRef) as CFStringRef
Return objectForInfoDictionaryKey(mainBundle(NSClassFromString(“NSBundle”)), “CFBundleShortVersionString”)
End Function
[/code][/quote]
For this instead of using a declare I simply use a pre build script:
I have defined a constant at app level kVersion as text
my pre build script is simply:
dim v() as string
v.append PropertyValue("App.MajorVersion")
v.append "."
v.append PropertyValue("App.MinorVersion")
v.append "."
v.append PropertyValue("App.BugVersion")
v.append " ("
v.append PropertyValue("App.NonReleaseVersion")
v.append ")"
dim m as string=join(v,"")
ConstantValue("App.kVersion")=m
obviously you can create the constants based on your needs.
I am trying to get Antonio’s method to work and my script does not seem to affect the value of App.kVersion
I am pretty sure the script is running. (maybe not at the right time?)