Splashstack and datastack for iPhone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Splashstack and datastack for iPhone
Hi all,
there was a long thread of using the Splash and Stack approach for the iPhone on this forum
http://forums.runrev.com/phpBB2/viewtop ... 3&start=45
As of Livecode version 4.5.3 it is possible to save stacks in the documents folder of the iPhone. This basically opens up the possibility to use one stack, the splash-screen stack to start the app and use the other stack as a working stack that can save its changes and is backed up by iTunes.
The stack I posted over there was a very rough proof of principle stack.
Here I would like to post a stack that shows how to do it in a little more refined way. Still basically a proof of principle.
There are some things to consider. The two stacks - Splash and Data are linked. You can not save directly into the documents folder of the iOS device but in the standalone application settings in Livecode for the Splash stack you can include a file. This file, the stack Data.livecode is copied to the 'engine' folder of the application when it is build.
Now the Splash stack when starting on the iDevice looks for the Data stack in the documents folder, if not found it will copy the data stack to the documents folder and there the Data stack stays and can be modified and saved.
Whenever the Splash stack starts it will find the Data stack in the documents folder and use it, no more copying of the data stack from engine folder to documents folder.
This set-up is important to understand since when you change the data stack in Livecode and then use it in the Simulator or the actual device, the new Data stack will NOT be copied to the documents folder, only the Splash stack is replaced.
So this has an important consequence:
WHENEVER YOU CHANGE YOUR APP DELETE THE VERSION YOU PUT ON THE SIMULATOR OR THE IPHONE FIRST BEFORE TESTING THE NEW VERSION.
The rest should be pretty obvious and you can always read up on the pitfalls in the long thread cited above or ask here.
But be aware that this is not a shure fire recipe for app approval, the iOS is after all a touch operated OS and the user expects a certain interface and handling. Also you have to consider how you would want to change the logic of the data stack in case of an update/added functionality without wiping the users data, which are stored in the data stack.
Oh, when in the data stack and you have more than one card swipe to the right or swipe to the left to go from one card to the next.
Kind regards
Bernd
there was a long thread of using the Splash and Stack approach for the iPhone on this forum
http://forums.runrev.com/phpBB2/viewtop ... 3&start=45
As of Livecode version 4.5.3 it is possible to save stacks in the documents folder of the iPhone. This basically opens up the possibility to use one stack, the splash-screen stack to start the app and use the other stack as a working stack that can save its changes and is backed up by iTunes.
The stack I posted over there was a very rough proof of principle stack.
Here I would like to post a stack that shows how to do it in a little more refined way. Still basically a proof of principle.
There are some things to consider. The two stacks - Splash and Data are linked. You can not save directly into the documents folder of the iOS device but in the standalone application settings in Livecode for the Splash stack you can include a file. This file, the stack Data.livecode is copied to the 'engine' folder of the application when it is build.
Now the Splash stack when starting on the iDevice looks for the Data stack in the documents folder, if not found it will copy the data stack to the documents folder and there the Data stack stays and can be modified and saved.
Whenever the Splash stack starts it will find the Data stack in the documents folder and use it, no more copying of the data stack from engine folder to documents folder.
This set-up is important to understand since when you change the data stack in Livecode and then use it in the Simulator or the actual device, the new Data stack will NOT be copied to the documents folder, only the Splash stack is replaced.
So this has an important consequence:
WHENEVER YOU CHANGE YOUR APP DELETE THE VERSION YOU PUT ON THE SIMULATOR OR THE IPHONE FIRST BEFORE TESTING THE NEW VERSION.
The rest should be pretty obvious and you can always read up on the pitfalls in the long thread cited above or ask here.
But be aware that this is not a shure fire recipe for app approval, the iOS is after all a touch operated OS and the user expects a certain interface and handling. Also you have to consider how you would want to change the logic of the data stack in case of an update/added functionality without wiping the users data, which are stored in the data stack.
Oh, when in the data stack and you have more than one card swipe to the right or swipe to the left to go from one card to the next.
Kind regards
Bernd
- Attachments
-
- splash and stack.zip
- (41.52 KiB) Downloaded 513 times
-
- VIP Livecode Opensource Backer
- Posts: 40
- Joined: Sat Jan 15, 2011 10:57 am
Re: Splashstack and datastack for iPhone
Hello Bernd
Phantastic Tutorial and Stack !
Cheers
Rolf


Cheers
Rolf
Re: Splashstack and datastack for iPhone
Hi Rolf,
thank you.
I did not know that Kangaroos use Livecode and even iOS, maybe it is the touch interface that finally won them over. They prefer to scroll.
Wieders, Gierkes, Majors and Gaskins I know of, but Kangaroos is new to me.
The future of Livecode looks bright!
Kind regards
Bernd
thank you.
I did not know that Kangaroos use Livecode and even iOS, maybe it is the touch interface that finally won them over. They prefer to scroll.

Wieders, Gierkes, Majors and Gaskins I know of, but Kangaroos is new to me.

The future of Livecode looks bright!
Kind regards
Bernd
Re: Splashstack and datastack for iPhone
Great, Bernd! These instructions will make it much easier for others. Thanks again for all your help!
I have trying to submit my little app to the Apple Store and created another topic regarding that process that seems a little daunting so far. I am in a "prepare for upload" state and I guess waiting to hear from Apple that I am "ready for upload."
I have trying to submit my little app to the Apple Store and created another topic regarding that process that seems a little daunting so far. I am in a "prepare for upload" state and I guess waiting to hear from Apple that I am "ready for upload."
Re: Splashstack and datastack for iPhone
Hi Sylvan,
good to hear you are on your way. Please keep us posted how it goes.
Kind regards
Bernd
good to hear you are on your way. Please keep us posted how it goes.
Kind regards
Bernd
Re: Splashstack and datastack for iPhone
Progressed to the "waiting for upload" state. I am using the Application Loader but keep getting errors. One error that took me quite a while to resolve and which, for others, should be documented in the iOS documentation is that you have to change the profile when saving as a standalone application before uploading. I spent hours on that one problem. I got the distribution certificate from Apple but it wasn't entirely clear in the LiveCode documentation what I was to do with the certificate. The LiveCode documentation for iOS just seems to take you through the process of adding the Team Provisioning certificate for testing the app on the iPhone but it doesn't mention that you then have to replace that certificate with the distribution certificate before uploading to the Apple Store. I eventually stumbled across this. When I decided that I might need to replace that provisioning certificate, it also took me a while to figure out HOW to replace it. I finally discovered that I needed to drag the new distribution certificate to the Xcode icon before the certificate would show up in the pop-up profiles menu. It actually took me a couple of days to get there! I think it would be helpful for others to have that simple little process added to the documentation to save people a lot of time and grief.
Now, I have reached another roadblock. When I try my upload now, using the applicatoin loader, I get an error that says "cssmerr_tp_not trusted" I have changed all my certificates to "trust always" and back to "default" but nothing seems to make a difference. I'm not sure what I'm doing wrong at this point. Somebody else on the forum said that they were using the ITunes Connect to upload their app rather than the Application Loader, but I can't see that option in iTunes Connect. Here is the actual error message:
"Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate."
and
"Unable to extract codesigning entitlements from your application. Please make sure StudyCards.ap is a valid Mach executable that's properly codesigned."
This first app was just a simple little app to test out the whole process to see how everything worked. It has taken me a couple of months to get this far! Hopefully, the next one will go much smoother!
Now, I have reached another roadblock. When I try my upload now, using the applicatoin loader, I get an error that says "cssmerr_tp_not trusted" I have changed all my certificates to "trust always" and back to "default" but nothing seems to make a difference. I'm not sure what I'm doing wrong at this point. Somebody else on the forum said that they were using the ITunes Connect to upload their app rather than the Application Loader, but I can't see that option in iTunes Connect. Here is the actual error message:
"Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate."
and
"Unable to extract codesigning entitlements from your application. Please make sure StudyCards.ap is a valid Mach executable that's properly codesigned."
This first app was just a simple little app to test out the whole process to see how everything worked. It has taken me a couple of months to get this far! Hopefully, the next one will go much smoother!

Re: Splashstack and datastack for iPhone
Update- well, maybe persistence pays off?? After I had posted my last mssg here, I had sent a message to iTunes Connect regarding my problem with uploading the app. I'm not sure if they did something on their end or if I just stumbled into a solution again but I tried uploading one more time, and this time, after probably 30-40 tries, the iTunes store accepted the app and now it is just waiting for approval.
Re: Splashstack and datastack for iPhone
I guess i'm going to bring this topic back up in the ratings
Two questions
1. I have made each card a standalone stack and included them in the first stack you see. So I have a "level select" standalone stack and a "Level" standalone stack etc. When I run it in the sim all the stacks work fine, switching them is no problem, but when I run it on my iPod I can't get it to change cards. I've tired "go stack Level Select" and "open stack Level Select" but none of it opens the card.
2. I need help with this whole saving thing. I got it to work in the simulator but I always had to press a button. When I changed it to "on shutDown" or "on closeStack" it didn't save it. Now I don't have too much in the way of code directed towards saving files in the Documents folder and the reason is that I saw that it worked in the simulator. When I did have code directed towards saving files in the Documents folder it didn't work. Help
I did use your sample program but I didn't really see how you were saving it in the scripts. But I did see that it was saving perfectly on my iPod.
Thanks,
Danny

1. I have made each card a standalone stack and included them in the first stack you see. So I have a "level select" standalone stack and a "Level" standalone stack etc. When I run it in the sim all the stacks work fine, switching them is no problem, but when I run it on my iPod I can't get it to change cards. I've tired "go stack Level Select" and "open stack Level Select" but none of it opens the card.
2. I need help with this whole saving thing. I got it to work in the simulator but I always had to press a button. When I changed it to "on shutDown" or "on closeStack" it didn't save it. Now I don't have too much in the way of code directed towards saving files in the Documents folder and the reason is that I saw that it worked in the simulator. When I did have code directed towards saving files in the Documents folder it didn't work. Help
I did use your sample program but I didn't really see how you were saving it in the scripts. But I did see that it was saving perfectly on my iPod.
Thanks,
Danny
-
- VIP Livecode Opensource Backer
- Posts: 65
- Joined: Sat Feb 26, 2011 10:02 am
Re: Splashstack and datastack for iPhone
Great, I've been searching for this a while!
About the splash-stack: How does the button work to go to the data-stack? I was expecting to find a <go to stack "data"> expression but couldn't find that. I'd like to replace the button with an image and jump to the data-stack 'on mouseup'
I love the ability to swipe in the data stack. I was looking for something like that in text-fields. Is it possible to make the text field in the data-stack respond to a swipe-up and swipe-down gesture so that when there is a lot of text in that field you can scroll it up and down (just like the ios/iphone addresbook for example?) I've tried that in numerous ways but can't get it to work
thanks!
About the splash-stack: How does the button work to go to the data-stack? I was expecting to find a <go to stack "data"> expression but couldn't find that. I'd like to replace the button with an image and jump to the data-stack 'on mouseup'
I love the ability to swipe in the data stack. I was looking for something like that in text-fields. Is it possible to make the text field in the data-stack respond to a swipe-up and swipe-down gesture so that when there is a lot of text in that field you can scroll it up and down (just like the ios/iphone addresbook for example?) I've tried that in numerous ways but can't get it to work

thanks!
Re: Splashstack and datastack for iPhone
Hi John,
you find the code in the red button "go data stack"
As for swiping the text field: do you want to swipe a locked text field or do you want to swipe a text field that is editable?
For swiping a locked text field have a look at
http://forums.runrev.com/phpBB2/viewtop ... =49&t=6876
if it is an editable field I would have to look into that. The tricky part would be to decide when to enter text and when to scroll.
@ Danny
the code for saving is in the stack script of the data stack:
with this code there should not be a need to hit a 'save' button.
I dont understand exactly what you are doing
How many stacks do you have? Are those stacks substacks of another stack or are they individual stacks?
Which one is the Splash stack? The splash stack is not saveable since it is the app and you can not save changes to the app.
If they are data-stacks and you moved them to the Documents folder they should work. Please explain or even better upload a simple zipped version of your project that shows the problem.
Kind regards
Bernd
you find the code in the red button "go data stack"
Code: Select all
on mouseUp
if the environment is "mobile" then
put (specialFolderPath("Documents") & "/data.livecode") into tPathToDatabase
put (specialFolderPath("engine") & "/data.livecode") into tPathToStartLoc
try
if not (there is a file tPathToDatabase) then
put url ("binfile:" & tPathToStartLoc) into temp
put temp into url ("binfile:" & specialfolderpath("Documents") & "/data.livecode")
wait 5 milliseconds with messages
end if
catch pErr
put pErr into field 1
end try
try
go stack tPathToDatabase
catch pErr
put pErr into field 1
end try
end if
end mouseUp
For swiping a locked text field have a look at
http://forums.runrev.com/phpBB2/viewtop ... =49&t=6876
if it is an editable field I would have to look into that. The tricky part would be to decide when to enter text and when to scroll.
@ Danny
the code for saving is in the stack script of the data stack:
Code: Select all
on shutDown
save this stack
end shutDown
I dont understand exactly what you are doing
How many stacks do you have? Are those stacks substacks of another stack or are they individual stacks?
Which one is the Splash stack? The splash stack is not saveable since it is the app and you can not save changes to the app.
If they are data-stacks and you moved them to the Documents folder they should work. Please explain or even better upload a simple zipped version of your project that shows the problem.
Kind regards
Bernd
Re: Splashstack and datastack for iPhone
I think an example program would be best@ Danny
I dont understand exactly what you are doing
27 so farHow many stacks do you have?
They are all individual mainStacksAre those stacks substacks of another stack or are they individual stacks?
The MainMenu stackWhich one is the Splash stack?
So I've foundThe splash stack is not saveable since it is the app and you can not save changes to the app.

Look out below! I don't know if my app will be a big one (Although you never knowPlease explain or even better upload a simple zipped version of your project that shows the problem.

Explanations are in the app.
Hopefully I hit on all your questions hehe but let me know if you have more.
Thanks for taking the time,
Danny
Re: Splashstack and datastack for iPhone
Hi Danny,
somehow your stack is not uploaded.
Your have to zip it, upload it a then "add the file" as an extra step.
Kind regards
Bernd
somehow your stack is not uploaded.
Your have to zip it, upload it a then "add the file" as an extra step.
Kind regards
Bernd
Re: Splashstack and datastack for iPhone
Wow I can't believe I forgot that. Here it is
- Attachments
-
- Saving Stacks Help.zip
- (5.63 KiB) Downloaded 404 times
Re: Splashstack and datastack for iPhone
Hi Danny,
the only thing I changed was in the "StartMenu" stack to block in the button. Everything else worked out of the box.
I reassigned the "level Menu" stack in Standalone Application Settings-> Copy Files.
Everything worked in the Simulator and the iPhone. (iPhone G3 iOS 4.2.1)
Stars were saved and everything. Repeatedly starting the App there where no problems to go to the Level Menu stack.
Did you delete the app from the iPhone before loading a new version to the iPhone?
I am wondering if you should not go for substacks instead of 27 stacks. You could make your leves all substacks of the Level Menu stack. That should make things easier, I guess. Start with just one or two substack and see how it goes.
You might try the stack you posted on your iPhone and see if it works if you block that one line of code in the button.
Kind regards
Bernd
the only thing I changed was in the "StartMenu" stack to block in the button
Code: Select all
Open stack "Level Menu"
I reassigned the "level Menu" stack in Standalone Application Settings-> Copy Files.
Everything worked in the Simulator and the iPhone. (iPhone G3 iOS 4.2.1)
Stars were saved and everything. Repeatedly starting the App there where no problems to go to the Level Menu stack.
Did you delete the app from the iPhone before loading a new version to the iPhone?
I am wondering if you should not go for substacks instead of 27 stacks. You could make your leves all substacks of the Level Menu stack. That should make things easier, I guess. Start with just one or two substack and see how it goes.
You might try the stack you posted on your iPhone and see if it works if you block that one line of code in the button.
Kind regards
Bernd
Re: Splashstack and datastack for iPhone
Hey Bernd,
It's getting better but I have two questions.
As you can see in the program I used the
code, but when I tried it in my game, on my iPod, it didn't save. I have a button that has the same code and when I press it I can quit, come back, and it saves the stack. I'm not sure why this is going on. Does shutDown run when I quit the game or another time.
Second. I was wondering why preOpenStack only works once on my iPod. Because as you might've seen in my app I have some code that says when you open the stack, add up those fields. Is there a way around this?
And I was looking and I do have the levels in substacks under the "Level Menu" stack. I always delete the app from the simulator and my iPod after I saw some of your posts.
Thanks,
Danny
It's getting better but I have two questions.
As you can see in the program I used the
Code: Select all
on shutDown
save this stack
end shutDown
Second. I was wondering why preOpenStack only works once on my iPod. Because as you might've seen in my app I have some code that says when you open the stack, add up those fields. Is there a way around this?
And I was looking and I do have the levels in substacks under the "Level Menu" stack. I always delete the app from the simulator and my iPod after I saw some of your posts.
Thanks,
Danny