Getting Bundle Version of App

I am very sure I am missing something obvious, but I just can’t seem to find anything related to this.

I need to get the Bundle Version of my app’s PLIST in code. Can someone provide an example of how to do this?

If you mean the data you enter in Shared Build Settings Properties, you can get them through App.ShortVersion, App.LongVersion, and other properties pertaining to the version. See :

If you want to open the PLIST, it is at app.executablefile.parent.child(“Contents”).child(“Info.plist”)

Thanks Michel, but I think I wasn’t clear enough.

After I run my application through App Wrapper, it moves the NonReleaseVersion to the Bundle Version in Info.plist (this is actually what I want as I’m using the NonReleaseVersion as a build number). Therefore, this number is no longer available from App.NonReleaseVersion. However, I still need to get this number at runtime. I know I can open Info.plist directly, but with the application being Sandboxed, I figure that might be a no-no. That’s why I was looking to see if there was some sort of officially sanctioned way to get this number.

What is strictly forbidden is writing. Opening info.plist for reading seems possible.

After signing and sandboxing with App Wrapper, app.MajorVersion will give you the number which is beside App.NonReleaseVersion in your Xojo project. Sam can better explain why, I just know that’s where you get it.

I just opened the info.plist in a sandboxed app. Problem is, its content is no longer text and cannot be used. But Roger gave the solution :slight_smile:

or set it using a constant then you can just refer to that constant

it’s a binary plist file. You can for example use plugin methods to read it.
NewCFObjectMBSFromXML will do that.

Binary or not you can’t read whats not present
Apples format and what Xojo create are different and to conform to Apples guidelines you end up stripping what would amount to the non-release version number
But if you just set it with a constant then you can use the constant in your code

If the “Change Version” flag is set in App Wrapper, it’ll convert the version number from Xojo to Apple’s preferred format.

I do need to alter how I deal with version numbers as it confuses a tremendous amount of people.[quote=94369:@Michel Bujardet]I just opened the info.plist in a sandboxed app. Problem is, its content is no longer text and cannot be used. But Roger gave the solution :)[/quote]
plist files should be opened with a CF or NS counter part. If it’s a dictionary, then use CFDictionary or NSDictionary, if it’s an array, then array counterparts. You should find these in MBS of Mac OS Lib.

The NSDictionary function is dictionaryWithContentsOfURL.

Thank you Roger! As I said in my original post, I was sure I was missing something obvious and there it is!