views:

2816

answers:

5

I would like to create a framework for some reusable code that I would like to include in other iPhone apps. What is the best way to do it? Ideally, I would like it to work just like builtin frameworks and have the app use it without mucking around with build files.

A: 

I have been thinking about the same thing. So far all I've been able to do is make one project just the way I want it and copy it to another folder to start a new project. Then I rename the .xcodeproj file and open that. Then I customize the basics (icons, default.png, the target, the executable) before building the new app.

It's clunky, and NOT the way code reuse is supposed to work. I'm sure there are better solutions. Maybe some clever use of source code management / version control? Maybe something built into XCode? Other ideas? I look forward to seeing more posts here.

Alan
+7  A: 

Apple prevents the use of custom frameworks on the iPhone. But you can use good old static libraries. In the 3.0 GM SDK there's even a project template for that, but you can also simply set up a static library target yourself.

Nikolai Ruhe
+2  A: 

Please see the following link for how to construct an iPhone Framework from an iPhone static library:
How-To Construct iPhone Framework Bundles For Cross-Compiled iPhone Libraries

Michael Aaron Safyan
Excellent write-up! You helped me a lot. I tweaked it a little bit and will try to make your script a part of my build-phase.
Felix
A: 

@Nikolai Ruhe - where exactly does Apple forbid use of custom frameworks on the iPhone? I have read through both the iOS Developer Program License Agreement and the App Store Review Guidelines, and cannot seem to find any mention of such a ban.

I don't see why Apple would allow the use of custom static libraries, and forbid the use of custom frameworks. Perhaps I'm missing some other legal document?

Vladimir Mitrovic