简体   繁体   中英

iPhone - Using a static Library?

I created a static library project which generates an "a" file. I included this "a" file to another project as a static library.

The only way I could use the classes in this static library was to copy all header filed over as well as the "a" file.

Is it possible to avoid copying the header files, and still be able to use and import classes from this static library?

Not really, you have to declare the functions somewhere visible to the caller. Header file is the most convenient way to do it, because it provides an interface. A possible approach is to merge those headers into one .h file, so you provide a single and complete interface with your library.

The only other approach I can think about is declaring the functions in the files where you call them, but this is much more devastating and error prone then including a header file.

The best option I could find is here:

http://www.cocoanetics.com/2010/05/making-your-own-iphone-frameworks-in-xcode/

...basically, you can jump through a few hoops to package your static library as a Framework. The Framework will create an internal copy of your header files, so you get access to them automatically when you include it in your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM