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

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

Related

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

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.

When I run cordova on ios it keeps building my old app

I started a cordova project a while again and needed to do a major update so I cloned the folder and rebuilt the app. I deleted the old xcode project and cordova app but when I run:
cordova run ios --device
it keeps bring up my old app even though its deleted and no where to be found. If I run it in xcode and target my device it works fine? Is there some kind of caching I need to delete?
It is an issue with xcode 10 and cordova 8. This fix is to use this instead:
cordova run ios --buildFlag='-UseModernBuildSystem=0'

Xcode does not include changes in rebuild of cordova app

I am experiencing the problem that Xcode does not incorporate any changes made to HTML/CSS/JS files when rebuilding the app for iOS
Right now I am deleting the whole platforms/ios folder and rerunning cordova add platform ios every time. This can't be the intended way of testing cordova apps. What is a good workflow for testing cordova apps on an iOS device?
Well, the recommended workflow for testing Cordova apps is not using Xcode at all, just use the Cordova CLI to run your apps. But the truth is that running from the CLI might be slower than using Xcode.
What you need to copy the changes from www to the Xcode project is to run cordova prepare ios before running from Xcode. You can do it manually or create a Xcode build script to run it for you.
To add a build script, on Xcode select your project target, go to Build Phases, click the + button and select New Build Script phase.
You can try to just add cordova prepare ios and this might work.
If you get a cordova command not found, then you also need to add Cordova path to your PATH. To do it, open a terminal and type which cordova, you'll get the Cordova path, something like /Users/davidnathan/.nvm/versions/node/v4.4.7/bin/cordova.
Now add that path without the cordova part to your build script before the cordova prepare ios, something like
PATH=/Users/davidnathan/.nvm/versions/node/v4.4.7/bin/:$PATH && cordova prepare ios
Move the build script to be over the existing "Copy www directory"
Try ionic cordova prepare ios.

How to edit a Phonegap/Cordova-project in XCode?

I built a Phonegap/Cordova iOS-app using the command line. I can run it with the CLI.
After that I'm using XCode to compile and run the project that was created in 'platforms/ios' on the iOS simulator. This works too.
Now I would like to use XCode to make changes to the app. XCode does display a www-folder and config.xml but these are the top ones in the project folder , not in platforms/ios.
So if I change the files that are displayed in XCode, no changes appear when I run the project.
So, how can you edit a files of a Phonegap/Cordova project and run it with XCode ? (and still being able to use the CLI, would be nice as well).
You always need to modify the project_folder/www files. You can edit this files using Xcode, notepad++ or even with a simple notepad. Use what ever you like.
Then run the command using CLI
cordova build ios
Your project is now completely built. You can see the changes you made inside platform/ios/.../www files too. Now you can run the project using CLI or Xcode as wish. To run in CLI
cordova run ios
Or to emulate in emulator
cordova emulate ios
You are doing it right, you have to edit the root www folder.
Your problem is you have to do a cordova prepare ios to copy the changes from the root www folder to the platform/ios/www folder
You can do it from the cordova CLI or you can add a build script to you project (on build phases -> new Run Script phase) that runs the cordova prepare ios every time you run the project from xcode
The code you need on the scrip is
PATH=${PATH}:/usr/local/lib/node_modules/cordova/bin/:/usr/local/bin
cordova prepare ios
Put it the first one
If you really want to edit the patform/ios/www folder, on xcode you will see a staging folder, there you have the www folder and the changes you do there are applied to the project, but when you do a cordova prepare ios that files will be replaced by the ones on the root www folder and you will lose all your work, so don't do that

How to update code when emulating Cordova app on Xcode?

I have a Cordova project which I have opened with Xcode and then emulate from there. Xcode performs a git checkout of the project to a new folder and runs the code from there. However when I run the emulator, it seems to open and older version of my project because it includes a JS debugger which I deleted a long time ago.
When I look at the code in Xcode, it looks correct, but the emulator still runs the old version.
With cordova 3.X you are not supposed to work with xcode
Even if you are working with xcode, you have to run the cordova prepare ios command each time you change something.
You can create a script (in xcode select the project, go to build phases, click the + button, and new run script phase). It should be over the copy www phase
The code you need is:
PATH=${PATH}:/usr/local/lib/node_modules/cordova/bin/:/usr/local/bin
cordova prepare ios
EDIT: On Xcode 7 you don't need to add the PATH line, just cordova prepare ios
EDIT2:
On Xcode 8 I was getting cordova command not found, I think it uses it's own node version instead of the installed one.
In case you have this problem then add Cordova path to your PATH.
As now I use nvm to handle node versions, the path I provided on my answer no longer works for my case.
Best thing to get the path is to type which cordova in a terminal window, you'll get the Cordova path, something like: /Users/username/.nvm/versions/node/v4.4.7/bin/cordova.
Add that path without the cordova part to your build script before the cordova prepare ios, something like
PATH=/Users/username/.nvm/versions/node/v4.4.7/bin/:$PATH && cordova prepare ios

Resources