skip to Main Content

I’m trying to run the command

ionic cordova platform add [email protected]

everything is updated, my versions are:

ionic - 6.17.1
npm - 7.21.1
node - 16.9.1
pod - 1.11.2

I have the last version of Xcode (13) just released 2 days ago. When running that command I get:

--save flag or autosave detected
Saving ios@~6.2.0 into config.xml file ...
Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Debug
Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Release
Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES for build configuration Debug
Use Swift language version 5
Update IOS build setting SWIFT_OPTIMIZATION_LEVEL to: -Onone for build configuration Debug
Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES for build configuration Release
Use Swift language version 5
[ERROR] An error occurred while running subprocess cordova.
        
        cordova platform add [email protected] exited with exit code 1.

After reading every post I found, I included on my config.xml:

<preference name="UseSwiftLanguageVersion" value="5" />

Thinking I might had a non-supported Xcode version, I downgraded Xcode to v12.5.1, selected it on Xcode -> Preferences -> Locations, then restarted all terminals and processes, restarted the Mac, but still not working.

I tried to update CocoaPods with the commands:

pod install
pod setup

And still nothing was working so I decided to run the command

ionic cordova prepare ios 

to see if I could go on anyway but got this error:

[error] Error: Cannot find module '@ionic/angular-toolkit/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/run-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng

And yes, if you are wondering every time I updated or ran a command I did also deleted the platforms, plugins, node_modules and www folder, but anything is happening.

2

Answers


  1. Chosen as BEST ANSWER

    Well, at the end, after 15h of work and a lot of searching, it was all fixed by downgrading my Node version from 16.9.1 to 14.17.5.

    I didn't know that this new Node version is not supported by Angular jet, but I found out, and you can too by just running the command

    ng -v
    

    which says at the end

    Warning: The current version of Node (16.9.1) is not supported by Angular.
    

    to downgrade your Node version you can follow the instructions on this post:

    How to downgrade Node version

    You can also see all the Node versions available here: https://nodejs.org/es/about/releases/

    Since Angular is a step behind of Node I suggest to download an Active version and not a current one.


  2. Coincidentally today I had to migrate a Cordova project to iOS 6.2 due to Apple’s usual annoyance in updating hours before and leaving everything obsolete (the best in backward compatibility, it should be noted).

    I’ll share with you the short commands that work with cordova without digging too much:

    0-) sudo npm install cordova-ios@latest

    1-) sudo ionic cordova platform remove ios

    2-) sudo ionic cordova platform add ios@latest // don’t specify version, the last one already assumes this

    3-) sudo chmod -R 777 platforms/ios // usually, I must enable read and write permissions, things on my computer but with that I ensure full permission.

    4-) sudo ionic cordova build ios

    5-) You open XCode again in the generated project and voila, you can compile it.

    If step #1 fails you, run it 2 times (for some reason I always have to run it 2 times to get it done).

    Best regards.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search