Cordova 'NSInternalInconsistencyException'错误,原因是config.xml文件不存在。

6

我正在尝试在iOS上运行一个新的Hello World Cordova应用程序。它在启动画面处不断崩溃。

但我一直收到以下错误:

'NSInternalInconsistencyException',原因:'ERROR:config.xml不存在。请运行cordova-ios/bin/cordova_plist_to_config_xml路径/到/项目。

当我导航到hellocordva.xcodeproj并运行

run cordova-ios/bin/cordova_plist_to_config_xml .时,它不是一个命令。

这是testapp/platforms/ios/HelloCordova中的config.xml内容:

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
    <preference name="AllowInlineMediaPlayback" value="false" />
    <preference name="BackupWebStorage" value="cloud" />
    <preference name="DisallowOverscroll" value="false" />
    <preference name="EnableViewportScale" value="false" />
    <preference name="KeyboardDisplayRequiresUserAction" value="true" />
    <preference name="MediaPlaybackRequiresUserAction" value="false" />
    <preference name="SuppressesIncrementalRendering" value="false" />
    <preference name="SuppressesLongPressGesture" value="false" />
    <preference name="Suppresses3DTouchGesture" value="false" />
    <preference name="GapBetweenPages" value="0" />
    <preference name="PageLength" value="0" />
    <preference name="PaginationBreakingMode" value="page" />
    <preference name="PaginationMode" value="unpaginated" />
    <feature name="LocalStorage">
        <param name="ios-package" value="CDVLocalStorage" />
    </feature>
    <feature name="HandleOpenUrl">
        <param name="ios-package" value="CDVHandleOpenURL" />
        <param name="onload" value="true" />
    </feature>
    <feature name="IntentAndNavigationFilter">
        <param name="ios-package" value="CDVIntentAndNavigationFilter" />
        <param name="onload" value="true" />
    </feature>
    <feature name="GestureHandler">
        <param name="ios-package" value="CDVGestureHandler" />
        <param name="onload" value="true" />
    </feature>
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
</widget>

这是testapp根目录内的config.xml文件

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap = "http://phonegap.com/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

以下是完整的 Xcode 错误信息,希望能有所帮助:

2016-03-23 09:04:35.758 HelloCordova[7284:185520] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/ibraheemabukhdair/Library/Developer/CoreSimulator/Devices/364F5298-04FE-4875-BE94-DEF9F74EA607/data/Containers/Data/Application/AD59ED2C-1BA5-4639-9260-CFF211D7C527/Library/Cookies/io.cordova.hellocordova.binarycookies
2016-03-23 09:04:35.803 HelloCordova[7284:185520] Apache Cordova native platform version 4.0.1 is starting.
2016-03-23 09:04:35.803 HelloCordova[7284:185520] Multi-tasking -> Device: YES, App: YES
2016-03-23 09:04:35.803 HelloCordova[7284:185520] *** Assertion failure in -[MainViewController parseSettingsWithParser:], /Users/ibraheemabukhdair/components/cordova/testapp/platforms/ios/CordovaLib/Classes/Public/CDVViewController.m:149
2016-03-23 09:04:35.805 HelloCordova[7284:185520] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ERROR: config.xml does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000106eb1d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001068fcdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000106eb1bea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x0000000106546d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   HelloCordova                        0x00000001063b405e -[CDVViewController parseSettingsWithParser:] + 478
    5   HelloCordova                        0x00000001063b42fe -[CDVViewController loadSettings] + 110
    6   HelloCordova                        0x00000001063b38a9 -[CDVViewController __init] + 1017
    7   HelloCordova                        0x00000001063b3962 -[CDVViewController initWithNibName:bundle:] + 162
    8   HelloCordova                        0x00000001063b30a9 -[MainViewController initWithNibName:bundle:] + 121
    9   HelloCordova                        0x00000001063b3abe -[CDVViewController init] + 62
    10  HelloCordova                        0x00000001063b315e -[MainViewController init] + 62
    11  HelloCordova                        0x00000001063b2fa3 -[AppDelegate application:didFinishLaunchingWithOptions:] + 115
    12  UIKit                               0x0000000107a869ac -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
    13  UIKit                               0x0000000107a87c0d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
    14  UIKit                               0x0000000107a8e568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
    15  UIKit                               0x0000000107a8b714 -[UIApplication workspaceDidEndTransaction:] + 188
    16  FrontBoardServices                  0x000000010c4b58c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    17  FrontBoardServices                  0x000000010c4b5741 -[FBSSerialQueue _performNext] + 178
    18  FrontBoardServices                  0x000000010c4b5aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    19  CoreFoundation                      0x0000000106dd7301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x0000000106dcd22c __CFRunLoopDoSources0 + 556
    21  CoreFoundation                      0x0000000106dcc6e3 __CFRunLoopRun + 867
    22  CoreFoundation                      0x0000000106dcc0f8 CFRunLoopRunSpecific + 488
    23  UIKit                               0x0000000107a8af21 -[UIApplication _run] + 402
    24  UIKit                               0x0000000107a8ff09 UIApplicationMain + 171
    25  HelloCordova                        0x00000001063b2f11 main + 65
    26  libdyld.dylib                       0x0000000109d5392d start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我遇到了相同的问题。当我将“主要内容”从一个项目复制到另一个项目时。 - Poonam
我不记得我是如何解决这个问题的。很抱歉 :( - Train
2个回答

10

您可以通过将 config.xml 添加到 Targets>Build Phases>Copy Bundle Resources 来解决此问题。


1

我遇到了类似的错误,这是因为文件实际上缺失了。在XCode中重命名项目后出现了这个问题。 删除XCode项目并重新构建解决了这个问题:

rm -rf platforms/ios
phonegap build ios  # or cordova build ios

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接