Mastering Xcode 4 by Joshua Nozzi

Mastering Xcode 4 by Joshua Nozzi

Author:Joshua Nozzi
Language: eng
Format: mobi, epub
Publisher: Peachpit Press
Published: 2012-02-15T10:00:00+00:00


* * *

Tip

The WebKit.h header is an “umbrella” header that includes any other headers in the WebKit framework. Referencing this header includes all headers from WebKit.

* * *

That’s it. Run the application. You might have to fish around for the second window (look behind the one you’re familiar with), but it should be waiting there with Google loaded and ready for a search (Figure 15.5). Go ahead and try it out.

Figure 15.5 A working WebView showing Google.com

Negative Reinforcement

Now break it. To prove that the power to use a Web view comes from linking against WebKit.framework, unlink it. Navigate back to the TestApp target in the project, and then remove WebKit.framework from the Link build phase. Try running the app. I dare you. The app should terminate on launch on signal SIGABRT and spew a bunch of messages and a stack trace into the debugger console. The most interesting console message is the second one, that mentions “cannot decode object of class (WebView),” which is a good indicator you’re referencing symbols from a library that hasn’t been loaded (usually because you haven’t linked against it). To fix it again, just add WebKit.framework back into your Link build phase.

Third-Party Framework Example

Third-party frameworks require a little more work to use. Since they aren’t a part of the operating system, they must be distributed with the application. The most common way to do this is to embed the framework inside the application bundle so that it goes along for the ride when the user installs your application.

Adding a Framework to the Project

Most third-party frameworks are open source and many must be built before they can be used in your project. For this example, you can download a simple (and almost entirely useless) framework called Foo.framework from this book’s Web site. The direct download URL is http://files.xcodebook.com/fooframework/FooFramework.zip. Download the file and unzip its contents. You should see a folder titled Foo.framework.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.