Recent

Author Topic: How to generate a MacOSX application archive?  (Read 13019 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
How to generate a MacOSX application archive?
« on: June 29, 2010, 01:42:04 pm »
After successfully compiling my MacOSX application, there's a lot of minor stuff left to get an installation file for the user:

(1) generate additional files for a distribution, make the correct folder structure and place the files to the correct location
(2) generate a PKG file which gets unpacked by the installation program
(3) generate a DMG file where the PKG file resides.

A few small steps, but a complete new world for Windows programmers...

Where's the best documentation how to do this? I need to begin from zero... Not only the structure of the archive has to be explained, also the structure of saving MacOSX applications in the app folders on the hard disk. Thanks for any hints.

Martin

Lord_ZealoN

  • Full Member
  • ***
  • Posts: 141
    • http://lordzealon.com

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: How to generate a MacOSX application archive?
« Reply #2 on: June 29, 2010, 10:40:36 pm »
(1) generate additional files for a distribution, make the correct folder structure and place the files to the correct location
(2) generate a PKG file which gets unpacked by the installation program
(3) generate a DMG file where the PKG file resides.
Where's the best documentation how to do this? I need to begin from zero... Not only the structure of the archive has to be explained, also the structure of saving MacOSX applications in the app folders on the hard disk. Thanks for any hints.

http://wiki.lazarus.freepascal.org/Deploying_Your_Application#Mac_OS_X_installers
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #3 on: July 17, 2010, 03:21:15 pm »
Thank you for the links.

There are a few problems left:

(1) file Myprog and directory Myprog.app

When comiling myprog in Lazarus, I get a file

myprog  (without extension)
myprog.app/Contents/MacOS/myprog  (the executable file)

If I double click to myprog.app (the finder does not show the extension), the program does not really work and it is executed via terminal window. User input gets into the terminal window instead of myapp.
If I double click myprog without .app extension (a file, not a directory), the application works fine.

What do I have to copy into /Applications folder that myprog works fine? I haven't seen additional files without extension in the Applications folder for other programs. I do not want to run the program via terminal window, of course.

(2) Stripping executables in MacOSX

On Windows and Linux, I can enter

strip --strip-all Myprog

and the executable file size gets reduced.

In MacOSX, there's also a strip command, but with other functionality and syntax. I assume, strip is part of XCode and not of Lazarus.

What is the reccomended way to reduce the size? Do I have to install upx additionally or instead?

Martin

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: How to generate a MacOSX application archive?
« Reply #4 on: July 17, 2010, 04:26:00 pm »
If I double click to myprog.app (the finder does not show the extension), the program does not really work and it is executed via terminal window. User input gets into the terminal window instead of myapp.
If I double click myprog without .app extension (a file, not a directory), the application works fine.
This is odd. Try to delete the .app dir (bundle) and recompile the project.
It should re-created the .app dir, so Finder can launch the application correctly.

myprog inside of the bundle is actually a symbolic link to the myprog executable outside of the bundle!
Whenever you distribute your application you should move myprog inside of the bundle, instead of using the symbolic link

(2) Stripping executables in MacOSX
What is the reccomended way to reduce the size? Do I have to install upx additionally or instead?
upx is additional executable files packer. it works different from strip.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #5 on: July 18, 2010, 06:48:45 pm »
Thank you for the hints. To strip the executable with macos strip, this seems to work:
strip -u -r myprog

I've studied now the file structure and it seems that Lazarus generates the executable file into the directory where the pas and lpi files resides and where the myprog.app directory is generated. In the directory myprog/Contents/MacOS/ resides a symbolic link which points to the executable file which resides in the main directory where myprog.app resides. It should be exactly reverse. If I change these two file locations (using cp and rm in the terminal window), the finder executes myprog.app correctly, but clicking to the symbolic link or running ./myprog in the terminal opens a new terminal window before opening my program window.

While finder works, Lazarus cannot debug the program anymore. I have to re-move the files to the primary location, then finder fails and Lazarus is OK again.

Deleting myprog and myprog.app and rebuilding the project does not change the behaviour.

I can handle this behaviour by copying the files to another directory where the file structure works with the finder and with the package manager. Nevertheless, the behaviour is strange. Any ideas?

Martin

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: How to generate a MacOSX application archive?
« Reply #6 on: July 18, 2010, 11:09:44 pm »
Have you tried to remove .app directory completely allowing Lazarus to rebuild the structure and allowing the system to flush its caches?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #7 on: July 19, 2010, 12:09:33 am »
Yes, after deleting the old structure I rebooted, before rebuilding the project in Lazarus again.

Meanwhile I tried a "hello world" sample form project, with the same behaviour. In the myprog/contents/MacOS folder, there is a link pointing to ../../../myprog

I use a Lazarus version which is one month old. Should I update the program and try again?

Martin

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #8 on: July 22, 2010, 03:14:27 pm »
Now I have successfully copied the files to a new myprog.app directory where the structure is OK for publishing by writing a simple shell script. Then I did run package maker. I think it is most useful to unpack the myprog.app directory into the /Applications directory by default.

But when I click to the pkg file or run "build + run" in the package maker, I get a "installation failed, please contact the software author" window (or something similar, I have here german text) when the installation ends, and no more specific information what happened. Where can I read more about the possible errors of a pkg file?

Martin

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #9 on: July 22, 2010, 04:44:36 pm »
I've seen now that Package maker has created one warning after "build":
myprog
0 errors, 1 warnings
and then you can read the text by clicking to an arrow.

When writing into /Applications, you need to set the checkbox "require admin authentication"

Summary: now I have solved the following problems:

(1) Lazarus creates the executable into the project directory, but it has to be copied to myprog/contents/MacOS, where Lazarus only places a symbolic link

(2) To create a pkg file, you need "Package Maker" from the Apple xcode program suite which is also necessary for Lazarus development
(2a) If you select the destination: "/Applications", you need to check the checkbox "require admin authentication"

(3) To pack the pkg file into a dmg file, you can use the on-board application "applications - utilities - disk utilitiy" (German "Programme - Dienstprogramme - Festplatten-Dienstprogramm" which means "hard disk utility" which is not really correct...). In the menu structure, you will find a "New - Image from folder" entry.

Martin

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #10 on: July 22, 2010, 07:17:23 pm »
I managed to run Packagemaker, but the result does not work. The pkg file gets unpacked without an error, but the unpacked data is not there. The packagemaker program crashed several times, and it is not updated by Apple for 1 1/2 years.

After reading this:
http://homepage.mac.com/simx/technonova/tips/packagemaker_and_installer.html

I searched an alternate packager and found

iceberg

This program is Freeware, has got a tutorial and works fine. The installed pkg files are the same as generated from packagemaker, with the difference that the iceberg pkg files do work.

Martin

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: How to generate a MacOSX application archive?
« Reply #11 on: July 23, 2010, 12:36:13 am »
I have now managed to create a dmg file from the terminal:

Code: [Select]
hdiutil create -srcfolder myprog myprog.dmg
while myprog is a folder where I place the myprog.pkg file and perhaps a readme file if you want.

Martin

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: How to generate a MacOSX application archive?
« Reply #12 on: August 22, 2010, 11:33:00 pm »
Are you sure you need to make a package? Unless something needs to be installed somewhere  else most programs simply arrive as a disk image which has the program as usual as .app folder and maybe a README file. The user simply drags the .app folder to a place he likes. Usually he will drag it to the /Applications folder. Therefore, you can add an alias to the /Applications folder in your disk image. This makes it easier for the user to drag the application to that folder.

Often, you can actually run the program from the disk image.

Greetings mischi.
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink