ios - ionic 找不到平台

标签 ios cordova ionic3

我的配置文件有什么问题(或 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 height="57" src="resources/ios/icon/icon.png" width="57" />
    <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
    <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
    <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
    <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
    <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
    <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
    <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
    <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
    <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
    <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
    <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
    <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
    <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
    <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
    <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
    <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
    <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
    <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
    <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
    <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
    <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
    <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
    <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
    <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
    <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
    <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
    <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
    <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
    <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
</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 

任何和所有提示和提示表示赞赏!

最佳答案

Ionic 找不到平台,因为 <engine> config.xml 中缺少标签.尝试清理一下您的设置:

  • 运行 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命令只是通过cordova CLI而不是通过ionic CLI(运行时ionic cordova ... ionic CLI只是将cordova相关命令转发到cordova CLI,这可能会导致错误)。只是为了构建和运行应用程序,我使用组合命令,因为它更方便。

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

    关于ios - ionic 找不到平台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46697664/

    相关文章:

    ios - iOS后台任务选项有哪些

    ios - iOS 上不再收到 crashlytics 崩溃的消息

    javascript - jquery 移动按钮不出现

    ios - 如何检测表情符号和更改字体大小

    objective-c - 如何在没有 url 方案或外部服务器的情况下在 2 个本地 ios 应用程序之间共享文件?

    PHP - 正则表达式匹配带或不带国家代码的电话号码

    css - 如何停止屏幕从 Phonegap 应用程序顶部滚动?

    javascript - 无法在 Ionic 3 应用程序中导入 Amplitude SDK

    javascript - 如何自定义 ionic 选择和 ionic 选项菜单( ionic )

    javascript - Angular2渲染器: Svg rect is rendered but not showing in page