Framework for xcode static libraries

I just added a linked library to my project using the question here The process of linking ObjC static libraries to Xcode and the document related to the answer.

I know that the library uses CoreData objects, such as NSManagedObject, although in the xcode project of the library the CoreData structure is not added and created without errors. However, when I create my application, it has several errors, such as:

Undefined symbols:
"_OBJC_CLASS_$_NSManagedObject", referenced from:
  _OBJC_CLASS_$_AClass in library.a(AClass.o)

Thus, after seeing all the errors mentioned in the CoreData objects, I added the CoreData base platform to my application and successfully created it. So, now I tried to remove the CoreData environment from my application and added a library project, and they built both, and that failed.

So why does this work when coredata is added in my project, but not in the library project, and only the library uses it?

(and why is a library built without its own coredata framework?)

+3
source share
2 answers

The library is static. This is not a separate piece of code; it must be connected.

Your application is connected, which means that the linker resolves all external dependencies and populates the library function addresses in the final executable.

If you want to use the Core Data dependency library in your application, you must set the link to Core Data.framework.

Adding a linking stage to a static library has no effect, since there is no linker in creating a static library, but only a compiler (and an archiver).

+3

, @import . , .

0

Source: https://habr.com/ru/post/1794716/


All Articles