I am building a cocoa touch framework and including in my code third party framework - "framework_X"
How can i use it in a way that "framework_X" will not be linked directly to my framework, instead it will require the consumer project which use my framework to link "framework_X" to his project in order for it to work.
In Android this is done easily, but in Xcode if i am not linking the "framework_X" in my framework the project won't build
You can load libraries at runtime. Here an example of loading zlib with dlopen():
https://github.com/nicklockwood/GZIP/blob/master/GZIP/GZIP.m
Related
I have few components written in Objective-c and Swift.
When I want to use it in any react native project, i will manually copy those native components and creating a bridge.
Now i want to use the same components in multiple projects, so i'm thinking of putting all those native components along with bridging part into one framework.
To start with i developed a simple framework with a simple native view..as below
When i try to run ComponentTest project, frameworks fails to build with error saying RCTViewManager.h is not found. I'm sure this dependency will be available in all projects which uses my framework.
ComponentTest/node_modules/tmobcomponents/ios/TMobileNativeComponents/TMobileNativeComponents/components/SimpleView/SimpleViewManager.h:12:9: Include of non-modular header inside framework module 'TMobileNativeComponents.SimpleViewManager': '/Users/someone/Library/Developer/Xcode/DerivedData/ComponentTest-auqzutioszphtnhfizcfhndibnnl/Build/Products/Debug-iphonesimulator/include/React/RCTViewManager.h'
Is it possible to build a framework without adding ReactNative dependency in framework, because React native dependency(RCTViewManager) will be available in the project which uses my framework.
How to accomplish this (Native views and also bridging part(native) ) should be in framework
So, I've been struggling for some time with embedding a third party framework into a Flutter plugin I'm writing for iOS.
The plugin is fairly straightforward, mostly just forwarding calls and events to/from the third party framework.
The third party framework in questions is for controlling a Sphero robot (RobotKit.framework).
This particular framework is an umbrella framework, with several sub frameworks within.
To include this .framework in my plugin, I've tried a lot of combinations between
preserve_paths
vendored_frameworks
resource
xcconfig
in the .podspec file to link to the RobotKit.framework package (inspired by blog), but without luck.
I can use
vendored_frameworks = 'Frameworks/RobotKit.framework'
to get Xcode to detect the package and import the headers, but when building I get an error linking to a header in one of the sub frameworks (RobotKitClassic is a sub framework):
fatal error: 'RobotKitClassic/RobotKitClassic.h' file not found #import <RobotKitClassic/RobotKitClassic.h>
Am i approaching this the wrong way, or is there a trick that I'm missing?
I ended up working around this by implementing the plugin functionality directly in my main app project instead of in a separate Flutter plugin.
Doing this, i can add the RobotKit framework to the Runner project and it links, builds and runs just fine.
IF your case is nested frameworks to use the result in app then nesting frameworks isn't allowed in IOS , here from apple forums , I faced error like can't load frameWork #rpath to do this all code in dynamic framework must be pure code not pods or plugins
They asked me to create a cocoatouch framework that bundles all off our 3th party frameworks. So that we can use that framework all over the company.
Now I think it's better when you make the application responsible for adding the dependencies that your framework need but this not possible here.
So I created a framework added some frameworks like PureLayout.framework, etc.. and added them to the linked frameworks and libraries.
It compiles and delivers a .framework but when I add that framework to the project and run it, then I get this error:
dyld: Library not loaded
Reason: image not found
So I think they are only linked against and not embedded in the framework.
How can I really embed them?
I am trying to create a cocoa touch framework out of my existing app so it can be embedded in other apps via a simple drag and drop.
The thing is my app uses a lot of libraries and have been using cocoapods to manage dependencies.
I already know how to build a simple framework but I couldn't find a source that talked about how to turn a complex project with lots of dependency into a framework.
Questions:
Is it even possible to achieve my goal (Package my own code and all the libraries it depends on into a single framework that can be easily embedded into other projects)
if yes what's the right way to do it?
Assuming all of the above were resolved, what happens when the parent app also contains some of the same libraries that are being used in my framework?
Imagine the following scenario;
I'm developing a cocoa touch framework that requires SomeLibrary (e.g. AFNetworking). My framework is going to be included into someone's project that might require SomeLibrary as well.
How do I accomplish this without running into these nasty duplicate warnings when I include AFNetworking into my framework directly (either via source code or Cocoapods)?
I've tried it with Cocoapods on both projects (my framework, and a test project that includes my framework), but that results in duplicate code warnings as well.
When I don't add AFNetworking into my framework development project, the compiler can't find the required files, which is why I can't build it. I've tried with including AFNetworking's source code directly into the main project, and using the pod, but in both cases the AFNetworking/AFNetworking.h import in the framework project fails.
How can I do this without making a pod out my framework (which isn't really an option)?
I've found this related answer, but I don't know what search path to set for the framework project in order to find a library of the master project;
https://stackoverflow.com/a/23123725/1069487
Any help would be highly appreciated!
You will have to build your framework linked against static library.
You build AFNetworking as a static library (that will give you a .a file as AFNetworking.a)
You build your framework that link against your static library. But be aware that the library won't be embedded in your framework (there is no way to include static library into framework on iOS). Your framework is able to use AFNetworking API because it is linked against it.
any project that use your framework and use AFNetworking methods of your framework need to link with the static library AFNetworking.a that you should provide as a standalone file beside your framework.
See iOS-Framework here for more details : https://github.com/jverkoey/iOS-Framework