Test for MAS version

Would like to know if application is MAS version at runtime. Will this work:

[code] dim f as FolderItem = App.ExecutableFile.Parent.Parent.Child("_MASReceipt").Child(“receipt”)

if f <> nil and f.Exists then
app.MASVersion=true '<<<<<<<<<<<<<<<<<<<<<<<< MAS >>>>>>>>>>>>>>>>
end if[/code]

Or is there a better way?

Better use a constant which you define before you build.

The other way is to use the ‘codesign -d -vvvv’ command line function and process the result to figure out what code signature this application was signed with. If you choose this method, you want to verify against the “Developer ID” certificate.

isMASVersion = if( codeSignature <> “Developer ID”, true, false )

The reason being is that you should be using the “Mac Developer” signature when debugging, use the “3rd Party Developer” signature for final testing and uploading to Apple. Once Apple release on the Mac App Store, they’ll use a different code signature.

Ultimately, you probably want a compile time constant, they way you can tell the compiler to ignore or include certain code depending on the target. A future version of App Wrapper will include a function for assisting in this.

for the receipt, you should check it.
Some code is in MacOSLib and also the MBS Plugin has classes like AppReceiptMBS.

While I agree receipt validation should be some for MAS apps, I don’t think it should be used to determine if the app is a MAS build or not. The first time the app is installed it has no receipt.

The constant you set before building suggested by Christian is the only sensible way to go, IMHO.

Sam, I wish there was a way to retain the “NonReleaseVersion” (build number) someway.

Thanks all. Will follow the recommendation to set a constant for this purpose.