I cant import React BridgeModule on header file - ios

I am working on a node module that integrates with a native react app. I need to implement in the iOS project the functionalities of the node module written in "swift" and make it available in react. It turns out that when I try to import "RCTBridgeModule", it doesn't exist. I tried various "solutions" with no results.
I clarify that I have changed the name of the xcodeproj (the node module's iOS project) since it collides with the name of a framework that I plan to add.
Honestly, this problem gives me a headache and I don't have much experience with iOS development environments.
Xcode: Version 12.0.1 (12A7300).
Attached screenshots of some files and settings:
Thanks in advance!

Related

Convert swift Xcode project into importable cocoapods

I have a Xcode project and it's running well.
But now I want to convert my Xcode project into importable cocoapods, so I can import same cocoapods in multiple Xcode project and create new separate app with same features. (by changing some UI configuration only)
(Basically, I want to move whole app/project into cocoapods, including storyboards, assets and all files. so I can create another similar app by just re-branding UI)
Can someone please help me how to configure and setup for this kind of structure?
Thanks.

Xcode 9 not finding React Native 0.56 or 0.57

I was working on my first React Native NativeModule. A simple 'Hello, World!' Objective-C function just to get an idea of how it worked. Things were going relatively smoothly, however, it seems xcode lost reference to all React Native files. I thought this problem was probably project specific, so I started a new TestApp using react-native init TestApp, but when I open that .xcodeproj file I have the same issue.
The first error in this new TestApp is in the AppDelegate.m file: 'React/RCTBundleURLProvider.h' file not found but as you might expect it avalanches from there.
I spent the most of yesterday trying out all sorts of potential solutions to no avail.
This might be a false lead, but maybe not, however I noticed Header Search Paths is empty whenever I first open .xcodeproj on a newly initialized project. That being said, I have tried numerous search paths based on answers I have found here on StackOverflow, GitHub, etc, the latest being $(SRCROOT)/../node_modules/react-native/React
I know this problem might be a little vague, but any help would be greatly appreciated. As an iOS developer, I am trying my best to be open to React Native, but continually running into issues such as this is really putting a damper on that.
Thanks!
ps. At this point I wonder if reinstalling xcode, node, npm, and react native altogether would be the surest solution.
Edits for clarity
First I run react-native init TestApp and cd TestApp followed by npm install. I've tried running react-native link at this point as well.
I then open ios/TestApp.xcodeproj. After xcode does its usual indexing I will inevitably be greeted by a red 'React/RCTBundleURLProvider.h' file not found in AppDelegate. Sometimes 'React/RCTRootView.' file not found' happens too. Most of the time, even if this second warning doesn't happen, The RCTRootView * in didFinishLaunchingWithOptions is not colored.
If I try to create a native module like so:
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#interface Test : NSObject <RCTBridgeModule>
#end
I get an immediate 'RCTBridgeModule.h' file not found.
In other words, Xcode is not finding anything RCT. Autocomplete doesn't suggest anything RCT.
Even with these warnings, I can run the app from Xcode or by running react-native run-ios.
This extra bit, may or may not be relevant:
If I have import { NativeModules } from 'react-native' in my App.js, NativeModules turns out to be undefined.
My current feeling is that there is a crucial step in set up that is not listed in the RN Docs, and for some reason other tutorials aren't touching either. I tried on another computer to the same result.
"Header search paths" being empty is perfectly normal. RN is exposing its headers from the React project. If you go to React.xcodeproj (under Libraries) you can see that the React target has a "Copy Headers" Build Phase, and these headers are being exposed when packaging the library as public headers.
To make sure that your app can use the headers, go to your app's scheme and into the Build section - the React target should be in the list and before your app's target. Also, the Parallelize Build checkbox needs to be OFF. It should be set-up like this out of the box in new RN projects, but maybe something was changed in your project so it's worth checking.
When the build is just starting, and especially on a freshly initialized project, you can expect to see some errors in the IDE during the build regarding public React headers, but they should be gone and resolved once all React third-party libraries finish building and React itself is packaged.
If everything is set-up correctly and it's still not working, delete the DerivedData folder and build again.
Finally linking native code with react-native!
So, I haven't really solved the precise issue, but I managed a workaround.
Previously I was trying to initialize a react-native project and then modifying the Xcode project that was built in the initialization.
I decided instead to approach the problem from the opposite angle of linking react-native to an existing xcode project by following this documentation: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
I've been able to repeatedly link native code (both swift and objc) to react-native after react-native init TestApp by erasing the contents of TestApp/ios and following the process in the link above.
Thanks #Artal for providing some valuable info on the way it is supposed to work.

Developed a framework, Cannot load underlying module for 'x'

First I have did tons of researches on this issue. Non of existing solution similar to my issue.
I developed a framework. It is a pretty heavy framework which include a c++ static library and contains both objective-c and swift codes. I have created a sample app that imports my framework to mimic the behaviour of people can using my framework.
I put the framework under a libs folder of the project. I have make sure the framework is under Embedded Binaries and Linked frameworks and Libraries. I have also make sure that the path to libs folder exists under Framework Search Paths and Library Search Paths and User Header Search Paths.
Now When I run the sample app using my actual device and running on the computer that contain my framework project file, it works perfectly.
However If I run the sample app using simulator devices, it told me No such module x
Moreover If I run the sample app using my actual device and running another computer that I didn't use to develop my framework project, it shows error Cannot load underlying module for x.
Has anyone had this problem before? Any hint would be appreciated.
(I have also tried clean, clean build folder, clean Derived Data, restart Xcode, restart computer etc.)
Solved problem by setting Defines Module to No

How to add unity project in a currently existing ios project?

I have searched a lot about this. But all the answers suggest that, it is possible to add new files into unity(xcode) project but vice versa is not possible. Actually, my target is to create sdk which will be used in a cordova plugin. What should I do?
To create an iOS sdk for unity you can create a library project in xCode and import the build to unity's Assets/Plugins/iOS folder. everything in here will automatically get included in xCode project generated by Unity.
And yes, it's very hard to include unity build in your own xcode project. There have been people begging for enlightenment to integrate Unity in another app but every time the threads are stranded beyond hope. Gibberish-gibberish... It's not possible.
It's extremely frustrating but it is possible. It requires a lot of changes to the build settings and compiler settings as well as customizing the launch of Unity components.
Best place to start is to import the Classes, Libraries, and Data folders (if applicable). Data as a folder reference and not a group. I'm also assuming your Unity project output is similar to what I've been given. We've modified our main.m file to be a C++ file (main.mm) and added in the Unity initialization code. We also updated the UnityAppController.mm file to not run startUnity on launch.
If this is still something you're working on please feel free to contact me on Twitter (#Ruprect) and I can help troubleshoot.
In this repo: https://github.com/jiulongw/swift-unity you can find how to integrate Unity Project into Xcode Swift Project.

XCode how to know SDK Version Used to create older project

Is there any way to find which SDK used to create the xcode project. Actually I have source code for the project but not aware which SDK used to create that project. The problem right now I am facing is using the latest SDK the xcode shows some reference error with an external library which is linked by the project. And these libraries are compiled at the time of the project created.
And I am thinking like, if I use the same SDK which is used to create the project at first time, the linking problem will not happen, and I can start working with the project. Please correct me if I am wrong.
Thanks and regards,
Haris

Resources