Create ios static library with with more classes - ios

I want to develop iOS static library and distribute to other developers.
I have started some R&D and found only one way to create static library with only one class which is having header file and implementation file.
I would like to create static library with more individual classes. Now we are creating static libraries with only header files and implementation files.
Is it possible to add XIB files also to that? Can anyone guide me to solve this requirement?

As you are saying, you have created static library, then you just need to add more files. Suppose you can want to make some file to make public to developers then you need to make it public scope.
This may help you... http://www.blog.montgomerie.net/easy-xcode-static-library-subprojects-and-submodules

Related

How to prevent exposure of methods and header files(.h) of other library

I’m creating one framework, which is using another third party static framework (has .h file, which contains public methods) and I don’t want to expose the header files(.h), code, methods and classes of that library to the user of my library.
Any ideas will be very appreciated. Thanks.
Easy to control header file visibility in Build Phases

is there need of static library to create framework?

Is this necessary to create static library for creation of framework or we can create it without help of static library what is diffrence betwwen them.
You have two options for creating framework, one is static library (code is linked at compile time) and iOS8 onwards dynamic framework(code is linked at runtime). Refer to following answers for knowing the difference between them :
Library? Static? Dynamic? Or Framework? Project inside another project

iOS: Can i create a static library with all classes (.h & .m) as public?

I have a bunch of classes that i want to share with others so i thought of creating a static library but i don't want to hide my code. I want to allow them to put change in the library if they want to.
I can share a folder of files but i want to merge all the files into a single package so it's easy to manage and maintain.
Static library generally shows only header (.h) files to users but is it possible to make implementation (.m) files also visible?
I've one more static library which is a dependency for this one. Can i put one static library inside another? or i have to add both files in my project?
I didn't do this library stuff before so am i going in a right direction? or is there any more appropriate way in iOS that can fulfil my requirement?
Thanks!
Ship the code as a framework and instead of sharing a folder, turn the library into a regular project on GitHub or anywhere else. Add what’s needed to install the library through CocoaPods or Carthage. Make proper releases with semantic versioning, write a proper Changelog.
It’s a lot of stuff to go through for the first time, but it’s a good practice that will pay off. See my simple goo.gl client for an example of such library.

xcode static library public/private/project header files

So, I have an iOS app project with a static library as subproject. As found multiple times here on SO, you should set the visibility of the library header files to public/private/project, depending on who should be able to use them.
Based on that, I created one class with a header file that exposes functionality to the app project (or whoever is going to use this library). Naturally, this header file imports a number of headers from other classes inside the library project. As these other header files do not provide functionality that should be exposed to the library's users, i would like to set these to "project", making them invisible to the rest of the world.
However, when i set header files to "project" they don't get copied into any of the private or public header folders. This results in a 'ProjectHeader.h' file not found error when using #import "ProjectHeader.h" in the PublicLibraryClassHeader.h when compiling the app project that uses the library.
So the question is: How can I set header files to "project" in a library project and stil use them from within that library project? Am I misunderstanding the concept of public/private/project header files in static libraries?
The easies way is to convert your static library into framework. Framework is a static library in a specific container, that does all magic for you. Btw, this words about public headers are related to frameworks, not to static libraries.

Exposing methods in iOS static library

I want to expose only selected methods inside my Static library to classes outside.
Is there a way to do it?
This is impossible the way Objective-C works. The best you can do is not publishing those methods by declaring them in an internal header (either in a class continuation or a category) which you don't give to the user of the library. Using tools like classdump or the runtime APIs those methods still can be found and called.
Here's on approach to do this:
Take the methods you want to be private and put them in a separate category. E.g. MyClass+PrivateMethods
Make sure these MyClass+PrivateMethods.h files are not included in the Public part of the copy headers build phase, so they can't be seen by those who use the static library. (Make sure you understand the three different options for Copy Headers - Public, Private, and Project).
#include these MyClass+PrivateMethods.h files where you need them within implementation files (.m) of your static library.
Profit.

Resources