Custom Framework Always include in Embedded? - ios

Custom Framework Always include in Embedded Section is there another way instead?

You must embed dynamic frameworks, because they are based on a shared library, and shared libraries are loaded at runtime. You could create a static framework wich contains a static library. Static libs are linked at build time, and thus they must not embedded into your app.

Related

IOS : 3rd party dynamic framework inside a static library

Is it possible to embed a dynamic framework inside a static library in such way that when using the .a lib in other projects, there is no need to use link framework/embed binaires.
So using the framework inside the static library just by using the header name.
If so, how is it done?
THANKS.

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.

split an existing iOS app project into static library and app skin project

I would like to split an existing iOS app project into one static library and one app project.
Since the existing app project has been copies multiple times into brand new instances with different resources(graphics, icons etc) and settings.
I find it's hard to maintain across difference instances once the core project has been updated.
So i'm turning the core project into a static library with model, views and third party libraries.
the other project contains the app part which only contains customised resources and app settings.
the problem is how can the classes in the static library getting the app settings from the app project and the main app project calling classes in the library.
any good practise and tools for that?
The main app project can make use of your static library classes through exported header (.h) files. I would recommend reading a bit about them here:
http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html
And creating the static library here:
http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/
As for providing the app-specific settings to your static library, it sounds like your static library might need to contain a ApplicationSettings protocol or similar, that can be provided to the static library for any calls that require it. Your protocol could define getters/setters for any known properties your application possesses.
#protocol ApplicationSettings
- (BOOL)isUserReallyAwesome;
- (void)setIsUserReallyAwesome:(BOOL)awesome;
#end
Then you can either configure an instance of this object statically, or you can provide to each static library method that requires it:
- (void)someStaticLibraryMethodWithArg:(NSString *)arg settings:(id<ApplicationSettings>)settings { ... }

Undefined symbols to framework when building application separated to library and application part

I have application separated into library part and the Application which links with the library.
Library uses AFNetworking, and thus requires SystemConfiguration and MobileCoreServices frameworks. They are added to build process and library builds nicely.
Why I need to add the same frameworks to my the Application part in order to build properly and not to see linking errors?
Is it not enough to link only with library?
I assume the library is a static library. You are only adding the frameworks when building the static library in order to access the include files; you are not linking with the frameworks. This is because a static library is not linked when it's built; it's simply a collection of object files. Try this from the command line to list the object files:
$ ar t /path/to/my/library.a
When the static library is linked with the app binary you must provide the libraries and frameworks of both, just as if the object files in the static library had been part of the app binary source tree.
Just think of the static library a simple collection of object files and it should make sense to you.
Apple's iOS frameworks contain dynamic shared libraries. AFAIK, when our app launches there is a process which gets created and dynamic shared libraries that the process is linked with gets loaded in to the memory. If the dynamic shared libraries are already loaded in the memory(for some other app process), they are shared with our app process. This is per process activity.
Since the static library is linked as part of the application binary itself and does not create a separate process, it becomes necessary to inform the runtime to load the frameworks that the static lib links with. Hence it is logical to add the frameworks used by static library in the application as well.

How to create static library from an existing framework in iOS?

I have been provided with a framework by a third party vendor for an iPhone hardware accessory. So I have a folder like Device.framework. Inside that folder is a binary file and a set of .h files. There are instructions for how to add this to an iOS project and use the classes contained within. However, I'm actually using MonoTouch and want to use a static library.
Is there a way to create a static library that makes all the classes from the framework available in the static library? So in my MonoTouch project I would link in the static library and have access to that framework.
A *.framework is simply a package containing: the static library, headers, associated meta data. Copy and paste the .framework and extract the static *.a file and related header files.
Then it's simply a matter of using the MonoTouch btouch tool to bind the static library for use in your MonoTouch project. There is a great example of how to bind a native library to MonoTouch on Github. With guidance on targeting simulator + device and using the LinkWith attribute to embed the static library in a single *.dll:
https://github.com/xamarin/monotouch-samples/tree/master/BindingSample
Also, make sure to check out the btouch Reference documentation here:
http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types
Rename that binary file to Device.a. You can do that as the framework you mention is not done by Apple, hence it has to be a static library and not a dynamic one.
Make sure your project links that library (Device.a).
Include the headers in your project and reference them where appropriate.

Resources