ios 使用cordova构建ios时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38615582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error building ios with cordova
提问by Ary
I have a problem when I build the ios platform with cordova. 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:
使用cordova构建ios平台时遇到问题。我拥有应用程序和设备的所有证书,但是当我尝试在我的 ios 设备中运行时,执行 ionic run ios,控制台返回此错误:
Error: Source path does not exist: resources/ios/icon/[email protected]
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。
采纳答案by 0kk0
I've had same error only with other image:
我只对其他图像有同样的错误:
Source path does not exist: resources/ios/icon/[email protected]
源路径不存在:resources/ios/icon/[email protected]
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 [email protected]
回答by Joseph Ocasio
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.
在构建设置 > 标题搜索路径上。不要删除类似的行,只需将其添加到末尾即可。
回答by Eric Gopak
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, i.e. the error I had was this:
问题是我在图标的路径中有 Windows 风格的斜杠(反斜杠),即我遇到的错误是这样的:
Error: Source path does not exist: resources\ios\icon\icon-40.png
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
ionic state reset
Make sure you have ios
listed under cordovaPlatforms
in your package.json
before running this command. Then ionic
automatically re-downloads your plugins afresh and is ready to build.
在运行此命令之前,请确保您已在您的ios
下面列出。然后自动重新下载您的插件并准备好构建。cordovaPlatforms
package.json
ionic
Hope that helps. Take care!
希望有帮助。小心!
回答by Saranjith
Just use: Remove platform
只需使用:移除平台
cordova platform remove ios
And add ios platform with old one
并用旧的添加ios平台
cordova platform add [email protected] --save
It worked for me..
它对我有用..
@4.0.0 will select previous version automatically
@4.0.0 会自动选择以前的版本
回答by yu canghai
I have try some times, finally success.
我试了几次,终于成功了。
- 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
别着急,稍后试试
- use
ionic platform remove ios
when execute successfully useionic platform add ios
- 使用
ionic platform remove ios
时将执行的成功使用ionic platform add ios
DON'T USEionic state reset
不要使用ionic state reset
回答by Gregor Sklorz
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 格式。
回答by Lasneyx
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/[email protected]
What solved my issue was manually creating the platforms folder: mkdir platforms
. After creating this folder, adding a platform worked as usual.
解决我的问题的是手动创建平台文件夹:mkdir platforms
. 创建此文件夹后,添加平台照常工作。
I hope it could help someone out there.
我希望它可以帮助那里的人。
回答by Jér?me Demyttenaere
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 [email protected]
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 [email protected]
This worked for me, waiting for an Cordovaupdate :)
这对我有用,等待Cordova更新:)
回答by ir2pid
it's a cat and mouse problem,
这是一个猫捉老鼠的问题,
- the icon resources aren't built because the platform isn't added and
- 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. just keep removing and adding the android/ios platform and build the resources using ionic cordova resources --force
这不断使 CI 管道崩溃。只需继续删除和添加 android/ios 平台并使用构建资源ionic cordova resources --force
回答by Jonathan Perry
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 的项目,这个命令将安装必要的库。