MACOsLib Advice

There are a couple of bits and pieces I would like to use out of MacOsLib (link text but find I struggle to use it. Can anyone help. I am assuming I just copy the classes I want into my project and hey ho off I go?

Basically I want to use NSSearchField whose super is NSObject and within NSSearchField reference is made to NSText and NSThis, NSThat and NSTheOther. Ahhhhhh.

So… I want to use NSSearchField, found that Cocoa.NSSearchField, now what? How do I find all the associated classes, constants, properties etc I need to go with it?

You don’t, just copy the entire macoslib folder into your project. The compiler will strip the code you don’t need, and it will be much easier for you to install an update to it later.

Kem, Thanks. Partially working. However, I have done what you said. I then added a window added an NSDatePicker to the window, run it and fine a window with a date picker. So I built the app. 11 Meg for what should be just one window with a date picker on it? I don’t think the compiler has stripped disused code out. Am I doing something wrong?

If I create a brand new Cocoa project in Xojo and add a single button to a window, the app is about 3.8 MB. If I then add the macoslib folder to the project, the app remains 3.8 MB. If I then add an NSDatePicker to the window, it jumps to 6.2 MB.

I can’t reproduce the 11 MB you are seeing, but I can confirm that merely adding macoslib does nothing to the app size.

Strange, I too get the 3.8 MB button on window app size. No tried everything, 11.9 MB built with NSDatePicker.

What version of the IDE are you using? I tried this in Xojo.

Yes me too and the latest version of MacOs Lib downloaded today from GitHub.

You’re welcome to send me your test project so I can compare.

What should I send? The whole lot with MacOsLib?

Sure.

What is your email. Ive zipped it to 4.4MB and the build I have built is in there.

I got the project, but this looks like the whole MacOSLib project, not just your sample app, so I think this explains the discrepancy. You are compiling a bunch of other windows and functions into the project.

Do this: Start a new project. Open the macoslib project, copy the “macoslib” folder within that project, switch to your new project, then paste. Then add the NSDatePicker to the window and compile.

Well that solved that one. Thanks for your time Kem, most appreciated. My new build is strangely 6.2MB exactly the same as you were getting, oddly enough…

:slight_smile:

Just to clarify: A lot of people add all of macoslib to a new project when what they need is to add just the “macoslib” folder within the “macoslib” project. This is the source of a lot of confusion, and it can balloon a project by including a ton of unused resources only indirectly referenced.

Additionally, keep in mind that macoslib may be using additional libraries you weren’t using already, and they need to be added. XML and Regex libraries, for example. Using a single function from one of the libraries means adding it all to the final build (RBXML is half a meg, RBREGEX is 200K, RBSSL is a meg, RBScript is 5 Megs, etc., and they used to be double this, RBScript used to be 11megs, for example).

Also, something Macoslib adds that is easy to miss is a slew of languages to Menus for Cocoa with the official language names. You can add them by reference but then you’re adding all the languages they include. If you don’t want to edit macoslib you can add a post-build script to remove them:

[code] dim dest as string
dest = CurrentBuildLocation +"/" + chr(34) + CurrentBuildAppName + chr(34) + “.app/Contents/Resources”

dim cmd as string
cmd = "/bin/rm -rf " + dest + “/”
'print cmd

call doshellcommand(cmd+ “bg.lproj”+"/")
call doshellcommand(cmd+ “bn.lproj”+"/")
call doshellcommand(cmd+ “cs.lproj”+"/")
call doshellcommand(cmd+ “da.lproj”+"/")
call doshellcommand(cmd+ “de.lproj”+"/")
call doshellcommand(cmd+ “el.lproj”+"/")
call doshellcommand(cmd+ “et.lproj”+"/")
call doshellcommand(cmd+ “fi.lproj”+"/")
call doshellcommand(cmd+ “fr.lproj”+"/")
call doshellcommand(cmd+ “he.lproj”+"/")
call doshellcommand(cmd+ “hr.lproj”+"/")
call doshellcommand(cmd+ “hu.lproj”+"/")
call doshellcommand(cmd+ “is.lproj”+"/")
call doshellcommand(cmd+ “it.lproj”+"/")
call doshellcommand(cmd+ “ja.lproj”+"/")
call doshellcommand(cmd+ “nl.lproj”+"/")
call doshellcommand(cmd+ “no.lproj”+"/")
call doshellcommand(cmd+ “pl.lproj”+"/")
call doshellcommand(cmd+ “pt.lproj”+"/")
call doshellcommand(cmd+ “ro.lproj”+"/")
call doshellcommand(cmd+ “sk.lproj”+"/")
call doshellcommand(cmd+ “sl.lproj”+"/")
call doshellcommand(cmd+ “sv.lproj”+"/")
call doshellcommand(cmd+ “tr.lproj”+"/")[/code]

(I sorely miss syntax-coloured code blocks in the forum)