React Native, iOS, trying `yarn run ios` and I get RCTAppDelegate.h not found - ios

Trying to build a React Native iOS app, and while I got it running fine using Android, trying to get it running on iOS has been a bit of a nightmare.
I created this base react native app, back in Sept 2022, doing the typical npx react-native init <projectname> and was working on android mostly (I use a linux box, and I have to use Teamviewer to connect to a mac to build the iOS apps).
I had my app working fine in android and iOS, and then added the Zoom Video SDK and everything went to hell. Got it working fine in Android, and tried to take my changes and build them in iOS but I couldn't get it to work, and seemingly got my iOS project corrupted, so I tried to create a fresh iOS project, by basically created a same-named project in a different directory, and replacing the <projectname>/ios with the new base ios project.
Of course, I did this Jan 2023, so it's the new architecture, and the AppDelegate.h tries to import the RCTAppDelegate.h file instead of React/RCTBridgeDelegate.h
I do my usual yarn install go into the ios directory and pod install and then try to do a yarn run ios and it tells me it can't find RCTAppDelegate.h
Anyone solve this yet? The React-Native docs aren't up to date with their github repo

I got the same error, i solved it by opening the .xcworkspace instead of opening .xcodeproj
I also cleaned the build folder by
Product --> Clean Build folder
and then it successfully built the app.

Related

Building old version of React-Native app with Xcode 11

I just started working on an already existing React-Native app that needs a really small update, but that has not been updated since October 2019.
The first thing I need, in order to start updating it, is to build the app. That is where I cannot find a way to do it.
At the moment, I’m trying to build the app only on iOS and not on Android.
First of all the current toolset versions I’m using are:
React-Native version: 0.53.3
Xcode version: 11.4.1
iOS SDK: 13.4
Node version: 8.16.6
NPM version: 6.14.1
I initially had problem with third-party tools, but I managed to fix it through manually installing them in the node-modules/react-native folder.
Now I’m getting errors about Xcode not finding headers of the modules the app is using
like, for example,
React/RCTViewManager.h file not found
Or, similarly, the GoogleSignIn.h headers in the RNGoogleSignIn module
I believe it’s just an error of how libraries are imported in Xcode, because as a test I have created a new react-native “test app” with the same exact versions of react-native and node, then I installed the core dependencies needed to perform the update on the original app, and I managed to build it without problems.
I’ve also tested building the app on an old Mac with macOS 10.14, using Xcode 9, but I’ve got different errors, always related to importing headers of modules.
This is the toolkits versions of the “old Mac”:
React-Native version: 0.53.3
Xcode version: 9.4.1
iOS SDK: 11.3
Node version: 8.16.6
NPM version: 6.14.1
Searching online I know that some of the problems I have faced (like the third-party react-native manual install) have been fixed in react-native updates, but I’m not expert enough with the technology to be sure that I can handle the update process without introducing bugs. I would prefer to just make this version run for now and facing the updating process later.
Do you have any suggestion of things about what I can do in order to successfully build the app?

If anyone ever comes here with a similar problem: the solution was pretty simple.
Be sure you're using the .xcworkspace file in your iOS folder, and not the .xcodeproj. This is used to automatically (and correctly) load the Pods dependencies in Xcode without having to manually link them.
Be sure that you installed the dependencies correctly with the right version of Cocoapods. We had to use an old version (1.5.x) that would automatically downloaded some pod dependencies. Our error was due to Facebook SDK. Newer versions of cocoapods did not download it, while the 1.5.x version would download it.

I can’t get my iOS project to build my changes

I'm new to the iOS side of things and I’m having a huge issue. None of my changes I am making to my views are being built when I build iOS. I run
sudo cordova build ios
Then I open Xcode and “sign” it. I then run from Xcode to my test device. But no changes are made. Even when I remove the iOS platform, add it back, rebuild iOS, run from Xcode, my changes still have not taken effect in the build. Am I missing something?
After you update your view, the process is:
1. build the components and pages and copy the result into www dir.
2. copy the contents in www into ios project, with ionic prepare command.
3. build your ios project.
With the latest version of ionic, it will be done one one command ionic cordova build ios, but if you use some old version of ionic, maybe you need to run:
ionic build
ionic cordova build ios

React-Native app can build for debugging but not for archiving

I'm trying to archive my iOS app which works fine when I build for debugging via xcode but when I try to archive the app I get the following errors which I'm not sure what's causing it
I think the real reason for failure would be a little above in the listing, which cannot be seen here.
I had similar kind of issue when updated react native to version 0.54.2 the iOS archive stopped working.
My error message was something like:
A problem occurred while trying to fetch the minifier. Path: "metro-minify-uglify" Cannot find module 'uglify-es'
And the problem was that my react native project only had uglify-js in node-modules (I quess that the new react native needed the uglify-es). So I installed that with:
npm install uglify-es --save
And after that I did (not sure if these are needed) xCode->clean project, shutdown xCode, delete Library->Developer->Xcode->DerivedData, restart Xcode and archive started working again.

WebStorm - React-Native App simulator not working

I created a brand new React-Native app using WebStorm. When I click on Run -> iOS to fire in iOS simulator, I don't see iOS simulator loading. I don't see any errors also. Here is the screenshot after I run the project.
Now I could run react-native run-ios to get iOS simulator to work (btw which works), but I would like WebStorm to fire simulator so that I can use in-built debugger in WebStorm.
What webStorm and react-native versions do you use? looks similar to WEB-29569, fixed in 2017.3
It's possible that WebStorm uses not latest version of react native that caused some troubles with Xcode version.
First you need to upgrade your Xcode to currently latest version.
Second you would better use stable version of Node JS.
I recommend you not to create app with WebStorm. For today the best way to create new app is create-react-native-app command line tool. It will create app using expo kit. As app will be initialized - run npm start (or better yarn start if you have it, because yarn is optimized version of npm). As it loaded it will show you QR code in terminal witch is you should read with your device and it will install Expo App and open your app inside it. Also you can press i to run iOS simulator.
Here is short documentation for creating app with create-react-native-app. Follow this steps and everything will be all right.
https://facebook.github.io/react-native/docs/getting-started.html

React Native app not running in XCode iOS simulator

I try to make my first steps using React Native. Development for Android (on Windows host) works. Now I wanted to test iOS, and tried to set up a development environment on a MacBook Pro.
Problem: React Native starts the iOS simulator, and then nothing happens any more. The simulator runs OK, but my React native app won't start.
What do I need to do to get my React Native installation going?
More Info:
I set up XCode and React Native according to the docs on the MacBook Pro running OSx 10.13.2 (High Sierra). XCode was installed and tested successfully, including the simulator.
When I installed Node.js I deliberately picked an older version (containing npm 4.2.0), since forums say that React Native does still have problems with npm 5. I also installed Homebrew and Watchman, like stated in the docs.
To initialize an empty project, I used
create-react-native-app HelloWorldProject
and a projet structure got created in my Documents folder.
If I finally fire up my "Hello World" test app using
cd HelloWorldProject
sudo react-native run-ios
the system responds:
Starting packager ...
Starting simulator ...
and then nothing happens. The simulator does indeed start (boot --> apple logo --> progress bar --> IOs start screen), but nothing happens afterwards.
Edit
I have given up on React Native for several reasons, I leave this question here for documentary purposes, but I cannot verify or accept any answer, I don't have a React Native development environment any more.
It's probably because you used sudo. /.expo/ is owned by root. Try to change the ownership with
sudo chown -R `whoami` ~/.expo
Refer https://github.com/react-community/create-react-native-app/issues/422
Even everything in your app seems fine, sometime you face the issue that the app is taking too much time to load either through terminal or Xcode. If there is no any other specific issue with your project, the following solution works most of the time:
Go to your app folder and then go to 'iOS' folder.
Delete 'Podfile.lock' and 'Pods' folder.
Execute the following command in Terminal from your 'ios' folder, that will bring back the 'Podfile.lock' and required Pods will be installed to 'Pods' folder:
pod install
Delete the 'build' folder in your 'iOS' folder.
Run the following command in terminal:
react-native run-ios
While the terminal is running, open '.xcworkspace' in your 'ios' folder in Xcode.
The above steps will make sure it will be build your react native project newly and will run on the simulator.
Thanks
Wasantha Wijayaratna

Resources