Objective-C: How to make a Framework?
I'm new to Objective-C but has a lot experience with Java and .NET.
I'm trying to add EGOPhotoViewer to my iOS 5 project in Xcode 4.2.1. But I get a lot of release, dealloc, retain etc. issues while compiling their code, since I'm using Automatic Reference Counting (I think!).
How can I create a class library, framework or what it is called in Objective C for their code, that I can add to my project?
EDIT: I've done the approach from JeremyP by inserting the code with a new target. I compiled in the beginning, but after a while I get this compile error:
Undefined symbols for architecture i386: "_OBJC_METACLASS_$_EGOPhotoViewController", referenced from: _OBJC_METACLASS_$_PhotoViewController in PhotoViewController.o "_OBJC_CLASS_$_EGOPhotoViewController", referenced from: _OBJC_CLASS_$_PhotoViewController in PhotoViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anybody know why?
You can't create frameworks for iOS. You can however, create static libraries using beryllium's technique. You can also add a static library to your existing project using File / New / New Target... Obviously, once you create the target you can change the Objective-C automatic reference counting build setting to "no" for your new target.
I thought it was possible to turn ARC on and off at the source file level, but I can't figure out how.
For your purpose, a regular static library as described by beryllium would do fine.
Just for unashamed plug purposes and for spreading the word, this document describes how to create versioned, documented frameworks using Xcode, GIT and DoxyGen.
The main purpose of creating such frameworks is to redistribute them. I personally find it extremely annoying to manually include libraries and headers I receive from third parties - especially if the libraries are delivered in separate versions for simulator and device. That guide is meant for classic middleware developers. I have written it to allow people like those folks from Google Analytics to finally provide something worth their brand.
This document gives you a step by step explanation, bundled with loads of screenshots.
Open Xcode -> File -> New -> New Project -> Framework & Library -> Next -> Type Name, Choose Folder -> Create
It will be a library called yourApp.a. You can find it in Derived Data folder