简体   繁体   English

使用cordova构建ios时出错

[英]Error building ios with cordova

I have a problem when I build the ios platform with cordova.使用cordova构建ios平台时遇到问题。 I have all the certificates for the app and device, but when I try to run in my ios device, doing ionic run ios, the console return this error:我拥有应用程序和设备的所有证书,但是当我尝试在我的 ios 设备中运行时,执行 ionic run ios,控制台返回此错误:

Error: Source path does not exist: resources/ios/icon/icon-40@3x.png

This path is written in config.xml file.这个路径写在 config.xml 文件中。

I tried to run it in xCode but the problem there was:我试图在 xCode 中运行它,但问题是:

Cordova/CDVViewController.h not found

I read a lot of possible solutions but any works for me.我阅读了很多可能的解决方案,但任何对我都有效。

My xCode version is 7.3.1, the cordova version is 6.3.0 and the cordova ios version is 4.2.0.我的 xCode 版本是 7.3.1,cordova 版本是 6.3.0,cordova ios 版本是 4.2.0。

If you are missing the icon you can run the command如果您缺少图标,您可以运行命令

ionic resources --icon

This will generate all the icons with the pixels needed to run on any device.这将生成具有在任何设备上运行所需的像素的所有图标。

To simulate on the device you first need to要在设备上进行模拟,您首先需要

ionic build ios

and then然后

ionic simulate ios

It is also a good practice to have xcode up to date.更新 xcode 也是一个好习惯。

If you are still getting the error you can paste this line如果您仍然收到错误,您可以粘贴此行

"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"

on Build Settings > Header Search Paths.在构建设置 > 标题搜索路径上。 Do not remove the similar line, just add it at the end.不要删除类似的行,只需将其添加到末尾即可。

Update - 03-08-2017更新 - 03-08-2017

> ionic cordova resources

Old CLI command:旧的 CLI 命令:

I had the same error, and after re-running ionic resources it went away.我有同样的错误,在重新运行ionic resources它就消失了。

The problem was that I had Windows-style slashes (backslashes) in the path of the icon, ie the error I had was this:问题是我在图标的路径中有 Windows 风格的斜杠(反斜杠),即我遇到的错误是这样的:

Error: Source path does not exist: resources\\ios\\icon\\icon-40.png

So, converting backslashes into slashes resolved it for me.因此,将反斜杠转换为斜杠为我解决了这个问题。

Update: And regarding your second error, it helped me to reset the state:更新:关于你的第二个错误,它帮助我重置状态:

ionic state reset

Make sure you have ios listed under cordovaPlatforms in your package.json before running this command.在运行此命令之前,请确保在package.json cordovaPlatformsios Then ionic automatically re-downloads your plugins afresh and is ready to build.然后ionic自动重新下载您的插件并准备好构建。

Hope that helps.希望有帮助。 Take care!小心!

I've had same error only with other image:我只对其他图像有同样的错误:

Source path does not exist: resources/ios/icon/icon-40@2x.png源路径不存在:resources/ios/icon/icon-40@2x.png

This happened after upgrading to Cordova 6.3.0 and I've solved it downgrading Cordova .这发生在升级到Cordova 6.3.0 ,我已经解决了降级Cordova

Quickfix for now:现在快速修复:

npm uninstall -g cordova
npm install -g cordova@6.2.0

Just use: Remove platform只需使用:移除平台

cordova platform remove ios

And add ios platform with old one并用旧的添加ios平台

cordova platform add ios@4.0.0 --save

It worked for me..它对我有用..

@4.0.0 will select previous version automatically @4.0.0 会自动选择以前的版本

I have try some times, finally success.我试了几次,终于成功了。

  1. use ionic resources --icon , maybe met the new problem使用ionic resources --icon ,可能遇到了新问题

"Unable to generate images due to an error Failed to upload source image: Error: read ECONNRESET" “由于错误无法生成图像无法上传源图像:错误:读取ECONNRESET”

don't worry , try it later别着急,稍后试试

  1. use ionic platform remove ios when execute successfully use ionic platform add ios使用ionic platform remove ios执行成功后ionic platform remove ios use ionic platform add ios

DON'T USE ionic state reset不要使用ionic state reset

Try to replace the "\\" with "/" (backslash and slash) in the config.xml.尝试将 config.xml 中的“\\”替换为“/”(反斜杠和斜杠)。

If you create the project on a Windows system and move to macOS for iOS compilation, it still has the Windows URI format.如果您在 Windows 系统上创建项目并移动到 macOS 进行 iOS 编译,它仍然具有 Windows URI 格式。

I've found this issue in several occasions and some of the provided answers worked quite well till today, when no one worked.我已经多次发现这个问题,并且提供的一些答案直到今天都很好用,当时没有人工作。

My environment: MacOS high Sierra 10.13, ionic cli 3.18.0 and cordova 7.1.0.我的环境:MacOS high Sierra 10.13、ionic cli 3.18.0 和cordova 7.1.0。

My problem was that if I run ionic cordova prepare it fails saying that I need to add a platform and if a I add a platform with ionic cordova platform add ios it fails with the error specified in the answer:我的问题是,如果我运行ionic cordova prepare它失败,说我需要添加一个平台,如果我添加一个带有ionic cordova platform add ios的平台,它会失败并显示答案中指定的错误:

Error: Source path does not exist: resources/ios/icon/icon-40@3x.png

What solved my issue was manually creating the platforms folder: mkdir platforms .解决我的问题的是手动创建平台文件夹: mkdir platforms After creating this folder, adding a platform worked as usual.创建此文件夹后,添加平台照常工作。

I hope it could help someone out there.我希望它可以帮助那里的人。

I got similar issue with cordova-ios@~4.5.1我在cordova-ios@~4.5.1上遇到了类似的问题

ionic cordova build ios离子科尔多瓦构建ios

> cordova build ios
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

[ERROR] An error occurred while running cordova build ios (exit code 1).

ionic cordova platform add ios离子cordova平台添加ios

> cordova platform add ios --save
Using cordova-fetch for cordova-ios@~4.5.1

Adding ios project...

Creating Cordova project for the iOS platform:

Path: platforms/ios
Package: -
Name: -
iOS project created with cordova-ios@4.5.4

Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png

I remove ios platform我删除了ios平台

ionic cordova platform remove ios

And add ios platform with old one并用旧的添加ios平台

ionic cordova platform add ios@4.0.0

This worked for me, waiting for an Cordova update :)这对我有用,等待Cordova更新:)

it's a cat and mouse problem,这是一个猫捉老鼠的问题,

  1. the icon resources aren't built because the platform isn't added and未构建图标资源,因为未添加平台,并且
  2. platform can't be added because the icon resource isn't there平台无法添加,因为图标资源不存在

ionic/cordova is pretty unstable and a nightmare to work with in CI pipeline. ionic/cordova 非常不稳定,在 CI 管道中使用是一个噩梦。

this kept crashing out CI pipeline.这不断使 CI 管道崩溃。 just keep removing and adding the android/ios platform and build the resources using ionic cordova resources --force只需继续删除和添加 android/ios 平台并使用ionic cordova resources --force构建ionic cordova resources --force

Running these commands solved it for me:运行这些命令为我解决了这个问题:

ionic platform rm ios离子平台rm ios

ionic resources离子资源

ionic platform add ios离子平台添加ios

It says that the resources directory only contained empty folders.它说资源目录只包含空文件夹。 Downloading this repo ( https://github.com/ionic-team/ionic2-app-base/tree/master/resources ) and replace the resources directory下载这个 repo ( https://github.com/ionic-team/ionic2-app-base/tree/master/resources ) 并替换资源目录

Run again the "ionic cordova resources".再次运行“离子科尔多瓦资源”。

我不得不从任何其他项目存储库手动复制文件,例如https://github.com/sphilee/eTAS_GPS/tree/master/resources/ios

You just need to update the cordova to fix this error: to update the cordova run below command您只需要更新cordova 即可修复此错误:更新cordova 运行以下命令

$sudo npm install -g cordova@6.2.0

once you update the cordova type below command to remove the platform一旦您更新以下命令的cordova类型以删除平台

$sudo ionic cordova platform rm ios --save

And then add platform again using below command然后使用以下命令再次添加平台

$sudo ionic cordova platform add ios --save

I hope this will help you.我希望这会帮助你。

I ran into the same problem:我遇到了同样的问题:

Error: Source path does not exist: resources/ios/icon/icon-40@3x.png错误:源路径不存在:resources/ios/icon/icon-40@3x.png

Looks like the relative path is in reference to the config.xml.看起来相对路径是对 config.xml 的引用。 If the resources folder exists inside of 'www', then you may need to update the relative path.如果资源文件夹存在于“www”中,则您可能需要更新相对路径。

I was able to resolve this by updating the relative path to "www/resources/...".我能够通过更新“www/resources/...”的相对路径来解决这个问题。

It's likely that your resources haven't been run.您的资源可能尚未运行。

Run:运行:

npm i -g cordova-ionic platform rm ios
ionic platform rm ios // You want to do this just so when you recreate you have necessary resouces
ionic cordova resources
ionic cordova build --release <ios/android>

There should be more answers with this solution, since ionic is a project based on npm and this command will install the necessary libraries.这个解决方案应该有更多的答案,因为 ionic 是一个基于 npm 的项目,这个命令将安装必要的库。

I used the no brain way, but it works.我使用了无脑方式,但它有效。 I added the ressources temporarily with the name they ask for.我用他们要求的名字临时添加了资源。

Like I copy and past an image icon-20 copy.png then rename it into my needed ressources like icon-small@2x.png就像我复制并icon-20 copy.png图像icon-20 copy.png然后将其重命名为我需要的资源,如icon-small@2x.png

make sure you add: xmlns:cdv="http://cordova.apache.org/ns/1.0确保添加: xmlns:cdv="http://cordova.apache.org/ns/1.0

to the widget section(on the very top) of your config.xml到 config.xml 的小部件部分(在最顶部)

This will add all necessary Cordova components.这将添加所有必要的 Cordova 组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM