Universal iOS Deployer?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Universal iOS Deployer?

Post by richardmac » Mon Jan 02, 2012 6:20 pm

My little company has deployed an iPad app to the app store ("HAT") and I've just finished creating an iPhone 4 version with super awesome graphics. My plan is to now create an iPhone 3 version, so in all we'll have 3 different versions of the app, each with it's own stack.

Now here's the question. Can you build a stack and include all three versions of the program (iPhone 3, iPhone 4, iPad) as substacks? Or do you have to release separate iPad and iPhone applications?

Side note question - when you select iOS for development, it won't let you add substacks. How would one use the Animation Engine substack, then?

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Mon Jan 02, 2012 9:26 pm

To answer part of my own question - You can uncheck the iOS box, add substacks, and recheck the box. You can then use:
go stack "my substack"

That works. Works in the simulator too.

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Universal iOS Deployer?

Post by FireWorx » Tue Jan 03, 2012 6:09 am

Good learning going on here. = ] I wasn't aware of that little piece o data. Thanks.
Dave

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Universal iOS Deployer?

Post by Jellicle » Tue Jan 03, 2012 6:19 am

I deploy to Retina and non-Retina iPhones in one app. My app has a starter stack that contains (in the Copy Files list) the Animation Engine stack, plus 2 stacks, one each for each resolution. I then detect the device the app is running on first launch and copy the appropriate stack to the Documents folder on the device. I then go to that stack. On subsequent launches I detect the device again and just go to the stack. I do a 'start using stack "animationEngine.livecode' to make that stack available.

Cheers

Gerry
Last edited by Jellicle on Wed Jan 04, 2012 9:10 am, edited 1 time in total.
14" MacBook Pro
Former LiveCode developer.
Now recovering.

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Tue Jan 03, 2012 6:24 pm

Jellicle wrote:I deploy to Retina and non-Retina iPhones in one app. My app a starter stack that contains (in the Copy Files list) the Animation Engine stack, plus 2 stacks, one each for each resolution. I then detect the device the app is running on first launch and copy the appropriate stack to the Documents folder on the device. I then go to that stack. On subsequent launches I detect the device again and just go to the stack. I do a 'start using stack "animationEngine.livecode' to make that stack available.

Cheers

Gerry
Gerry,

You put the stack files in the "Copy Files" list? The Copy Files list says to use non-stack files, but I just tested it and it does allow you to copy stacks. Which approach is the best according to the LiveCode folks, does anyone know? And does anyone have any ideas about the pros and cons of putting stacks in the stacks area vs the Copy Files area?

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Universal iOS Deployer?

Post by Jellicle » Wed Jan 04, 2012 9:09 am

richardmac wrote: And does anyone have any ideas about the pros and cons of putting stacks in the stacks area vs the Copy Files area?
I don't think you can add stacks to iOS apps under that Stacks tab in the standalone settings - at least I can't - it's all greyed out.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Wed Jan 04, 2012 9:26 pm

Jellicle wrote:
richardmac wrote: And does anyone have any ideas about the pros and cons of putting stacks in the stacks area vs the Copy Files area?
I don't think you can add stacks to iOS apps under that Stacks tab in the standalone settings - at least I can't - it's all greyed out.

Gerry
You can. You have to uncheck the iOS box first, then add the stacks, then recheck the iOS box. The stacks appear grayed out in the list but are still accessible.

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Thu Jan 05, 2012 3:14 am

I ended up putting the stacks in the Files area, not the Stacks area. And in the Files area, I can call it by doing this:

put specialfolderpath("documents") & "/stackname.livecode" into disPath
go stack disPath
close stack "originalstack"

I found I had to close the original stack, because I had this code in a case statement and if I didn't close the stack I had issues.

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Universal iOS Deployer?

Post by andyh1234 » Thu Jan 05, 2012 11:39 am

Just in case you go down the Android route next, I've found having the stacks (including Animation Engine) anywhere other than under the main stack to be a real pain to support!

However, you can simply copy the animation engine and any other stacks into your project folder, open their properties and set their main stack to the name of your stack and they become substacks of your main stack.

Everything else is then done for you, you don't need to tell the builder to include any files etc and it works in iOS and Android.

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Thu Jan 05, 2012 1:55 pm

Good to know. I'm not developing for Android yet - but it's definitely on the radar. I'd be curious as to how you handle all of the different screen sizes.

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Universal iOS Deployer?

Post by andyh1234 » Thu Jan 05, 2012 2:42 pm

Handling the vast array of screen sizes is probably the hardest part, but once you get into it its not that bad.

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Thu Jan 05, 2012 3:28 pm

For anyone reading it to try to figure out how to use substacks in an iOS app, here are a few things I've learned - if anyone sees anything incorrect in this list, please chime in and correct me:

1. You can definitely use substacks, but keep in mind that LiveCode on iOS can only have one stack window open at a time.
2. Import the substacks in as files, in "Copy Files" in Standalone Application Settings. Yes, that field IS labeled "Non-stack files in the application," but it works anyway. Besides, once you click the iOS box for deployment, it locks up the "Stacks" screen.
3. When you call a substack, you need to use "specialfolderpath." Here is an example:
put specialfolderpath("documents") & "/HAT for iPhone3 v50.livecode" into disPath
go stack disPath
4. You do NOT need to include a "close stack" message in your main stack as I thought above. The stack will automatically close when you go to a new stack.
5. When you do this approach, any graphics that you have LINKED in your substack (as opposed to imported) will not show up. Therefore, if you have a folder of graphics/sounds/etc that your substacks rely on, you need to add that folder to the Copy Files screen on your main stack. Then all will work.
6. The iOS settings of substacks appear not to matter - the only iOS settings that are honored are the settings in the main stack.
7. Put the go stack disPath command in openStack, NOT preOpenStack. It doesn't work in preOpenStack.

I'm pretty excited that I learned how to do this. I know it's probably basic stuff but I feel that my next project will go three times as fast because now I know what I'm doing. :)

(edit - added number 7)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7397
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Universal iOS Deployer?

Post by jacque » Thu Jan 05, 2012 6:50 pm

Is there a reason not to just keep the substacks as part of the stack file? That would be much simpler, you wouldn't need to calculate their file path, and they'd always be available. All the open/close business is automatic. The only time you'd want to avoid that is if you need to save data, and in that case just clone the substack to the Documents folder.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Universal iOS Deployer?

Post by richardmac » Thu Jan 05, 2012 7:52 pm

jacque wrote:Is there a reason not to just keep the substacks as part of the stack file? That would be much simpler, you wouldn't need to calculate their file path, and they'd always be available. All the open/close business is automatic. The only time you'd want to avoid that is if you need to save data, and in that case just clone the substack to the Documents folder.
By keeping the substacks as part of the stack file, do you mean adding them to the main stack in Standalone Application Settings/Stacks? Or am I missing something? You mean, opening up the substack and using the message box to set the main stack of the substack to my main stack?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7397
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Universal iOS Deployer?

Post by jacque » Fri Jan 06, 2012 5:47 pm

Yes, I meant during development. Put your secondary stacks into the same stack file on disk by making them substacks of the mainstack. Then it is all one single file, and the substacks are always available. You don't even need to open them, you can just "go" to them. No file paths needed because they are part of the same file on disk. You don't have to include anything in the standalone builder; the substacks are already attached to the mainstack. (BTW, you don't need to set that in the message box if you don't want to; in the General pane of the stack property inspector there's a popup button for it.)

The word "substack " has a specific meaning in LiveCode. It does not mean "other stacks I open". It means "stacks that are embedded as part of the same file on disk as the mainstack." Substacks are intended to keep all related stacks together, will always load into RAM automatically when your mainstack opens, can be referenced by their short name whether they are open or not, and have a lot of advantages over using separate files on disk. The one thing they cannot do is save data to themselves in a standalone. Because it is all a single application file, no part of the file can save itself. So if any of your stacks need to save data (like a preferences stack) then that one does need to be in a separate document file. Everything else can be a substack.

Because "substack" is a specific LiveCode term, I usually differentiate between embedded stacks and separate stacks by calling the separate ones "document stacks".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply