Doug Smith
Doug Smith

Reputation: 29326

Is it possible to include frameworks in a project that outputs a ".a" library?

I have a project that compiles into a library .a file, and it's working great but when I try to add a framework like CoreBluetooth to the project, when I build the library Core Bluetooth doesn't come along for the ride?

Is this not possible? When I import the library into a project do I have to include Core Bluetooth separately?

Upvotes: 1

Views: 113

Answers (2)

Putz1103
Putz1103

Reputation: 6211

I have this same problem. My static libraries utilize many Apple frameworks. But linking the library project against these frameworks does not link the frameworks into the project that use the library.

It's pretty much exactly like static library resource bundles. They need to be linked into the main project that includes the library, not just in the library its self. So if you use the frameworks in the library you need to make the main project link the frameworks too (you actually don't need to link the frameworks into the static library project at all).

Static libraries code is called from the main project directly. As such if the library uses framework calls the main project needs to know about them. It would be nice if static libraries could be self contained like that, but it's not currently so.

Upvotes: 0

trojanfoe
trojanfoe

Reputation: 122458

You'll have to include CoreBluetooth in both the static library project (for include files) and the final binary project (for linking with the framework).

Static libraries aren't linked, so they can't take CoreBluetooth "along for the ride".

Upvotes: 2

Related Questions