“npx cap add ios”失败,并显示错误“使用 pod install 更新 iOS 本机依赖项 - 失败!”

问题描述 投票:0回答:7

我刚刚创建了一个全新的 Ionic 应用程序,使用命令“ionic start myApp Blank”

我添加了必要的角度依赖关系以使“离子服务”正常工作。

我已经使用以下命令安装了电容器

npm install @capacitor/cli @capacitor/core
npx cap init

npm install @capacitor/ios @capacitor/android

我的 Package.json 如下所示,

{
  "name": "myApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~12.1.1",
    "@angular/core": "~12.1.1",
    "@angular/forms": "~12.1.1",
    "@angular/platform-browser": "~12.1.1",
    "@angular/platform-browser-dynamic": "~12.1.1",
    "@angular/router": "~12.1.1",
    "@capacitor/android": "^3.2.4",
    "@capacitor/app": "1.0.3",
    "@capacitor/core": "^3.2.4",
    "@capacitor/haptics": "1.1.0",
    "@capacitor/ios": "^3.2.4",
    "@capacitor/keyboard": "1.1.0",
    "@capacitor/status-bar": "1.0.3",
    "@ionic/angular": "^5.5.2",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.1.1",
    "@angular-eslint/builder": "~12.0.0",
    "@angular-eslint/eslint-plugin": "~12.0.0",
    "@angular-eslint/eslint-plugin-template": "~12.0.0",
    "@angular-eslint/template-parser": "~12.0.0",
    "@angular/cli": "~12.1.1",
    "@angular/compiler": "~12.1.1",
    "@angular/compiler-cli": "~12.1.1",
    "@angular/language-service": "~12.0.1",
    "@capacitor/cli": "^3.2.4",
    "@ionic/angular-toolkit": "^4.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "4.16.1",
    "@typescript-eslint/parser": "4.16.1",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.2.4"
  },
  "description": "An Ionic project"
}

我运行了以下命令,效果很好

rm -r "./www"
rm -r "./ios"
ng build

此后我尝试运行以下命令

ionic capacitor add ios
(或者)
npx cap add ios

错误如下

✔ Adding native Xcode project in ios in 29.98ms
✔ add in 30.56ms
✔ Copying web assets from www to ios/App/App/public in 864.98ms
✔ Creating capacitor.config.json in ios/App/App in 699.86μp
(node:25320) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/493055/Desktop/dev/IonicExperiment/myApp/node_modules/tslib/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ copy ios in 908.37ms
✔ Updating iOS plugins in 5.66ms
[info] Found 4 Capacitor plugins for ios:
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
✖ Updating iOS native dependencies with pod install - failed!
✖ update ios - failed!
[error] ERR_SUBPROCESS_NON_ZERO_EXIT

并且

(base) AMBIN01978:myApp 493055$ ionic capacitor add ios
> npm i -E @capacitor/ios@latest
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/


up to date in 5s

136 packages are looking for funding
  run `npm fund` for details
> capacitor add ios
[capacitor] ✔ Adding native Xcode project in ios in 32.31ms
[capacitor] ✔ add in 33.30ms
[capacitor] ✔ Copying web assets from www to ios/App/App/public in 696.66ms
[capacitor] ✔ Creating capacitor.config.json in ios/App/App in 446.33μp
[capacitor] (node:25522) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/493055/Desktop/dev/IonicExperiment/myApp/node_modules/tslib/package.json.

[capacitor] Update this package.json to use a subpath pattern like "./*".
[capacitor] (Use `node --trace-deprecation ...` to show where the warning was created)
[capacitor] ✔ copy ios in 715.44ms
[capacitor] ✔ Updating iOS plugins in 4.48ms
[capacitor] [info] Found 4 Capacitor plugins for ios:
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor] ✖ Updating iOS native dependencies with pod install - failed!
[capacitor] ✖ update ios - failed!
[capacitor] [error] xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
[capacitor]         
[ERROR] An error occurred while running subprocess capacitor.
        
        capacitor add ios exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

这个问题已经让我头疼了好几天了。非常感谢任何帮助

ios angular xcode ionic-framework capacitor
7个回答
70
投票

我在终端中运行了以下命令

sudo xcode-select --reset

并为我消除了错误


41
投票

如果您有 M1 - 问题可能出在 Cocoapods 上。

如果这里的其他答案失败,请尝试:

sudo arch -x86_64 gem install ffi

然后在ios/App内

arch -x86_64 pod 安装

然后,看看它是否有效:

cd..

cd..

npx 上限同步


7
投票

在此之后逐行运行以下命令行

  1. cd ios
  2. cd 应用程序
  3. pod 安装
  4. cd ..
  5. cd ..

然后通过 ionic cap 打开 ios 检查问题已解决:) :)


2
投票

请使用以下命令

  1. 最初删除此项目上的 ios - Visual Studio 代码

rm -r iOS

  1. 在项目中添加ios

npx 上限添加 ios
npx 上限同步

  1. 您在 pod 安装或插件问题上遇到任何问题(例如)运行 pod 更新或安装时未找到 Capacitor 的 podspec

npm 我@capacitor/ios


0
投票

只需使用 Rosetta 打开终端,然后使用 npx capsync


0
投票

我从头开始重建了我的 Mac Monstery 12.6.6。全部全新安装 - Xcode、android studio、VSCode、node、cocoapods 等。

虽然

pod install

执行得很好

ionic cap sync iOS

操作消息失败。

执行以下两个命令解决了我的问题

sudo xcode-select -s /Library/Developer/CommandLineTools
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

0
投票

为我工作:

删除podfile.lock 将 podfile.lock 添加到 gitignore

部署

© www.soinside.com 2019 - 2024. All rights reserved.