I am trying to develop a framework out of my existing code base so that it can be used in another app. My app uses Core Data to save some of the data. Now my doubt here is, can we include classes which contain Core Data methods in my framework.
2 Answers
Yes.
As long as you require that any app using your framework must also include the CoreData framework - put it in your documentation / installation instructions.
Otherwise it won't compile :)

- 38,189
- 13
- 98
- 110
-
Actually i have created a framework and included that in a new project. I am able to import the new frame work but i am not getting any response when i call the methods in the framework. So, i thought may be core data classes are causing some conflicts here..DO u have any idea on why i am not getting response when i call these methods. Thanks – A for Alpha Dec 08 '11 at 15:58
-
So, your question should be __why don't my method calls work in my framework?__ :) Ask a new question on stack overflow and post your code :) – deanWombourne Dec 08 '11 at 16:03
-
well dean... i already asked the same question before posting this.... :) http://stackoverflow.com/questions/8427285/methods-in-a-framework-not-responding-to-method-calls...... But, i dint get much of a response from that.... :( – A for Alpha Dec 09 '11 at 06:04
-
There is not much of a code there dean. i imported the framework, created the object by allocing it and then called a method in that framework.... And that method in the framework contains nothing but an NSLog statement.. – A for Alpha Dec 09 '11 at 06:07
Just to add to Dean's answer. It's worth advising against any temptation to include the Core Data framework within your new framework. A framework that includes another framework is known as an "Umbrella Framework".
In the Framework Programming Guide, in the Guidelines for Creating Frameworks, they state:
Don’t Create Umbrella Frameworks
While it is possible to create umbrella frameworks using Xcode, doing so is unnecessary for most developers and is not recommended. Apple uses umbrella frameworks to mask some of the interdependencies between libraries in the operating system. In nearly all cases, you should be able to include your code in a single, standard framework bundle. Alternatively, if your code was sufficiently modular, you could create multiple frameworks, but in that case, the dependencies between modules would be minimal or nonexistent and should not warrant the creation of an umbrella for them.
As Dean says, you can document the dependency - for example - in your new framework's README file.

- 26,115
- 13
- 104
- 132
-
yep I'd go with Dean's comment and ask a new question with that title. You should be able to add some NSLog statements to find out what's happening in your framework. – Max MacLeod Dec 08 '11 at 16:08