How to run legacy native module with react native 0.70+? - ios

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?

Related

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

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.

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

How to make swift native module in react native using cocoapods

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.

Unity Export IOS Project

I have a problem about Unity for IOS, Details as following:
I export the IOS native project from Unity, and then I copy the project file to another IOS native project,but there were many errors,like this:
It appears these libraries are missing. Installing same version of Unity iOS should fix this. Check your project structure as well https://docs.unity3d.com/Manual/StructureOfXcodeProject.html Is the iOS version same on both platforms?
Edit: You are either missing some libraries required, the structure of your project is not right or you are running different versions of unit. Download and install same versions of unity on both platforms. https://unity3d.com/get-unity/download.
Test run the following code in your other IOS native project:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void Start() {
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
}
Share the results of above script.
Unity is supposed to be platform independent but the code may break on different versions, what unity versions are you using?

Xcode: Embed Framework in React Native Module without modifying application project

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).

Resources