61

I'm trying to build a cordova ios app but not having much luck and getting strange errors.

Using this version of Cordova with older version of cordova-ios is deprecated. Upgrade to cordova-ios@4.0.0 or newer.

Error: Your ios platform does not have Api.js

The first warning says my cordov-ios version is old, which is strange as this is my output:

$ cordova --version
7.0.1



$ cordova platform version ios

Installed platforms:
  ios 4.4.0
Available platforms: 
  android ~6.2.2
  blackberry10 ~3.8.0 (deprecated)
  browser ~4.1.0
  osx ~4.0.1
  webos ~3.7.0

So I clearly have the latest versions necessary.

And then the Api.js error. What is causing this?

Error: Your ios platform does not have Api.js

Any ideas?

Community
  • 1
  • 1
andy
  • 8,775
  • 13
  • 77
  • 122

9 Answers9

74

I was having exactly this problem but managed to solve it by simply removing and then adding the IOS platform within my project:

cordova platform rm ios
cordova platform add ios

This seemed to fix whatever had somehow got broken when updating Cordova...

LuminousEagle
  • 771
  • 1
  • 5
  • 6
  • 1
    I tried this approach, but it didn't work for me. Explicitly updating node seemed to be the key point in my case. – David Vezzani Jun 23 '17 at 18:56
  • 1
    Without sudo access `cordova platform rm ios` would give the following error `rm: could not remove directory (code ENOTEMPTY): /Users/xyz/abc/platforms/ios` - with sudo it worked. – Danny Thompson Jun 28 '17 at 14:55
  • but you will need to `chown` the files back to user – Danny Thompson Jun 28 '17 at 15:31
  • This approach worked for me, I've removed all the platforms. Added back iOS and the installation was success without this error. It was helpful. – Santosh Jul 01 '17 at 10:50
36

I'm guessing that attempting to use deprecated code is the reason for seeing the error message.

It appears that one should be using the latest version of node. I also performed all my software updates for Xcode. I also connected my iPhone to my computer. Even after that (and before I updated node) I was still seeing this:

cordova platform add ios

Warning: using node version v0.12.0 which has been deprecated. Please upgrade to the latest node version available (v6.x is recommended).
Using cordova-fetch for cordova-ios@^4.4.0
Adding ios project...
Error: Your ios platform does not have Api.js

Then I decided to resolve the warning by updating node. And finally success:

sudo n latest
node --version
=> v8.0.0

cordova platform rm ios
cordova platform add ios

Using cordova-fetch for cordova-ios@~4.4.0
Adding ios project...
Creating Cordova project for the iOS platform:
    Path: platforms/ios
    Package: com.example.hello
    Name: HelloWorld
iOS project created with cordova-ios@4.4.0
Installing "cordova-plugin-whitelist" for ios
--save flag or autosave detected
Saving ios@~4.4.0 into config.xml file ...
David Vezzani
  • 1,449
  • 16
  • 24
  • I was struggling with this "Your ios platform does not have Api.js" error, and this was finally the fix for me. I was building remote using Visual Studio and updating node on MacOS fixed the issue for me. Thanks. – Mr. Blonde Jun 21 '17 at 10:12
  • I had similar issue in browser solution, same worked – Tejas Dec 05 '17 at 11:06
  • I tried cordova platform rm/add android.......Failed to install 'mx.ferreyra.callnumber': Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform ".gradle" does not appear to be a valid cordova platform. It is missing API.js. .gradle not supported.) My Versions on Ubuntu : + node -v v9.2.1 + cordova -v 7.1.0 + npm -v 5.5.1 + gradle -v ------------------------------------------------------------ Gradle 3.3 – Ashish Karpe Dec 11 '17 at 14:47
2

Has same issue with latest version of cordova (7.0.1)

Faced error while adding iOS platform and managed to resolve it by upgrading nodeJS to latest version (6.11.1)

Gandhi
  • 11,875
  • 4
  • 39
  • 63
2

This problem can also occur when you have both the Android and iOS installed. At least this was the case for me.

When I ran the command:

cordova platform rm android

It started to work

Sinan Samet
  • 6,432
  • 12
  • 50
  • 93
1

use cordova@6.0 solved the problem

lnd Shawn
  • 19
  • 2
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post;](https://stackoverflow.com/help/privileges/comment) instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – mrun Jul 06 '17 at 08:02
1

For those of you that have tried updating your NodeJs and that didn't work.

Go check in your platforms/android or platforms/ios folder. Mine was empty. Delete the folder, and run ionic cordova add android/ios again.

Ruan
  • 3,969
  • 10
  • 60
  • 87
1

Downgraded to cordova 8 and it's working.

Juan Angel
  • 656
  • 6
  • 6
1

I always fix this error removing the platform and adding it again (android in my case)

phonegap platform rm android

wait until it finishes...

phonegap platform add android

And that´s it. Let me know if it is fixed for you.

InsaurraldeAP
  • 682
  • 7
  • 16
0

I got this error in Windows 10 trying to run a "cordova plugins add ..." command to my android/ios app. I had the latest Node/NPM already and did not want to platform rm/add again. Instead I tried the "cordova plugins add ..." command on my OSX laptop instead of Windows 10 ... and it worked. No idea how/why but thankful it worked. Realize this may not help most w/this error but maybe someone else out there in same boat.

Christopher
  • 1,639
  • 19
  • 22