Porting old Cocoa projects to Xcode 7.3

Hello,


I have a number of very old Cocoa projects, created before Xcode using Project Builder and Interface Builder. I tried opening these projects in Xcode 7.3 and they wouldn't build -- the projects were too old. Is there another way to bring them up to date? Can the Interface Builder NIB file be updated to work in a recent version of Xcode?


Thanks.


Warren Nagourney

Accepted Reply

Literally nothing has changed in this area for years. Ignoring storyboards, if the window is marked "visible at launch", then it's actually created during nib loading. Otherwise, the window must be shown by code, but you'll need the outlet that was previously reported as missing, to get a reference to the window in the main nib.


So either you have code to show the window but it's not working because the outlet is not connected, or you were relying on "visible at launch" and it's not working because an exception was thrown (about the outlet) during nib loading.


It's actually better not to use any of this main nib infrastructure for windows at all, although it was the default for most of history. Better to have the window in a separate nib, and load it explicitly via a window controller. But you've got what you've got.

Replies

Your best choice is probably to download the last Xcode 3 (3.2.6), and run it on a version of OS X (10.5 maybe) that supports it. You should be able to convert your project to 3.2-compatible format, and that should let you open it with the current Xcode 7.3.


The trick is finding somewhere to run 10.5. If you don't have an old Mac that still works, you might have to run it in a virtual machine (VMWare, Parallels).

Thanks! I do have an old Powerbook (where I did my development). Can one get PPC Xcode from Apple? (I am reluctant to get it from a torrent, if there is one containing old versions of Xcode).


**

Xcode 3 is listed at


developer.apple.com/downloads/


which you should be able to access if you have a developer account.

Thanks! Found it.


**

I downloaded Xcode 3.24 to my old G5 running Leopard and found that it requires Intel hardware. Is there a version of Xcode which runs on PowerPC Macs and will act as a stepping stone to Xcode 7.3?


Thanks.

Instead of attempting to use an older Xcode, I just moved the various files and the single NIB file to Xcode 7.3. The project built fine, but all I get is a blank window when I try to run it. Apparently, the NIB (which has the various views, sliders, etc.) is not being recognized. Is there something I need to do to make it the output window instead of the (nonexistant) Storyboard? It seems that all the connections (Outlets and Actions) are intact.


Thanks.

In your info.plist, replace the NSMainStoryboardFile key with a NSMainNibFile key.

Thanks, when I do that, I get the message "Failed to connect (window) outlet from (NSApplication) to (NSWindow): missing setter or instancee variable".


In the plist, I removed the Storyboard key and added a NSMainNibFile key and placed the name of the nib into the value field.

I assume there's an outlet in the project that you created, connected to something in the deleted storyboard, OR a connection that was previously made to the NIB file where the outlet doesn't exist any more, or isn't connect.


I think, at any rate, you're going to need to get the NIB into an editable form in Xcode 7.3. Once that's done, you should be able to find the disconnected outlet and either reconnect it or delete it.

Since no windows appear when I launch the app, somehow the window containing the layout is not being loaded. I need to find how windows are loaded in recent versions of OS X -- apparently, things changed since I originally wrote the app.

Literally nothing has changed in this area for years. Ignoring storyboards, if the window is marked "visible at launch", then it's actually created during nib loading. Otherwise, the window must be shown by code, but you'll need the outlet that was previously reported as missing, to get a reference to the window in the main nib.


So either you have code to show the window but it's not working because the outlet is not connected, or you were relying on "visible at launch" and it's not working because an exception was thrown (about the outlet) during nib loading.


It's actually better not to use any of this main nib infrastructure for windows at all, although it was the default for most of history. Better to have the window in a separate nib, and load it explicitly via a window controller. But you've got what you've got.

Thank you, thank you! The key was "visible at launch". I found the box with this title, clicked it, and everything works fine now.


Warren Nagourney