Getting started with Levure

Collaborate on tools, libraries, and applications beyond the IDE

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Getting started with Levure

Post by martyknapp » Sat Oct 27, 2018 5:56 pm

After years of using the GLX framework, I'm need to switch over the Trevore's new "Levure" framework. I downloaded the files and attempted to just build a standalone using the sample stack. I built executables of the "standalone.livecode" stack leaving the default name "LevureStandalone." But when I tried to make standalones or the test standalone with the framework I had no success.

My first question is, after I build the executable files, where do I place them in the folder structure? I tried a number of locations but kept getting an error, "the app.yml" file must be in the same directory or a subdirectory of the standalone stack." I had tried the executables in the same folder as the app.yml file.

2nd question, what is the minimal info needed in the app.yml file to build a standalone? In my case I'd made no changes to that file. Perhaps that is where the problem is.

It would be great to see some samples, especially of the app.yml file since that is a new concept to me.

Thanks for any help.
Marty

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Sat Oct 27, 2018 6:32 pm

Hi @martyknapp - You shouldn't need to make any changes to the app.yml file in order to package an application. With Levure you don't build standalones using the LiveCode standalone builder. You use the Levure application packager. I think you need to read the following page in the wiki which explain how packaging a Levure application works:

https://github.com/trevordevore/levure/wiki/packager

If you want to test your application in a standalone without packaging up the whole application then take a look at this wiki page:

https://github.com/trevordevore/levure/ ... pplication

As for examples, the following two github repos have open source applications that use Levure:

https://github.com/trevordevore/bell-conductor
https://github.com/trevordevore/sql-yoga-levure-app
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Mon Oct 29, 2018 7:45 pm

Thanks Trevor,
So I configure the standalone settings for "standalone.livecode" stack but don't use LC to actually build like we did for GLX (that was my assumption)?

Either way, whenever I invoke "levureBuildStandalonesForTesting" the only thing created is a log file. No errors are generated, but there's no "test" folder nor any apps built. I created a "test" folder in the builds folder but it gets deleted when I try to build the test app.

The log file shows the correct output folder and that it's "Done building standalone for testing"

When I invoke levurePackageApplication "beta" I get an error:

"the app.yml file must be in the same directory or a subdirectory of the standalone stack"

I haven't moved anything - I've started with a fresh Levure project in a new folder and set the standalone settings for the "standalone.livecode" stack - that's it.

I've watched all the screencasts and have read the wiki extensively. But perhaps some of my "GLX" assumptions are throwing me off.

I'm using LC 9.0.1 Business on a Mac

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Mon Oct 29, 2018 8:01 pm

I would suggest starting from scratch as there is something odd going on. Perhaps when using the LC Standalone Builder it altered some settings that break Levure. I just created a new app using the project creator (go stack url "https://raw.githubusercontent.com/trevo ... n.livecode"), open the Standalone Settings dialog, closed it, saved the stack, and then called `levureBuildStandalonesForTesting` and executables were created as expected.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Tue Oct 30, 2018 1:05 am

That did the trick, though not sure why! Now I get to dive in and convert all my GLX-based code over to Levure.

Just want to say a big thank you to Trevor for creating this framework - makes for building apps very slick. The update helper, in particular, is a great resource for the LC community.

Marty

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Tue Oct 30, 2018 7:02 pm

Great! As to why it didn't work before, my guess is that a behavior (maybe the standalone.livecode stack behavior?) somehow got messed up which affected how packaging worked.

You are very welcome Marty! The nice thing about having Levure on Github is that others have been able to contribute to code and documentation. I'm hoping that we will see some community efforts around helpers going forward. They are a great way to package up and add complex functionality to an application without the developer having to worry about the details.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Wed Oct 31, 2018 10:53 pm

Yesterday I spent the day getting my app switched over to Levure and things seemed to be working well. Today when I start up the project in Levure it's not creating the preference file. It's name is set to be "CBP3_Prefs" on the Mac. When I save a preference setting, it's creating a file in the Preferences folder named "CBP_Prefs.plist" and it appears to have the values I'm trying to save. But of course when I try to read the preferences it's not finding the "CBP3_Prefs" file. I've quit and restarted LC and rebooted my Mac. Any clues?

Marty

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Wed Oct 31, 2018 11:35 pm

To add a little more info.. So I decided to "go with the flow" and change the name of the preference file to "CBP3_Prefs.plist." I then delete that file from the Preferences folder and start things up again. It will not create a new preference file by that name. But if I open up my Preference stack and save a setting, then it creates the file and is able to read and write. That's on Mac.

On Windows I have the pref file name set to "CBP3.prefs" and again, it will not create that file. Trying to save a preference setting does not appear to create file like it does on Mac.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Thu Nov 01, 2018 1:15 am

Marty - the .plist extension is expected on Mac. Don’t add it to your app.yml file though. The NSUserDefaults API automatically saves to the plist file format.

Are you calling prefsSave in your code? NSUserDefaults will flush prefs to disk on its own. On Windows the prefs file won’t be created until prefsSave is called. This happens automatically during shutdown of a standalone. It won’t happen automatically in the IDE.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Thu Nov 01, 2018 3:04 am

OK so now on Windows I have it check to see if the pref file exists and if not I call prefSave and it creates the file. But it wasn't saving when I shut down so I inserted prefSave on shutDownRequest and that fixes it for Windows.

I have a function which looks to see if the pref file exists and my code didn't take into account the ".plist" file extension on Mac. So I fixed that and now if it doesn't find it on the Mac it saves a bogus preference and that creates the file.

Now I can dive into the update helper - that looks like it could be a challenge!

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Thu Nov 01, 2018 3:36 am

Why do you need to manually create the pref file if it doesn’t exist? Is there some reason it needs to exist before the first save?

If the preference file isn’t being saved on Windows automatically when you quit then it may be that Levure isn’t getting a shutdown message it processes. Are you trapping shutdownrequest in your app?
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

martyknapp
Posts: 31
Joined: Fri Mar 24, 2006 5:33 pm
Location: Blaine, Washington - USA

Re: Getting started with Levure

Post by martyknapp » Thu Nov 01, 2018 4:08 am

The app does require one setting - the location of the folder where the user's documents are stored (which can be changed from within the app, then the path saved to prefs) so it's not so much that the pref file exists but that the app won't know where to find/save the documents. So if it can't then I force the user to re-establish that path and save it to prefs before they try to create a new document (and the app not know where to save it). I can see that with Levure I could take a different approach.

I'll have to check the shutDownRequest, I think that I am doing something with that - should be easy to rectify.

Thanks

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 919
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Getting started with Levure

Post by trevordevore » Thu Nov 01, 2018 4:35 pm

I looked at the code and Levure handles the `shutdown` message and runs code to shut things down and cleanup. The handler that is run is `levureShutdownApplication` which is in the `levure.livecodescript` script. That is the handler that calls `prefsSave "user"`.

So if you block shutdown and don't pass it then it would keep the prefs from being saved.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “Community Projects”