foxmagic
« previous entry | next entry »
Jun. 28th, 2003, 12:29 pm
[info]foxmagic
Builder
How To Make Your Own Web Browser on Mac OS X, In Ten Easy Steps.

[info]fraserspeirs came up with the instructions and helped me through 'em the first time. I'm just elaborating on what he wrote.

1. Sign up for a free Apple Developer Connection account at 'http://connect.apple.com/'. Go to the Download Software area, and download/install the December 2002 Mac OS X Developer Tools (under 'Developer Tools'), and the Web Kit SDK (v1.0) (under 'WWDC 2003').

2. Start up Project Builder (in '/Developer/Applications'), and create a new Cocoa Application project. Name it anything you like.

3. Open a Finder window and navigate to '/System/Library/Frameworks'. Drag the WebKit.framework folder into your Project Builder window, under 'Groups & Files'. It doesn't matter where you put it.

4. Click the arrow by Resources, and double-click on MainMenu.nib to open it in Interface Builder.

5. In your Finder window, go into 'WebKit.framework/Versions/Current/Headers'. Select all the files, and drag them into the MainMenu.nib window in Interface Builder. It should switch to the Classes tab and add a few classes to it, including one named WebView. You'll also get an error dialog complaining about an unknown superclass; click OK and ignore it.

6. In Interface Builder, click the Instances tab, then double-click on Window and you'll get an empty window and a 'Cocoa-Views' palette with lots of objects in it. Click the 'Containers' icon at the top of the palette (the sixth one over, has two tabs at the top of it). Drag 'CustomView' into your window. Click once on the CustomView in your window to select it, go to the Tools menu and select Show Info, and select Custom Class from the pulldown menu. Scroll the list down and click on WebView. This will be where the contents of web pages will appear.

7. Click on the second icon at the top of the Cocoa-Views palette, and drag the button named 'Button' into your window; double-click on it and name it 'Forward'. Then drag another one in; double-click on it and name it 'Back'. Drag the empty white rectangle (text field) into your window. This'll be where you type a URL in the finished application.

8. Hold down the Control key (that's Control, not Option or Command), and drag a line from the Back button to the WebView. An 'NSButton Info' window should appear. In it, click 'goBack:', then 'Connect'. Do the same to connect the Forward button to 'goForward:', and the text field to 'takeStringURLFrom:'. Don't forget to click 'Connect' each time.

9. Arrange and resize the items in your window however you want 'em. This probably will include making the text field wider, and making the WebView take up most of your window. When you have them where you want them, select 'Size' from the pulldown menu at the top of the info window. This is where you specify how things move when you resize the window. Click once on the WebView, and click on the lines inside its rectangle to change them to springs; this means its size will change, but the distance from its borders to the edges of the windows won't change. On the Back and Forward buttons and the text field, you'll want to change the line under their rectangles to be springs (since the distance from them to the bottom of the window can vary, but you want the distance to the top of the window to be the same). You should also put horizontal springs inside the text field so it can grow with the width of the window.

10. Select File/Save to save your interface modifications, then in the Project Builder window click the third icon from the left -- it's a hammer behind a couple of windows. This will build the project, then run it automatically for you. When the application window appears (looking just like the one you created), type 'http://www.apple.com/' in the text field, and hit Return. The Apple home page will appear. Try navigating around and using your Back and Forward buttons.

And that's all there is to it.

Notice that you never had to write any code.

Troubleshooting:

- If your buttons or text field don't work, make sure you connected them properly in step 8.

- If things move around weirdly when you resize your window, try adjusting the springs in step 9.
24 comments
Jasmine Becket-Griffith
Jun. 28th, 2003, 9:31 am
[info]jasminetoad
Link

That's too cool! Lol, maybe I do need a Mac ;)
Chernabog
Well, you could do all that...
Jun. 28th, 2003, 11:21 am
[info]chernabog
Link

Or you could download Safari for free. What am I missing here? ;)
Re: Well, you could do all that...
Jun. 28th, 2003, 12:56 pm
[info]ex_divalibby633
Link

downloading is much less fun!
Yuhui
Re: Well, you could do all that...
Jun. 29th, 2003, 2:46 pm
[info]yuhui
Link

What you're missing: the awesome ease of rolling your own browser, something that Mozilla has promised but remains difficult to do due to its unique UI API.

Sure, you could download Safari. But by following these instructions, anybody with little to no programming experience can create their own browser... and feel the power of being a developer! :)
Jun. 28th, 2003, 12:57 pm
[info]ex_divalibby633
Link

that is one of the coolest mac things I've ever heard, and I love my mac.

Apple is cool.
Unciaa
Jun. 28th, 2003, 3:40 pm
[info]unciaa
Link

Now if someone just ported Cocoa to Win32... ;)
Fraser Speirs
Jun. 28th, 2003, 4:08 pm
[info]fraserspeirs
Link

Apple would be out of business in two years....
Unciaa
Jul. 1st, 2003, 8:56 am
[info]unciaa
Link

Hmm, why? Since when is promoting a system by demonstrating what good software is a bad thing?
Fraser Speirs
Jul. 1st, 2003, 11:15 am
[info]fraserspeirs
Link

Because then there would be no incentive to pay the price premium that Apple computers command. If you look at Apple's financial statements, you'll see that the vast majority of their revenue comes from hardware sales.

I really wouldn't want to trade my PowerBook for a Toshiba :-)
Unciaa
Jul. 1st, 2003, 4:29 pm
[info]unciaa
Link

So on one hand people wouldn't buy Macs if they could just get its software... And on the other people wouldn't want to replace their Macs even if they could use the software elsewhere? :p
Fraser Speirs
Jul. 1st, 2003, 4:44 pm
[info]fraserspeirs
Link

on one hand people wouldn't buy Macs if they could just get its software

Probably not. The point is that Apple as a company cannot afford that risk. The software is the major attraction to buy the hardware.

on the other people wouldn't want to replace their Macs even if they could use the software elsewhere

I don't follow you on this point...care to expand?
Unciaa
Jul. 2nd, 2003, 4:23 am
[info]unciaa
Link

The only thing they stand to lose are new users, as most Mac users I know would never replace their Macs for PCs even if they could run some of the same software [one library does not OSX make]. From my point of view a joint library would both give developers more incentive to develop Cocoa software [hey, Macs and PCs, nothing to lose everything to gain!] and create good commercial for future consumers ["this is the quality of Mac software. Now imagine running it in a gorgous, stable OS and a much faster system"]. Think of it as modifying Ferrari tire carriage so it was compatible with Volvos. Would you prefer a Ferrari or a Volvo with Ferrari's tires? *g*
One Determined Flash
Jul. 21st, 2003, 10:22 am
[info]bratling
Link

back when macosx was more closely related to its NeXTstep/OpenStep ancestor than it now is, and was a project called Rhapsody, there actually was a plan to enable programmers to write one application which would run on both mac and windows. the project was called yellowbox (bluebox was classic mac). it really did work for a while, then apple quietly killed it.
Unciaa
Jul. 1st, 2003, 8:56 am
[info]unciaa
Link

Yep, heard of that. Damn shame.
Hugh
Jul. 22nd, 2003, 11:06 pm
[info]beansinmylap
Link

It's called OpenStep, my good man.
Brian
Jun. 29th, 2003, 1:40 pm
[info]velocity
Link

Wow, that was fun! Here's mine :D
Brian Kendig
Jun. 29th, 2003, 9:09 pm
[info]foxmagic
Link

Neat! Very nice! :-D

The Friendly Neighbourhood Technomage
Jun. 29th, 2003, 6:12 pm
[info]particle_man
Link

I love the fact that this kind of stuff survived from Next and made it into OSX. Being able to build an app like this as a demonstration for others is a powerful tool in convincing them just how powerful OSX is. I know companies still using Next apps that were built this way that the company has come to rely on so heavily that they'd have a hard time switching. If those apps can be made to run under OSX with very little trouble (and with most of the frameworks being very similar it should be easy) then I can see at least two companies I know switching to the new G5 systems as soon as they hit the market. Time to do some testing.
Allan
Jul. 16th, 2003, 8:25 am
[info]abaruz
Link

A NeXT developer can, within an hour of exposure to Apple development tools, be an award winning Macintosh developer.

A great MacHack story

One of the highlights of this year's MacHack was a complete coincidence. Duncan hints at this, but he doesn't give the full story.

A doctor named Carl (I think Williams was his last name, but I'm not sure) was staying at the Holiday Inn for some other reason. He didn't know anything about MacHack. He'd done NeXT programming on the side for years, but he'd never used Mac OS X. Well, he wandered into our little convention of Mac programmers, and in two hours the software he'd written for his wife (also a doctor) to track her patients was up and running on Mac OS X. Two hours. He enjoyed that so much that he stayed for the rest of the conference, demoing the ported code in the Hack Contest and winning an award at the banquet.

How cool is that? He went from a NeXT user to an award-winning Mac OS X hacker in just a couple of days. And that, ladies and gentlemen, is the story behind Duncan's Hacker Christmas in June.

[Eric (J Albert)'s Weblog]


Switch those companies over!
Aureth
Jul. 21st, 2003, 7:50 am
[info]aureth
Link

FYI, Brian, this was mentioned on Macintouch, today. Scroll down, it's near the bottom. :)
Brian Kendig
Jul. 21st, 2003, 8:53 am
[info]foxmagic
Link

Hee!! Neat! Thank you for the heads-up!

Hello, Macintouch readers! :-)

Andy
Feb. 18th, 2004, 7:55 am
[info]jarodrussell
Link

THANK YOU! I saw a similar article over at MacDevCenter, but it was for XCode (which is a Panther exclusive apparently). I've been trying to figure out how to do it with Project Builder. Thank you, Thank you, Thank you!
Brian Kendig
Re:
Feb. 19th, 2004, 6:48 am
[info]foxmagic
Link

Very welcome! Glad I could help!