XCode clang error no such file or directory with Push Plugin (Cordova project) - ios

I am developing a cordova project. A project which is intended to run cross platform: Android, Windows phone, iOS.
I using this pushplugin to implement push notifications: the push plugin is intended to communicate between the device and the relevant push notification system (Android: GCM, Windows: WNS, Apple: APNS): https://github.com/phonegap/phonegap-plugin-push
On a windows pc, in the visual studio, I have managed to implement push notifications in a todo app. The app runs well in the cross platform solution which runs on visual studio.
Now as you may know, in a Cordova app, when building for a specific platform, folders for each platform are created as sub folders to a folder called platforms found in the project directory.
When I tried building for ios and put the project folder on a ios computer, I am opening the project in Xcode and trying to run it, but I am getting these kind of errors referring to the same push plugin:
clang: error: no such file or directory: '/Users/Jurgen/Documents/Xcode/backbonetodo/BackboneToDo/platforms/ios/BackboneToDoPluginsphonegap-plugin-pushGCMLibrarieslibGGLCloudMessaging.a'
clang: error: no such file or directory: '/Users/Jurgen/Documents/Xcode/backbonetodo/BackboneToDo/platforms/ios/BackboneToDoPluginsphonegap-plugin-pushGCMLibrarieslibGGLCore.a'
clang: error: no such file or directory: '/Users/Jurgen/Documents/Xcode/backbonetodo/BackboneToDo/platforms/ios/BackboneToDoPluginsphonegap-plugin-pushGCMLibrarieslibGGLInstanceIDLib.a'
I just copied the first 3 errors (but there are over 20).
The push plugin works fine on visual studio and normally by copying the project folder on a mac computer and running the .xcodeproject file from inside the iOS platform folder, I manage to run with no problems.
Any idea, what could be wrong? I am also notificing that after BackboneToDo there is no / and also after Plugins. It seems like the way it is creating the directory is not right. I also tried to change the location to absolute but this didnt solve the problem.
Any help?
Thanks in advance

While coping the files of deferent platforms make sure you don't copy the following files / folders.
cordova_plugins.js, cordova-js-src, cordova.js, plugins.
It seems like you have copied the push plugin for android in iOS project.

Related

Ionic app loads using Ionic serve but not with Xcode

I'm currently stuck on a problem related to my Ionic project.
I have an Ionic project on GitHub which i've been working on in the past few weeks, i have a few Cordova plugins as part of the project.
When downloading the project from GitHub, i can run the app using Ionic Serve without a problem. However, when trying to setup the project for xCode to run on local device(s), i run into a multitude of errors
Some include:
When running ionic 'cordova platform add ios' the following error appears
Error: Could not install from "ios" as it does not contain a package.json file.
When trying to run 'ionic cordova run ios -l --external'
Error: Error: terminating with uncaught exception of type NSException
I have not yet tried to transfer my code into a new Ionic project, as i wish to see if my problem can be solved without that hassle.
View project code here: https://github.com/designsheikh/bitsandbobs.git
I figured it out. You have the exact same issue I've had with the android platform.
As I pointed it out in the comments, it is indeed caused by a "corrupted" project architecture.
How it happened
Initially, I had an issue with the cordova generated resources, somehow not being copied into the android platform directory. I tried plenty of things with the cordova-res CLI, including using the --copy and the --ios-project flags to force the copy to happen in the directory of my choice.
I couldn't manage to fix my issue, and then decided to rollback all my changes and start over on a clean project to try something else. Since then, I was not able to add the android platform anymore. Every single time, the following error was being thrown :
Error: Could not install from "android" as it does not contain a package.json file.
Explanation
With all my testing, I noticed that when using cordova to add the platform or copy the resources over, somehow, it had created the android platform in the wrong directory, at the root of my project instead of in the platforms folder. And that's where the issue comes from.
I can't explain it, but you will encounter this error every single time if you try to add a platform with cordova while having a folder with this platform name at the root of your project. I have no idea why this would prevent a platform from being added to the project, maybe this folder is used as a temp folder by the CLI.
Solution
The fix is to simply remove any ios or android directory at the root of your project.
The error will go away and you will be able to add the platform again.
#CodingJunkie
Regarding the Github repository you provided in your post, you will likely run into another error while trying to add the ios platform if you use cordova#>=9.0.0.
Using "requireCordovaModule" to load non-cordova module "xcode" is not supported.
Instead, add this module to your dependencies and use regular "require" to load it.
Check this issue#1033 for a workaround. However, it's not recommended to directly edit the plugin source code, you might want to look for another cordova Firebase plugin.
I also noticed you kinda mixed up cordova and capacitor in your project.
Make sure to use one or the other to avoid potential errors.
Hope this helped !
#Reqven
Thank you for your support! - i was sure that i had done this step while trying to fix the issue. It is such an absurd problem, it seems that there is a new project architecture as you mentioned which needs to be followed. I followed your steps with also one minor additional step as im working on the iIOS platform:
Delete iOS folder
cordova platform add ios
cordova prepare ios
ionic build
If step 2 throws an error causing the version not to be found or integrated into the project run - include '#latest' this also solved my problem

Can't build Cordova iOS project using CLI but can build/run the Xcode project

Absolutely new to Cordova. These are the steps I've done:
Checked out an existing project
run cordova build ios
The above generates this build error:
(node:10242) UnhandledPromiseRejectionWarning: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
I've Googled for a solution to the above and the general consensus seems to be to remove and then add the iOS platform.
Now there's a problem with that. Looking through the commit history, I can see that there have been code changes done to files within the platforms directory so I can't just remove it, or...
Question 1)
Can I?
Question 2)
Is it right to make code changes within the platforms directory? Because it seems like those are generated directories.
Question 3)
Why is it that when I open the Xcode project under platforms/ios, I am able to build/run it fine despite the Cordova CLI error above?
it's not right to manually edit the platform files. And some manual changes might make the project not build, so might be related to the manual changes somebody did. So if you don't want to risk to remove the platform, continue building from Xcode
from root www to platforms/ios is transferred by cordova commands such us cordova prepare ios or cordova build ios or cordova run ios.
So if you can't do a cordova prepare ios because of that error you can try a few things.
Copy your files from www to platforms/ios without replacing the whole folder, just the duplicate files. cordova prepare ios is not just a copy, it's also does some modifications/aditions, but if you don't remove existing files it might work.
Create a new project and copy the platforms/ios/cordova to your own project and see if that fixes the mentioned problem, as that's where the Api.js file is.
Downgrade the Cordova CLI, try to latest 7.x.x and if it doesn't work, try with latest 6.x.x, one of those won't require the Api.js as it relatively new.

Use native framework inside Unity in standalone build

I have a Unity project that uses a native ios framework from C# scripts. When I compile it for iOS app (.ipa), everything works fine.
I want to compile it for macOS, too, that means Standalone build.
To enable that, I check Standalone in import settings:
Then build the app for Standalone platform:
It builds an app, but it is unable to access native framework, and I don't see it inside package contents:
What am I missing?
unable to access native framework, and I don't see it inside package
contents:
The structure is:
Project-Name/Assets/SDK-Name/Plugins/iOS/SDK.framework
There are two issues:
1.The directory you put the plugin.
You put the iOS plugin the Plugins/iOS folder which works fine.
For Mac OSX, you put it in the Assets/Plugins folder. This is also where you put plugins for Windows and Linux.
2.You must convert or build the plugin or framework into a bundle. This bundle is what you should place in the Assets/Plugins folder.

ionic emulate ios (domain=com.apple.CoreSimulator.SimError, code=163)

I am trying to simulate a project with ionic using the command ionic emulate ios. I have installed xcode last version on mac Sierra. But no work. this is the error:
** BUILD SUCCEEDED **
No target specified for emulator. Deploying to iPhone-SE, 10.2 simulator
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup in current state: Shutdown
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup in current state: Shutdown
Error: ENOENT: no such file or directory, stat '/var/root/Library/Logs/CoreSimulator/4A052961-F773-4156-9D6C-76F137CC761B/system.log'
I found this solution(https://forums.developer.apple.com/thread/66665) but no work for me.
https://cordova.apache.org/docs/en/latest/guide/platforms/ios/
Open a Project within Xcode
Cordova for iOS projects can be opened in Xcode. This can be useful if you wish to use Xcode built in debugging/profiling tools or if you are developing iOS plugins. Please note that when opening your project in Xcode, it is recommended that you do NOT edit your code in the IDE. This will edit the code in the platforms folder of your project (not www), and changes are liable to be overwritten. Instead, edit the www folder and copy over your changes by running cordova build.
Plugin developers wishing to edit their native code in the IDE should use the --link flag when adding their plugin to the project via cordova plugin add. This will link the files so that changes to the plugin files in the platforms folder are reflected in your plugin's source folder (and vice versa).
Once the ios platform is added to your project and built using cordova build, you can open it from within Xcode. Double-click to open the ${PROJECT_NAME}/platforms/ios/${PROJECT_NAME}.xcodeproj file. The screen should look like this:
https://cordova.apache.org/static/img/guide/platforms/ios/helloworld_project.png
Then follow the instructions to deploy to a simulator:
https://cordova.apache.org/docs/en/latest/guide/platforms/ios/#deploying-to-simulator
You will be able to see errors more clearly.
In my case it was the problem of an unmatched resource file. I simply deleted it.
After this, I tried:
sudo chown -R $USER:$GROUP ~/.npm sudo chown -R $USER:$GROUP ~/.config
in terminal and was able to run the app in a simulator

when building an ionic app files and folders starting with "._" are created until error

I have a strange problem. I develop an app using Ionic on a samba network drive.
I develop on a windows machine and run all the command lines regarding Android development. I switch to a Mac to be able to build for iOS.
All went fine and as expected the last couple of days. Today I edited some HTML, JS and CSS files - just some minor improvements. I built the app for android on the windows machine (plus using jarsigner and zipalign - only if that should matter).
On the Mac I had troubles. Suddenly I get errors when trying to run ionic build --release ios (as I already did successfully the last couple days).
The executed script creates files and folders starting with "._" which were never created before and are already existing without it. This results at some point in an ENOENT (no such file or directory) aborting everything.
I don't get it. I already de-/re-installed node, npm, cordova and ionic. But nothing helped.
I would love to support you guys with additional error messages or logs, but due to I'm fairly new to mobile development (and using a Mac), I don't know what information would be helpful and what not.
Sp please tell me any information you need and I'll be happy to supply them.
I accidentally solved my own problem. I just "removed" the platforms directory (by renaming it) and re-added the platform using the command cordova platform add ios.
After that I could build my app as it did before. Don't know why or what actually triggered this behavior, but at least I'm able to proceed.
If somebody knows how to prevent that from happening again (so that I don't loose all the project settings I configured in Xcode), I would appreciate it.
This happened to me, too - I found this bug in the Cordova issues:
https://issues.apache.org/jira/browse/CB-5644
I found out that Xcode created the file PROJECT_PATH/platforms/ios/._APPNAME.xcodeproject. I deleted this file and "cordova prepared ios" was working again.
...
It should ignore files starting with ._ as they are hidden system
files used by osx to store infos about a file

Resources