Main app can't reference framework used in React Native Library - ios

I need some advice about building react native library that using framework. I'm trying to build one using this library. My react native library contains these files:
Sample-Bridging-Header.h
Sample.m
Sample.swift
Sample.xcodeproj/
Utilities/Utility.swift
Utilities/Helper.swift
Test.framework
Inside my Utility.swift and Helper.swift, I import library Test and there is no issue there.
However, when I build the sample app which uses the library, it will not build and it gives the error no such module 'Test'.
So it looks like if the main application try to use the react native library, and if the library uses a framework, the main application can't reference the framework. I'm not sure if this is the right approach or not.
I built react native library before and it worked for me but I never have to reference any framework.
Appreciate any help! Thanks!

Actually I just figured out how to handle this. I just need to update the podspec to include the framework by using s.ios.vendored_frameworks = ios/Test.framework.
Once I did that, I run pod install again for my example project. So now it can pull the framework in properly.

Related

How to use GoogleMaps in local Swift Package?

I'm trying to build an iOS Application which provides AppClips. This means I need to put my code into modules so that the AppClip can reuse some of the code from the main application. The reusable part is using GoogleMaps and that SDK is not yet available via SPM. There is a third-party-fork which makes it SPM-compatible and it kind of works, but it wont let me upload the build because the GoogleMaps SDK gets imported/linked multiple times. Also there is some kind of error stating that it is not "inside the framework folder".
Can anyone provide a solution as to how to use GoogleMaps inside of a local Swift Package? I'm even fine with some kind of hack, because I still hope Google will provide SPM support soon.
So is there a way to use cocoapods or carthage pods or whatever inside a local Swift Package?

How to write IOS framework for react native components

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

React Native Bridge Library for existing Objective C Framework which depends on other iOS Frameworks

I have an Objective-C Framework, which depends on other third party Frameworks through CocoaPods.
i.e A-->B,C,D
I created a react-native-create-library bridge which wraps the code around Objective-C Framework A.
i.e React_Native_A-->A-->B,C,D
I tried creating an example app Example_React_Native_A which links the React_Native_A using the react_native link command. Hoping that it links to the other frameworks added using the CocoaPods.
Unfortunately, this doesn't work in this way. It won't even consider React_Native_A-->A link.
Is there any other way to generate the example app, so that it can link all the required frameworks i.e A-->B,C,D.
If anyone looking for the solution, the way is mentioned in the RNNearBee.podspec here. The wrapper podspec depends on the version of the react as per the local machine installed version and then it depends on the original native podspec.

How to add a local framework to a Flutter plugin for iOS

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

iOS8 framework library linking WITHOUT Pods

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

Resources