Deploying MAC OSX (Cocoa) app - first time

Hi all,
I have built an app in Xojo on Mac OSX, and am looking at the folder structure now. How would I set up everything so that an installer can install the project and it will work ok on a Mac (in this case, a Mavericks virtual machine)?

I see the Frameworks folder, that stuff is necessary for the XOJO project to run, I assume?

I see a MacOS folder next, and what seems to be a single large file with my projects name on it. Is this the main project .EXE so to speak?

Next is the Resources folder, with some external graphics and files in it. This I assume is any external music and graphics files that the project needs to access? Can I add more external files to this if not all of them were merged directly into the project itself but may be needed?

For my installer, do I leave this folder structure as is for it to work the way it did in the IDE?

Thank you in advance for any help!

I should note I built the app on a Windows 8.1 machine, if that wasn’t clear, but have a Windows and Mac license for Xojo, so it built for both.

Unlike Windows installers for OS X are rare
Usually you get a DMG (disk image)
For Xojo on OS X once you mount the dmg (by double clinging) the “install” is simply drag & drop
And you’re done
The entire app is a “bundle” - a thing the Finder represents to an end user as a single item with all those bits inside it

I recorded an example http://great-white-software.com/micellaneous/FinderScreenSnapz001.mov
The app, AppStudio, comes on a DMG
I double click that and simply drag & drop to install

However I don’t think you can make a DMG on Windows and would require building that on OS X

As dave said on the other thread

[quote=115144:@Dave S]if you move that “folder” to a real Mac. it will “magically” appear as a “single” file… in reality it still is a folder… but OSX treats it differently. Win doesn’t know any better and displays it multi level folder.

Basically for Mac you do not need an “installer”… you would either deploy the “APP” file… ZIP it, or create a PKG or DMG…[/quote]

You will need a Mac to code sign the application, otherwise when people try to run your application, they’ll get a message telling them not to.

I use DropDMG for dmg creation. In most cases there is no need for an installer on the Mac. The only one working on the Mac is called PackageMaker and is part of XCode. There is a GUI version available at http://s.sudre.free.fr/Software/Packages/about.html .

For both you will need a Mac.

Oh, and use AppWrapper Mini to sign your app (by Sam Rowlands). Everything else is just a headache.

First, once you have built your app for Mac, you get a file called .app.tar. You do not need anything else, and especially not to bucher it and practice experimental surgery on the folders inside. You cannot do anything on the Windows machine with the folder structure, besides looking at it to satisfy you personal curiosity. And especially, do not try to repack that into a new tar file. For technical reasons beyond this post, unpacking the tar file looses files attributes needed by Mac OS X, that is the reason why Xojo puts the build into an archive build especially.

Simply copy the original tar file to your virtual Mavericks Mac and it is there where you will do the job.

On the Mac, double click on the tar file, and it will extract the contained .app executable. If you double click on it, you will see your app working.

Mac users are accustomed to simply drag the .app into the Applications folder to install. No need for any installer. If you want simple, put your app and documentation into a folder, right click (or Control-click) on the folder, and select “Compress ‘name of the folder’”. It will create a zip fie you can distribute which will extract by double click like the tar did.

For something fancier, and more usual to Mac OS X users, use the Disk Utility (in Applications/Utilities) to create a DMG virtual disk. That will be a file with the extension .dmg containing a virtual disk When opened, it creates a disk image on the desktop where the user will find the files.

May I strongly suggest you familiarize yourself with Mavericks ASAP. You will see how simple the whole thing is, and forget about your folder structure conundrum :wink:

Thanks, Michel! So far so good…except for the fact that it crashes with a “File Not Found” (Exception 2) error upon running. When it starts, it reads from a .txt file to get the status of something, which is an external file not imbedded in the Xojo project. Do all resources (.txt files, fonts, graphics, etc) need to be directly imbedded in the Xojo project to work on a compiled Mac project?

That is by far the simplest thing… especially if the text is static.

NEVER EVER attempt to WRITE to embedded files… you can read them, but never write to them in the resource location.

Ok, so would I handle something like that on the Mac platform?

Handle what? embedded files? Just drag them into your project, and refer to their “contents” as if it were a string constant with the same name as the file (minus the extension)

Works this way for OSX and WIN… just the compiled version is a different format… but the functionality is identical

Thanks, Dave…I meant an external text file that can be read and written to. I tried placing the files in the .tar in the same folder as the .app .exe, still crashes.

I should note the app works fine in Windows.

What I do… is drag say a textfile into the IDE

When the app starts… I check on disk to see if I have already a file with that name…if not then this is a first time run.
So I create the file, write the contents from within the IDE to it… and use the DISK based file from that point forward

I bet the path of the file is not right. That is what basically means ‘File Not Found’.

For all intents and purposes, the usual places where on Windows one would put the file is a bit different on a Mac.

Placing files next to the executable is not done, as it would wreck havoc the Applications folder.

For read only files, drag them into the project and you will find them here :

dim myfile as folderitem = app.executablefile.parent.parent.child("Resources").child("myfile.txt")

This targets a subfolder of the folder structure you had discovered, which you may see in any Mac application by right click and “Show Package Content” where Xojo places the files you drag into the project.

As Dave told you, they cannot be written to, so if you need to read and write, copy all these files into a subfolder of Specialfolder.ApplicationData where you will be able to manipulate them at will.

In general, especially if your app is sandboxed to be sold in the Mac App Store, accessing user folders like Documents is not possible without asking the user to open the file first.

dim myfile as folderitem = app.executablefile.parent.parent.child("Resources").child("myfile.txt")

Works ONLY for OSX, which is why I did not mention it.

this works xPlatform… put in APP.OPEN and it will make sure you have a myfile.txt on disk

dim s as string
dim f as folder
s=myfile // the name as seen when you drag it into the IDE
f=specialfolder.applicationdata.child("myfile.txt")
if not f.exists then 
  dim t as textoutputstream
t=create(f)
t.write s
t.close
end if

I currently use this to load the file:

Dim f as FolderItem #if DebugBuild f = getFolderItem("").Parent.Child("svi.txt") #else f = getFolderItem("svi.txt") #endif dim t as textinputstream = textinputstream.open(f) dim svn as integer = cdbl(t.readall)

How would I change this so it works X-platform? Or do I just need to drag the file into the Xojo project?

[quote=115262:@Derek DiBenedetto]I currently use this to load the file:

Dim f as FolderItem #if DebugBuild f = getFolderItem("").Parent.Child("svi.txt") #else f = getFolderItem("svi.txt") #endif dim t as textinputstream = textinputstream.open(f) dim svn as integer = cdbl(t.readall)

How would I change this so it works X-platform? Or do I just need to drag the file into the Xojo project?[/quote]

As I told you, placing the file next to the executable is not done on Mac as the Applications folder cannot be written to.

In practice, you will have to adapt your path according to the platform. Something like :

#If targetWin32 then //Place your windows way of accessing the file you posted above #ElseIf TargetMacOs then //Place the Mac way to access the file. Adapt your code. //Execute once the code Dave posted to create the file upon the first start of your program then afterwards // check if the file exist at f=specialfolder.applicationdata.child("myfile.txt") //and open it #EndIf

Thanks Michel and Dave!

Odd, this code gives me “this item does not exist” errors when I try to Build:

t=create(f) t.write s

Fixed it, I think. Thanks!