离子找不到平台

Posted

技术标签:

【中文标题】离子找不到平台【英文标题】:Ionic can't find platform 【发布时间】:2017-10-11 21:14:24 【问题描述】:

我的配置文件有什么问题(或 ionic cordova 设置);它找不到任何平台,但我确实已经安装了 ios,PLUS ionic 尝试添加并失败,因为它存在......下面的示例来自 emulate,$ionic cordova platform add ios 也会生成相同的错误。

$ ionic cordova emulate ios
> cordova platform add ios --save
✖ Running command - failed!
[WARN] Platform already added. Saving platforms to config.xml.
> cordova platform save
✔ Running command - done!
[INFO] Running app-scripts build: --platform ios --target cordova

[22:44:34]  build dev started ... 
[22:44:34]  clean started ... 
[22:44:34]  clean finished in 11 ms 
[22:44:34]  copy started ... 
[22:44:34]  transpile started ... 
[22:44:38]  transpile finished in 4.45 s 
[22:44:38]  preprocess started ... 
[22:44:38]  deeplinks started ... 
[22:44:39]  deeplinks finished in 264 ms 
[22:44:39]  preprocess finished in 265 ms 
[22:44:39]  webpack started ... 
[22:44:39]  copy finished in 4.89 s 
[22:44:50]  webpack finished in 11.63 s 
[22:44:50]  sass started ... 
[22:44:51]  sass finished in 1.04 s 
[22:44:51]  postprocess started ... 
[22:44:51]  removed unused font files 
[22:44:51]  postprocess finished in 10 ms 
[22:44:51]  lint started ... 
[22:44:51]  build dev finished in 17.47 s 
> ionic cordova prepare
[WARN] No Cordova platforms listed in config.xml. Nothing to prepare.

   You can save your installed platforms to config.xml with the ionic cordova platform save command.
[22:44:53]  lint finished in 2.11 s 

这是我的 config.xml 文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.nkt.pms" version="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Sys</name>
<description>System</description>
<author email="support@XXXX.net" href="http://XXXX">The XXXX Team</author>
<content src="index.html" />
<access origin="*" />
<allow-navigation href="http://ionic.local/*" />
<allow-navigation href="http://XXXX:8100" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="androidLaunchMode" value="singleTask" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="orientation" value="portrait" />
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
    <icon  src="resources/ios/icon/icon.png"  />
    <icon  src="resources/ios/icon/icon@2x.png"  />
    <icon  src="resources/ios/icon/icon-40.png"  />
    <icon  src="resources/ios/icon/icon-40@2x.png"  />
    <icon  src="resources/ios/icon/icon-40@3x.png"  />
    <icon  src="resources/ios/icon/icon-50.png"  />
    <icon  src="resources/ios/icon/icon-50@2x.png"  />
    <icon  src="resources/ios/icon/icon-60.png"  />
    <icon  src="resources/ios/icon/icon-60@2x.png"  />
    <icon  src="resources/ios/icon/icon-60@3x.png"  />
    <icon  src="resources/ios/icon/icon-72.png"  />
    <icon  src="resources/ios/icon/icon-72@2x.png"  />
    <icon  src="resources/ios/icon/icon-76.png"  />
    <icon  src="resources/ios/icon/icon-76@2x.png"  />
    <icon  src="resources/ios/icon/icon-83.5@2x.png"  />
    <icon  src="resources/ios/icon/icon-small.png"  />
    <icon  src="resources/ios/icon/icon-small@2x.png"  />
    <icon  src="resources/ios/icon/icon-small@3x.png"  />
    <splash  src="resources/ios/splash/Default-568h@2x~iphone.png"  />
    <splash  src="resources/ios/splash/Default-667h.png"  />
    <splash  src="resources/ios/splash/Default-736h.png"  />
    <splash  src="resources/ios/splash/Default-Landscape-736h.png"  />
    <splash  src="resources/ios/splash/Default-Landscape@2x~ipad.png"  />
    <splash  src="resources/ios/splash/Default-Landscape@~ipadpro.png"  />
    <splash  src="resources/ios/splash/Default-Landscape~ipad.png"  />
    <splash  src="resources/ios/splash/Default-Portrait@2x~ipad.png"  />
    <splash  src="resources/ios/splash/Default-Portrait@~ipadpro.png"  />
    <splash  src="resources/ios/splash/Default-Portrait~ipad.png"  />
    <splash  src="resources/ios/splash/Default@2x~iphone.png"  />
    <splash  src="resources/ios/splash/Default~iphone.png"  />
</platform>
<feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<icon src="resources/newicon.png" />
<icon src="resources/android/icon/drawable-xhdpi-icon.png" />
<plugin name="cordova-plugin-camera" spec="~2.4.1">
    <variable name="CAMERA_USAGE_DESCRIPTION" value=" " />
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value=" " />
</plugin>
<plugin name="cordova-plugin-console" spec="^1.1.0" />
<plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
    <variable name="URL_SCHEME" value="com.nkt.pms" />
    <variable name="ANDROID_SCHEME" value="com.nkt.pms" />
    <variable name="ANDROID_HOST" value="pmsys.eu.auth0.com" />
    <variable name="ANDROID_PATHPREFIX" value="/cordova/com.nkt.pms/callback" />
</plugin>
<plugin name="cordova-plugin-device" spec="^1.1.6" />
<plugin name="cordova-plugin-file" spec="~4.3.3" />
<plugin name="cordova-plugin-file-transfer" spec="~1.6.3" />
<plugin name="cordova-plugin-filepath" spec="~1.0.2" />
<plugin name="cordova-plugin-safariviewcontroller" spec="^1.4.7" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<plugin name="cordova-sqlite-storage" spec="^2.0.4" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />

$ ionic info

cli packages: (/Users/larsbrenna/Desktop/dev/app/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : ios
Ionic Framework    : ionic-angular 3.7.1

System:

Node  : v6.9.1
npm   : 5.4.2 
OS    : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235 

感谢所有提示和提示!

【问题讨论】:

【参考方案1】:

Ionic 找不到平台,因为config.xml 中缺少&lt;engine&gt; 标记。尝试清理一下您的设置:

运行cordova platform rm ios(可能会出现未添加平台的错误) 如果platforms 文件夹仍然存在,请将其删除 如果您希望重新安装 plugins 文件夹,也可以删除它们 删除package.json中所有与ios平台相关的引用 删除node_modulespackage-lock.json

然后确保 cordova 和 ionic CLI 是最新的:

(sudo) npm install -g cordova@latest ionic@latest

然后一步步还原一切:

npm install cordova platform add ios@4.5.1

我个人喜欢只通过cordova CLI 运行cordova 命令,而不是通过ionic CLI(运行ionic cordova ... 时,ionic CLI 只是将cordova 相关命令转发到cordova CLI,这可能会导致错误)。只是为了构建和运行应用程序,我使用组合命令,因为它更方便。

我还注意到您使用的是旧版本的@ionic/app-scripts 和最新的ionic-angular 版本。你也应该升级它。

【讨论】:

非常感谢!该应用程序现在通过 XCode 运行,但不直接从 Ionic CLI 运行:` > cordova emulate ios Error: Command failed: xcrun simctl list --json dyld: Library not loaded: /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A /CoreSimulator 引用自:/Applications/Xcode.app/Contents/Developer/usr/bin/simctl 原因:找不到图像 [错误] 运行 cordova emulate ios 时出错(退出代码 1)。` 您可能需要将 XCode 和/或 XCode 命令行工具更新到最新版本。还要确保你不时重启你的mac,所以所有更新都不会被锁定:) 我正在运行 XCode 9.0(最新)。哦,离子服务也失败了。重新启动后会再试一次! :)

以上是关于离子找不到平台的主要内容,如果未能解决你的问题,请参考以下文章

离子摇篮失败“找不到 com.android.tools.build:gradle:2.2.3”

离子3:找不到管道''[重复]

打字稿错误找不到名称'require'。离子 3

找不到模块“离子原生”

找不到离子目标设备

离子/角度:找不到管道“异步”