Permalink
Browse files

Updated README : how to use #import <Lib/Header.h> and avoid to fill …

…HEADER_SEARCH_PATH
  • Loading branch information...
1 parent 76d3081 commit 7d22e774b17313b51575b9694905c592667c7db9 @AliSoftware committed Jan 18, 2013
Showing with 20 additions and 9 deletions.
  1. +20 −9 LibraryWithRsrc/README.md
View
@@ -1,17 +1,23 @@
-* [LibraryWithRsrc](#librarywithrsrc)
+Table of contents
+
+* [Introduction](#introduction)
* [Example usages](#example-usages)
-* [How to generate a clean an reusable library](#how-to-generate-a-clean-an-reusable-library)
+* [How to generate a clean an reusable static library](#how-to-generate-a-clean-an-reusable-static-library)
* [Create a library project](#create-a-library-project)
* [Integrate the library in your application project](#integrate-the-library-in-your-application-project)
* [How to generate a valid resource bundle](#how-to-generate-a-valid-resource-bundle)
+ * [Create the Resource Bundle target](#create-the-resource-bundle-target)
+ * [Integrate the resource bundle in your application project](#integrate-the-resource-bundle-in-your-application-project)
---
-## LibraryWithRsrc
+## Introduction
-This is an example of how to create a Xcode projet that generate **both** a static library **and** a _resource bundle_.
+This example demonstrate:
+* How to create a static library project correctly that is easy to integrate then in your applications
+* how to make such static library project generate a _resource bundle_ to provide ressources to your app.
-The aim of this project is to show how you can have a library that provide both functional code but also **resources like
+This shows that you can have a library that provide both functional code **and resources like
XIB files, PNG files, xcdatamodels, and even Localized strings**, without the need for you to copy
each and every single resource in your application project.
@@ -25,12 +31,12 @@ There are a lot of advantages in this practice:
with the strings needed for the library: the library will have its own `Localizable.strings` and will be able to pick localized strings
from it instead of the one from the application itself.
-Once you have implemented a simple method in your library main class that returns an `NSBundle` object that will represent the
+Once you have implemented a simple method in your library main class, that returns an `NSBundle` object representing the
resource bundle generated by the library (see demo project), you can use all the standard methods of `NSBundle` like
`pathForResource:ofType:` and `localizedStringForKey:value:table:` to retrieve those resources.
-For images, the `+[UIImage imageNamed:inBundle:]` method is unfortunately a private method, but the demo project provides a workaround
-(see the `UIImage+Bundle.h` category in the demo project).
+_For images, the `+[UIImage imageNamed:inBundle:]` method is unfortunately a private method,
+but the demo project provides a workaround (see the `UIImage+Bundle.h` category in the demo project)._
## Example usages
@@ -47,7 +53,7 @@ All you will need to do to use them in your applications then is to link the app
of course, and add the resource bundle that your project generated with the static library (thanks to a second, dedicated target)
to the resources of your app.
-## How to generate a clean an reusable library
+## How to generate a clean an reusable static library
> **Note**: this is not exactly the process I presented in my CocoaHeads presentation #12 in Rennes (17 Jan 2013) since I found this much better solution a bit later.
> Contrary to what I told in my CocoaHeads presentation:
@@ -86,6 +92,8 @@ You can now **use `#import "YourLib/Header.h"` or `#import <YourLib/Header.h>` i
## How to generate a valid resource bundle
+### Create the Resource Bundle target
+
Since Xcode 4 does not provide a template to generate a Resource Bundle for iOS, you will use the template for OSX bundles
and then need to adjust the Build Settings to adapt it:
@@ -112,6 +120,9 @@ Once this Resource Bundle target is configured:
and dependent to your static library will ensure first that the bundle has been compiled first.
* Add your resource files (PNG, XIB, Localized.string, PLIST data files, xcdatamodel, …) to your bundle target so that
those resources will be embedded in the bundle
+
+### Integrate the resource bundle in your application project
+
* Build the bundle target once, for "iOS Device" (not for the simulator). The file should then change from red (inexistant)
to black (file exists) in the "Products" group in your Project Navigator on the left.
* Select the generated bundle in the "Products" group in your Project Navigator, and right-click to choose "Show in Finder"

0 comments on commit 7d22e77

Please sign in to comment.