Simple Standalone for a Macintosh

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
lohill
Posts: 745
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Simple Standalone for a Macintosh

Post by lohill » Tue Jul 23, 2019 9:59 pm

There is a LiveCode lesson entitled "How do I save custom properties in a standalone application?" which can be found at http://lessons.livecode.com/m/4071/l/17 ... pplication. It works just fine if you make the standalone for a Windows computer but the Mac version does not work. Can anyone discuss what it takes to produce an executable that will run on a Mac?

I have attached copies of my "Splash" stack and "Main" stack as a starting point for anyone willing to try. Ideally I would like something that works like the Windows one - as a folder that can be located on the desktop and run from there. At this point, however, I will take anything that uses the "splash" method and works on a Mac.

Thanks for any light you can shed on this. It should be a lot simpler than it is.

Larry

P.S.
I was not able to attach my stacks so here are dropbox links:
https://www.dropbox.com/s/cig5ty3fzx2pp ... ecode?dl=0
https://www.dropbox.com/s/bc81m6z8carrt ... ecode?dl=0

bogs
Posts: 3912
Joined: Sat Feb 25, 2017 10:45 pm

Re: Simple Standalone for a Macintosh

Post by bogs » Tue Jul 23, 2019 10:19 pm

I suspect that on OSX, the splash stack would work just fine if you save the actual stack to the documents location, not the app folder, if you see what I mean. Windows and Linux don't look at the app folder as the app (for the most part, there are situations where that can be the case).

I'm sure Klaus or someone else will chime in if I am completely off target here, or maybe even if I am right on target :D
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6226
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Simple Standalone for a Macintosh

Post by dunbarx » Tue Jul 23, 2019 10:55 pm

Hi.

When you say "does not work" do you mean you cannot save information to the "Main" stack? Or you cannot make a standalone at all? You already know you cannot save to the "Splash" stack, which is the executable.

I do this on a Mac all the time. I save to one or more stacks and subStacks of stacks.

Craig

lohill
Posts: 745
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Simple Standalone for a Macintosh

Post by lohill » Tue Jul 23, 2019 11:09 pm

bogs,
When I put Launcher Test.app in the documents folder and run it from there it runs but will not save a changed name upon quitting and starting again.

dunbarx,
Yes. I mean it cannot save the information that gets changed. A re-start displays the old name. That applies for Launchere Test.app either on the desktop or in the documents folder as bogs suggested.

You say you can do this all the time. Can you do it with my stack? (the one in the lesson)
Larry

SparkOut
Posts: 2027
Joined: Sun Sep 23, 2007 4:58 pm

Re: Simple Standalone for a Macintosh

Post by SparkOut » Wed Jul 24, 2019 3:35 am

I thought this sounds like a path issue, as in the launcher not knowing where to find the main application stack. Then I noticed in the comments for that lesson, near the end, you will see Ivan refers to an issue on Mac that sounds like yours, and provides a solution.
If that doesn't help, write back.

bogs
Posts: 3912
Joined: Sat Feb 25, 2017 10:45 pm

Re: Simple Standalone for a Macintosh

Post by bogs » Wed Jul 24, 2019 11:22 am

lohill wrote:
Tue Jul 23, 2019 11:09 pm
bogs,
When I put Launcher Test.app in the documents folder and run it from there it runs but will not save a changed name upon quitting and starting again.
Sorry lohill, apparently I wasn't clear enough, I'll try again.

When you make a standalone for the Mac, the whole rig is put in a '.app' folder and treated as a monolithic executable file. That file acts as a standalone no matter where it is located, and you (normally) don't have write access to the objects inside of it by default.

What I was suggesting, however poorly, was turning the launcher stack into the executable as you normally would, and putting the stack the launcher launches outside of that and into the documents folder, or a folder in the documents folder, where the end user would DEFINITELY have write permissions.

In your launcher stack, you would refer to the saving stack by url, in this case using "special folder path", something like :
go stack (specialFolderPath("Documents") & slash & "foo.livecode"))

Of course, you would need to write the routine that puts the stack you want to save stuff in in that location. Off the top of my head, in the preOpenStack of the launcher stack, you'd write something like (not tested)

Code: Select all

on preOpenStack
   # check to see if there is a file there...
   set the defaultFolder to specialFolderPath("Documents")
   if "foo.livecode" is not among the files then
      answer "first run..."
      copy stack "foo.livecode" to specialFolderPath("Documents")
   end if
   # continue with launching the stack using the special folderpath...
end preOpenStack
Hope that is a bit clearer :D
Image

Klaus
Posts: 11262
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Simple Standalone for a Macintosh

Post by Klaus » Wed Jul 24, 2019 1:16 pm

Hi all,

Apple had changed the structure of an APP package after the lesson mentioned above has been published, so this is in fact a path issue.

1. Add your stack to your standalone via the "Copy files" tab in the "standalone application settings". Then you will find it here in your standalone -> specialfolderpath("resources")

Code: Select all

...
## SPLASH stack:
go stack (specialfolderpath("resources") & "/foo.livecode")
...
However you need ADMIN rights to be able to save that stack if the APP is installed in the "Applications/Programm FIles" folder!

So you need to copy that stack to the users Docs folder as bogs suggested:

Code: Select all

on preOpenStack
   # check to see if there is a file there...
   put specialFolderPath("documents") & "/foo.livecode" into tTargetStack
   put specialFolderPath("resources") & "/foo.livecode" into tSourceStack

  ## First run, copy stack to DOCS folder:
   if there is not a file tTargetStack then then
      put url("binfile:" & tSourceStack) into url("binfile:" & tTargetStack)
   end if
   ## Go stack tTargetStack
   ## ...
end preOpenStack
Best

Klaus

bogs
Posts: 3912
Joined: Sat Feb 25, 2017 10:45 pm

Re: Simple Standalone for a Macintosh

Post by bogs » Wed Jul 24, 2019 2:37 pm

Thank you for the (much clearer) explanation and code Klaus, I thought it might be something like that, but unfortunately have no (current) OSX box to test on.
Image

lohill
Posts: 745
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Simple Standalone for a Macintosh

Post by lohill » Wed Jul 24, 2019 7:37 pm

Thanks everyone. Klaus, I'm still trying to digest this. Are these two scripts to be placed in the Splash stack?
Then in the main stack whenever something needs to be saved you save it in the "target stack".

Larry

Klaus
Posts: 11262
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Simple Standalone for a Macintosh

Post by Klaus » Wed Jul 24, 2019 7:51 pm

Hi Larry,
lohill wrote:
Wed Jul 24, 2019 7:37 pm
Thanks everyone. Klaus, I'm still trying to digest this.
:-)
lohill wrote:
Wed Jul 24, 2019 7:37 pm
Are these two scripts to be placed in the Splash stack?
Yes.
lohill wrote:
Wed Jul 24, 2019 7:37 pm
Then in the main stack whenever something needs to be saved you save it in the "target stack".
Exactly!
Once that stack has been opened it can be addressed by its name e.g.: stack "el stacko loco"

Best

Klaus

lohill
Posts: 745
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Simple Standalone for a Macintosh

Post by lohill » Wed Jul 24, 2019 11:34 pm

Thanks Klaus. I have made a couple of stacks that demonstrate this simple case. They are in the zipped file which I have attached. The splash is called "Launcher.livecode" and the main program is called "Main Application.livecode". I have also included a folder called "Launcher Test Compiled" which contains the executables. I cannot test the Linux one so maybe someone else might. When the executable is run on a Mac a copy is placed in the documents folder and that is what gets updated. It is import to note that in updating this application for someone on a Mac, the copy of "Main Application.livecode" in the documents folder should be deleted prior to running the updated version. Now I have a lot more exploring to do with encrypting things.

As a side note this is important enough that the tutorial that LiveCode provides should point this out.

Larry
P.S. My zipped file that included the executable was too big so now it only includes the two source files and is called Forum.zip.
Attachments
Forum.zip
Source for Launcher Test
(6.72 KiB) Downloaded 11 times

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”