Recent

Author Topic: [solved]Application Bundle  (Read 2742 times)

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
[solved]Application Bundle
« on: October 12, 2017, 02:15:18 am »
I am having a great deal of problems working with a Mac. Its Unix Captain, but not as we know it....

I understand the Mac wants an app directory like MyApp/Contents/MacOS/TheBinary. And, I guess, its kind of tidy.  But Lazarus makes a bundle with a link were the binary should be back up to same level as as the app directory -

TheBinary
MyApp.app/Contents/MacOS/(Link../../../TheBinary)

If I move the binary down to MacOS and overwrite the link, it will run from command line but not from the GUI. I get told "The application cannot be opened". Put another copy of the binary back, level with the MyApp.app and it works again.

If I want to distribute this, I'd prefer to send it out as a single directory, thats how it should be IMHO ? Can I ?

David


« Last Edit: October 12, 2017, 12:21:58 pm by dbannon »
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Apploication Bundle
« Reply #1 on: October 12, 2017, 04:18:19 am »
But Lazarus makes a bundle with a link were the binary should be back up to same level as as the app directory -

That's a known defect in Lazarus, that it can't create a proper app bundle.

Copying the actual executable over the symlink is all you normally need to do to fix this.

You can also install the ExportToXcode package in Lazarus and export to Xcode, where you can compile your Lazarus project and create a proper app bundle, edit the Info.plist file, etc.

For future projects, you can install the LazXProj package and create a proper app bundle that way.

For both, see this:

https://macpgmr.github.io/

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Apploication Bundle
« Reply #2 on: October 12, 2017, 07:46:57 am »
Thanks Phil. I did try copying the executable over the symlink but, as I said, if I remove the the original executable, the app cannot be started from the GUI.  Works fine from the command line but the GUI seems to need the binary up level with the app directory.

I'll look at the link you posted.

Thanks
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

mischi

  • Full Member
  • ***
  • Posts: 115
Re: Application Bundle
« Reply #3 on: October 12, 2017, 09:09:15 am »
I did try copying the executable over the symlink but, as I said, if I remove the the original executable, the app cannot be started from the GUI.  Works fine from the command line but the GUI seems to need the binary up level with the app directory.
If I replace the symlink with the actual binary, the program can be started by a double click on the icon of the application bundle. If this does not work in your case, there is still something wrong. Maybe the name of the binary does not match the name in the file Info.plist or a field is missing in the Info.plist file. Code signing could also be an issue, although I am not sure about the situation with El Capitan.

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Application Bundle
« Reply #4 on: October 12, 2017, 12:21:29 pm »
yes, thanks Phil, mischi.

You are right, it works fine. I was copying the binary down into the app directory and did not notice I got an error message. OSX was telling me the link was identical to the binary and refusing to copy. So, delete the link, copy and it all worked as expected.

Careless, sorry to bother you guys.

David
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Mr.X

  • New member
  • *
  • Posts: 8
Re: Apploication Bundle
« Reply #5 on: February 11, 2019, 02:42:49 am »
But Lazarus makes a bundle with a link were the binary should be back up to same level as as the app directory -

That's a known defect in Lazarus, that it can't create a proper app bundle.

Copying the actual executable over the symlink is all you normally need to do to fix this.

I'm having a similar problem.
If I double-click the .app folder (using finder) on the machine that I created the .app, it runs fine.
If I copy the .app file to another Mac, and double-click it, I get "The application "project1.app" can't be opened"
If I "show contents" of project1.app, and copy the project1 file over the link in the "MacOS" folder in project1.app, it doesn't make any difference. Same error on the other machine.

If I copy the entire project folder with the lib folder and everything to the other machine, then double-click project1.app, it will run.
It seems there is another file that is needed for project1.app to run.

I haven't been able to get LazXProj to compile yet, so I'm wondering if anyone has any suggestions on how to create an application bundle manually with Lazarus?

This is a Cocoa app, but the same issue with a Carbon app. The IDE is on MacOS Mojave.

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [solved]Application Bundle
« Reply #6 on: February 11, 2019, 08:04:28 am »
Mr.X, did you read the thread carefully. What I was doing was copying the binary down into the project1.app folder over top of the symlink. However, MacOS was refusing to do that. You must remove the symlink first, then copy (or mv) the binary down into there.

Code: [Select]
rm project1.app/MacOS/project1
cp project1 project1.app/MacOS/.
Works for me, I regularly make carbon and now Cocoa (yippie!) releases that way.

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Mr.X

  • New member
  • *
  • Posts: 8
Re: [solved]Application Bundle
« Reply #7 on: February 12, 2019, 12:49:36 am »
Thank you for your reply.

I did read the entire thread, including your post. I replaced the link with the actual file, and still have the same problem.

As I said, it SEEMS like the app needs another file that isn't contained in the .app, but I don't know what it is or how to include it in the .app bundle. Would be nice if there were something better than very unhelpful error message from MacOS,
"The application "project1.app" can't be opened"

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [solved]Application Bundle
« Reply #8 on: February 12, 2019, 09:36:10 am »
OK, thats pretty strange indeed. Is strace an option on MacOS ?  Its the tool I'd use in Linux to see what files a process has opened.

Otherwise, I guess its a case of moving files out of the directory until it stops working. I assume you can safely remove the .pas, .lfm etc files first - they cannot be important (at this stage). I honestly cannot guess just what i could be ....

Do please let us know when you find this !

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

CCRDude

  • Sr. Member
  • ****
  • Posts: 480
Re: [solved]Application Bundle
« Reply #9 on: February 12, 2019, 10:12:52 am »
What about standard things like file permissions? Depending on where the .app is located, they can cause issues.

You can check the source of this to see all the steps and tools that are involved in updating bundles and creating installers (e.g. I do a chmod 755 there because I experienced in some circumstances that permissions were too strict).

Mr.X

  • New member
  • *
  • Posts: 8
Re: [solved]Application Bundle
« Reply #10 on: February 12, 2019, 07:23:36 pm »
Ok, I think I figured it out, and it's pretty weird. I was mistaken about it needing additional files, I think.

I used DropBox to transfer the files from the Mac where I created the app to my "clean" Mac. If I download the file from DB on the web, the resulting .app seems to have been "cleaned" where the project1 executable gets changed so it's no longer an executable.
However, if I fire up the DB app on my clean Mac and sync the files to that Mac, the .app runs and the executable is still there. (Syncing means a copy of the folder is on my computer as well)

Some sort of virus protection in DropBox maybe? But... no warnings, it just seems to "convert" the executable into something that doesn't execute. I'm not up enough on MacOS to figure out what's happening behind the scenes. If it were doing this as some sort of virus protection, you'd think it would at least "warn" you that you're trying to download an executable and would you like DB to stop that...

If I use Airdrop (forgot about that feature) the file runs fine. So it really seems like DB is messing with the file (but not telling anyone!)

Strangest thing I've ever seen.
« Last Edit: February 12, 2019, 07:28:31 pm by Mr.X »

Mr.X

  • New member
  • *
  • Posts: 8
Re: [solved]Application Bundle
« Reply #11 on: February 12, 2019, 07:32:48 pm »
I can't find anything about this in any searches I've tried online.

Would be interesting to give a DB link to someone and see if the .app survives the download to them on a different Mac.

If I .zip the file first and then download it from DB, it works fine. DB can't seem to handle downloading .app files for some reason!
« Last Edit: February 12, 2019, 07:43:50 pm by Mr.X »

CCRDude

  • Sr. Member
  • ****
  • Posts: 480
Re: [solved]Application Bundle
« Reply #12 on: February 12, 2019, 08:22:38 pm »
It's really a standard Linux/Unix/Mac thing then - file permissions!

If the binary does not have the "execute flag" set, it won't execute.

That's why I said chmod 755 ;) Which you'll also find as a necessary app bundle preparation / validation step in the source of the tool linked above.

Some zip tools do indeed store these unix permission masks, but Dropbox does not, you're right.

Mr.X

  • New member
  • *
  • Posts: 8
Re: [solved]Application Bundle
« Reply #13 on: February 12, 2019, 09:17:09 pm »
It's really a standard Linux/Unix/Mac thing then - file permissions!

If the binary does not have the "execute flag" set, it won't execute.

That's why I said chmod 755 ;) Which you'll also find as a necessary app bundle preparation / validation step in the source of the tool linked above.

Some zip tools do indeed store these unix permission masks, but Dropbox does not, you're right.
Thank you for that information. I'm really a Windows guy, so I've never had to think about permissions. Not even sure how to change them on MacOS.
Much as I'd like to use the LazXProj tool (which is what I assume you're referring to), it doesn't seem to work for me. (compile errors) I've tried contacting Phil via PM and also posted in the thread that discusses it, but no replies as yet.
(Phil hasn't been online since Oct 2018 so he may have abandoned the project and moved on)

Interesting that this DB issue isn't more well known. Even the DB support person I chatted with had no idea.
« Last Edit: February 12, 2019, 09:33:02 pm by Mr.X »

dbannon

  • Sr. Member
  • ****
  • Posts: 456
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [solved]Application Bundle
« Reply #14 on: February 12, 2019, 11:00:54 pm »
Ah, Mr X, sounds like you are making progress. Problem is, maybe, how you are moving it between machines. In the Mac world, I don't think they distribute the binary itself, or even the .app thingo.  That would be far too easy.

They make a good .app (with the binary down where it should be) and turn that into a dmg file, sort of a virtual disk that gets mounted when an end user requires. Then, looking into that virtual disk, the end user drags its .app into their application directory. That way, permissions remain are preserved inside the dmg file.

For an example of how this is all done (ie making that DMG file) you might like to look at my project, I'm sure its not perfect and its not easily setup initially but it does work.

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng