Window from nib in dylib - cocoa

I'm quite new to the Mac but reasonably expirienced with windows.
What I need is a window owned opened and closed by the library (dylib).
This is very easy to do in MS Windows but seems not be hard under Cocoa.
I used the code from apple's 'CocoaInCarbon' example with C++ Wrappers.
But the NSApplicationLoad() followed by [NSBundle LoadNibNamed:#"MyWindow" owner:self] fails. Is this caused by the dylib not being a bundle.
Are there alternative ways to open and control a window within a dylib?

Yes, the problem is that it's not a bundle; your nib can't possibly be inside a bundle that doesn't exist, so how would the code find it to open it?
You need to either use a framework (which is a bundle), and ship the nib in that framework, or you need to create the entire window programmatically in your dylib.

It's not a standard practice to just ship dylib on Mac, when the shared library is not very low level and involves GUI in particular. You package it into a framework, so that it can not only have codes in it, but associated resources (nibs, images, sounds) in one place.
Read this Apple document to understand what's going on and how to prepare it. Or, take a look at /System/Library/Frameworks/ to see how the OS X itself provides libraries.

Related

Can you have Window creation code within a library?

I'm making a library that will act as a graphics aid, and one of the things I wanted to add was it's own Window creation.
I've seen how people use the default windows code in a Windows application, but that would only work in that project not the library.
Is it possible to add in window creation code into a library and have it behave in such a way like :
windowClass instance = libraryCreateWindow(blah,blah);
instance.showWindow();
Yes, it's possible. There is effectively no difference in creating a window from a library than from the main executable.
Windows belong to a process and are associated with a thread, it doesn't matter where in the code or in what module the window is created. I'm not sure what you're basing the statement "that would only work in that project not the library" on.
You didn't specify whether you were talking about a dynamic or static library, a C++ class library, or even a C#/.NET library, and the implementation details obviously differ depending on language and framework, but the answer should still be yes for any of the above.

MacRuby: How to write an app/script that generates native Mac apps?

So I'm basically trying to recreate what this app: Fluid, already does. I want to write a Ruby script, or MacRuby app that accepts a few parameters and can generate a simple native app.
Since their code is not open-sourced, I can't see how they do it. And I don't know how I would begin to accomplish something like this.
Also, I would like this script to be run on Windows (not that the user could install the generated app, but so the app could be distributed to Mac users).
How could I do something like this?
Solution:
Here is a project that does exactly the same thing that I'm trying to do. It takes an app bundle and does some string replacing on some files in the bundle. I'm going to use it as an example to imitate.
https://github.com/maccman/macgap-rb
MacRuby can already create native app bundles on OS X (it's a compiler as well as an interpreter), so in a sense there's no question to be answered here. If you want to write an app in MacRuby or Objective-C for OS X, the experience is essentially the same (though, of course, MacRuby has different command line flags for generating the final result, in this case the -deploy flag to MacRuby vs some linker invocation for ObjC). That said, nothing you write in MacRuby will run natively in Windows. Depending on the complexity of the app you have in mind, you may have to go to some cross-platform solution (like Unity) for that.
Check out Prism. It's not Ruby, but it does exactly what you describe and is open-source. One thing you'll to do is embed a web browser into a window, so look for libraries that do that. I'm assuming you'll use Cocoa for GUI since you're using MacRuby. In the end, the simplest way would be just have a window with web browser in it.

Is it possible to display XCode nib file on Windows?

I'm currently working on migration of iPhone project to Android. And since my dev machine is Windows 7, I'm wondering if there's a tool that would allow me to view nib files on Windows?
Basically what I want is to view nib files at least as an image file (no properties, just to understand how a View should look like).
And I would also appreciate if someone could suggest a tool that understands an XCode project structure and lets browsing of Objective-C files easy on Windows.
So, I'm looking into an convinient way of migrating an iPhone app to Android on Windows platform.
Thanks!
Not really. Nib files basically consist of a bunch of serialized ObjC objects; without reimplementing a significant portion of Cocoa / AppKit, it'd be difficult to make much sense of them. You might be able to extract the view hierarchy and bounds with some work, but it's probably much easier overall to just copy the file over to a Mac and open it up.

how to create XML Editor for MAC?

I need to build a XML EDITOR for MAC?
Can anybody help me in this regard? How should I proceed?
This is a very open ended question.
You can build applications for Mac OS X in a variety of languages/technologies. Common choices include:
Objective-C
Java
If you're developing in Objective-C (the native development platform for OS X), you'll need XCode from Apple.
You'll probably want to learn Cocoa (the UI framework on OS X) and the core libraries (Core Foundation, Core Data etc).
Oh, where to begin?
First of all, take note of Michael Shimmins' answer; you'll need Xcode to do the program. While his answer mentions Java, I would avoid that, and go for Objective-C.
As for the application itself, it all depends on how you want to edit the XML; some more information would be great on this point.
If you want a text-editor style XML editor, you should probably start with a simple Document-Based Cocoa Application; and put in an NSTextView, and see where you can go from there; if, on the other hand, you want a tree-based editor; you'll need to have a look at NSOutlineView and NSXMLDocument, part of the NSXML bits of Cocoa.
Then you'll need to design your application, program it, test it, and finally, if applicable, release it.
My advice would be to buy, not build.
There are also free XML editors, or free versions of commercial XML Editors.

Can FDT deal with .fla files or not?

I'm trying to find an all-in-one IDE for flash, one that can deal with various flash related files.
I just read this answer and it recommends fdt, but seems fdt can only deal with scripts but not .fla ones.
Which IDE should I use so that I can use it to develop various files involved in flash developing?
I am fairly certain it can not. Is there any particular reason you need this? Most developers code in external .as files. This way code is in one location and not buried in the timeline. Also the code can be placed in source control.
For an all in one solution, Adobe Flash CS5 is probably your best bet. They have somewhat improved the IDE and added things like autocomplete.
Flash Builder 4 and Adobe Flash CS5 have finally solved this problem - you can now create an FLA in Flash and then use the wizard to easily create a Flash Builder project around the .fla. All of your classes have access to library exports etc, and you can set it up so that when you click to edit a Class file in Flash it automatically opens the file in Flash Builder.
I really like it.

Resources