iOS create two static libraries with method in one library invoke method in another library

StackOverflow https://stackoverflow.com/questions/22088755

  •  18-10-2022
  •  | 
  •  

Question

Recently, I have seen a case: I downloaded two static libraries, called lib1 and lib2. I only imported lib1 to my project, and its associate .h file, and invoke a method in this .h file. But when I build my project, the compiler told me that I must import lib2 too.

My question is: If I create libraries myself, how can I reach the same thing? In my opinion, if lib1 depends on lib2, and if the method in lib1 invokes methods in lib2, the lib1 itself must import lib2, doesn't it?

Any advice can be a great help, thanks sincerely!

Was it helpful?

Solution

If lib1 depend on lib2

say for an example lib2 has 2 classes in it out of which you need to use one class. Just add only the interface reference(Only the .h) not the whole library.

Reason behind when you build a library you are just compiling not running the app. So when the time of compilation. compiler look for interface only not the implementation.At the time of your application compilation both lib1 and lib2 need to be added.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top