I'm developing a dynamic framework for iOS. This framework uses a static library, which is integrated with CocoaPods:
+--MyDynamicFramework
+--PublicHeader1.h
+--PublicHeader2.h
+--Sources
+--Pods
+--StaticLib
+--PublicHeader3.h
+--StaticLib.a
Now, I'm using PublicHeader3.h (which is part of StaticLib) in the sources of my dynamic framework, but I'd also like to expose it as a public header of the dynamic framework I'm building. So an App that uses my dynamic framework should be able to see all three public headers. Is this possible, and if yes, how?
Build Settings -> Header Search Path -> Add PATH of MyDynamicFramework/Pods/StaticLib
Related
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.
I have a framework that links against two static libraries. Each static library is a target and the framework is a target. The framework wraps the static libraries and clients of the framework only care about calling framework code (which in turn may call code from each static library). Is is possible to have the framework include the required headers and object files? When I build I get the infamous Include of non-module header inside framework module error. Each static library exports its headers and I've added the headers as public headers in the framework. Still no luck (and I would think there's a solution that doesn't require this).
Each static library must export a module.modulemap file with its headers. Contrary to popular wisdom, once this is complete, you need not add a bunch of headers to the Public section of the framework's Headers build phase in order to alleviate the error. The process is described in detail here: https://bjhomer.com/2015/05/03/defining-modules-for-static-libraries/
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.
I am builiding libraries in iOS, for that i want to access variables from my iOS static library. To do this, is it necessary to declare variables used in my library class as public variables?, so that I can access variables from my library class from another application?
If so, how to declare variables as public in library class? If not, is there any other method to access variables from library in client application?
If the headers are copied in the Copy Files build phase, then their symbols will be available to the client application which links your static library. This build phase is created automatically for you when Xcode creates the static iOS library project.
If you wish to exercise more control over which headers are public and which are private, then you'll need to create separate copy headers build phases for public and private headers and manually move header files between those build phases. You'll also need to adjust the header search paths. This blog post may help with those implementation details.
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.