I've been struggled to create a custom swift native module for react native. I wrote a bridge files to wrap the native module (which is in swift). This native module also has dependencies from cocoapods. Since react native module that I am working on, has to be linked with native module (to clarify, react native module A has a native module dependency B which can be installed by cocoapods), I have to use something like B-Swift.h (created by Xcode) in the react native module for objective-c project. The problem is I cannot find a proper way to configure header file in this situation. I was able to properly link everything together with carthage though.
I would appreciate for any advices.
Related
I had react-native 0.63.4 and updated to 0.71.2. My native module doesn't work on react-native 0.70+. I tried different versions of RN.
I started a new turbo native module and moved my native code to the new module. On android it works very well, but on ios the code don't compile because my module has been written with pure Objective-C (.m extension)
Is there any solution to use my old file.m instead of the new file type file.mm?
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.
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
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.
I am developing a React Native Module that includes our Framework 'AntaviSense'.
I am able to include the framework in the main project and by "embed framework" in the Project Settings, everything works fine.
React Native Module
Adding to main project works
My question though is: can I avoid changing the main project, and just include it into the React Native Module project (which is a subproject)? I tried various directories in "React-Module/Build Phases/Copy Files" without luck. This would make the inclusion into other projects much easier.
node-xcode could be an option, it enables you to parse an modify XCode projects, I am not a React developer but you could create a node-script which modifies the project and adds the framework when you add the module (in cordova this would be a hook, maybe there is something similar in React).