Page 1 of 1
Get bundle version from pList
Posted: Fri May 22, 2015 6:00 pm
by quailcreek
Hi,
I need to populate a fld with the app version so the user can tell what version they have. How would I pull the bundle version from the pList?
Re: Get bundle version from pList
Posted: Sat May 23, 2015 5:02 pm
by jacque
I'm sure there's a way, but I usually just create a custom property in the stack and read that.
Re: Get bundle version from pList
Posted: Sat May 23, 2015 7:04 pm
by quailcreek
Thank you once again, Jacqueline. I've been manually editing the content of the fld. I just thought making it automatic would be less error prone. H
I know it's from the standalone but how do you pull the version for AirLaunch?
Re: Get bundle version from pList
Posted: Sat May 23, 2015 8:51 pm
by jacque
Well, I read the plist.

But AirLaunch is coming at it from the other direction. The file is located at <app name>/Contents/info.plist. From a stack inside the contents folder you can get the path by getting the effective filename of the stack and working up from there. Shouldn't be that hard, I just never do it that way.
Instead I create a custom stack property named cVersion and add a setProp handler that updates all the standalone settings. Then when I type "set the cVersion of this stack to 1.0" it not only sets the custom version property but also updates all the build info. I started doing this when I got tired of clicking around in the standalone settings every time I updated the version.
Here's an example for an app I was working on for Android:
Code: Select all
setProp cVersion
put the cVersion of this stack into tCurVers
ask info "Current version is" && tCurVers & ". New version:" with tCurVers -- here's where you enter the version you want
if it = "" then exit to top
set the cVersion of this stack to it
put "android,version name" into tProp -- version #
set the cRevStandaloneSettings[tProp] of this stack to it
put char -2 to -1 of it into tCode
if char 1 of tCode = 0 then delete char 1 of tCode
put "android,version code" into tProp -- android build number
set the cRevStandaloneSettings[tProp] of this stack to tCode
end cVersion
There are dozens of standalone settings. Add the versioning ones you need for the platforms you are building for. You can find all the various LC settings by turning on "LiveCode UI Elements in Lists" (in the View menu) and then looking at the custom property set named cRevStandaloneSettings.
This particular example of the handler shows you what the current version is and lets you type in the new version you want. I find it handy because usually I don't remember what the last version was without looking. Then it sets up all the standalone settings with the new version and when you build, the plist will contain that info. If I had more than a couple of settings to change I'd put them into a repeat loop instead. I should probably generalize this to accomodate any app and platform, but so far it's just been a personal tool.
Or alternately...read the plist.

Re: Get bundle version from pList
Posted: Sat May 23, 2015 11:02 pm
by quailcreek
Thank you again, Jacqueline.
Looks like ios,bundle version is the one I'm looking for. Thanks for sharing your code... always helpful.