无法使用cordova从bundle.js加载主对象

我知道有重复的问题,但答案不适合我。

我有一个在桌面上工作正常的Web应用程序。 我想用cordova来包装它的移动版本。

我无法加载browserified捆绑软件,无法使用jquery token输入进行调用。

在我的index.html中:

  <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
  <script type="text/javascript" src="js/jquery.tokeninput.js"></script>

  <script type="text/javascript" src="js/bundle.js"></script> 

主应用程序对象,比如myApp,位于bundle.js中。

在我的index.html中有一个额外的脚本,用来绑定一个搜索函数和jquery tokeninput,它将启动myApp.main( keyword )

index.html ,我将使用<body>末尾的脚本绑定函数:

$(document).ready(function() { alert('test script loaded from index.html') // does not fire) }

在我的cordova的index.js中,我正在尝试一个基本的测试:

onDeviceReady:function(){this.receivedEvent('deviceready');

   alert('test from cordova index.js'); // ok
    if ($) alert('$ loaded') // ok
    if ($.tokenInput) alert ('$.tokenInput') // ok

    try {
        window.myApp = myApp

    } catch(err) {
        console.log('no app?', err);
        alert(err);  // cannot find variable myApp
    }

},

看起来这里有两个错误:我无法在index.html上执行jquery(document).ready(),并且bundle.js似乎也没有加载。

这是一个最简单的方式来包装在科尔多瓦browseover的wep应用程序?

下面,如果有帮助,ios模拟器的控制台日志; cordova for iOS@4.0.0和编译器xcode 6.2


Oct  1 19:17:41 my-computer.local CoreSimulatorBridge[97582]: LaunchServices: installing app for existing placeholder <LSApplicationProxy: 0x7fb864a17ce0> com.example.hello
Oct  1 19:17:41 my-computer.local CoreSimulatorBridge[97582]: LaunchServices: Not creating progress for <LSApplicationProxy: 0x7fb864a17ce0> com.example.hello since it is not a placeholder.
Oct  1 19:17:41 my-computer.local installd[97570]: 0x10e924000 -[MIClientConnection _doBackgroundInstallationForPath:withOptions:completion:]: Install of "/Users/gg4u/Sites/learndiscovery_light/hello/platforms/ios/build/emulator/HelloWorld.app" type Developer requested by CoreSimulatorBridge (pid 97582)
Oct  1 19:17:41 my-computer.local installd[97570]: 0x10e924000 MDMCreateDeltaDirectory: calling MDMDirectoryDiff with:
    state->old_bundle: /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Containers/Bundle/Application/6C12C45A-35B5-40BF-B9C9-24A3798FF47B/HelloWorld.app
    state->new_bundle: /Users/gg4u/Sites/learndiscovery_light/hello/platforms/ios/build/emulator/HelloWorld.app
    state->dst_bundle: /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Library/Caches/com.apple.mobile.installd.staging/temp.DNjSbw/extracted/Payload//HelloWorld.app, binaryDiff flag: FALSE
        dst_ipa: /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Library/Caches/com.apple.mobile.installd.staging/temp.DNjSbw/extracted
Oct  1 19:17:41 my-computer.local installd[97570]: 0x10e924000 createDictFromFile: open failed for /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Containers/Bundle/Application/6C12C45A-35B5-40BF-B9C9-24A3798FF47B/ManifestCache.plist : No such file or directory
Oct  1 19:17:41 my-computer.local installd[97570]: 0x10e595000 __MDMDirectoryDiff_block_invoke29: calling writeDictToFile with: /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Library/Caches/com.apple.mobile.installd.staging/temp.DNjSbw/extracted/ManifestCache.plist
Oct  1 19:17:41 my-computer.local installd[97570]: 0x10e595000 writeDictToFile: ==== Successfully wrote Manifest cache to /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Library/Caches/com.apple.mobile.installd.staging/temp.DNjSbw/extracted/ManifestCache.plist
Oct  1 19:17:42 my-computer.local installd[97570]: 0x10e924000 -[MIInstaller performInstallationWithError:]: Installing <MIInstallableBundlePatch ID=com.example.hello; Version=1.0.0, ShortVersion=1.0.0>
Oct  1 19:17:42 my-computer.local installd[97570]: 0x10e924000 -[MIInstallableBundlePatch applyPatchWithError:]: Attempting patch update of com.example.hello from 1.0.0 (1.0.0) to 1.0.0 (1.0.0)
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: Killing com.example.hello for termination assertion
Oct  1 19:17:42 my-computer.local pkd[97591]: releasing plug-in hold 1C539A6F-9B76-4EB2-BFEC-C78D1FBC2756 for dead client pid 97574
Oct  1 19:17:42 gg4u-2 com.apple.CoreSimulator.SimDevice.967377E0-2418-4069-8B52-8447DC3C273F.launchd_sim[97561] (UIKitApplication:com.example.hello[0xea3f][1729]): Service exited due to signal: Killed: 9
Oct  1 19:17:42 my-computer.local installd[97570]: 0x10e924000 -[MIInstallableBundle _refreshUUIDForContainer:withError:]: Data container for com.example.hello is now at /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Containers/Data/Application/D5CC347D-D8B8-43FF-BFF6-453C3F747481
Oct  1 19:17:42 my-computer.local installd[97570]: 0x10e924000 -[MIContainer makeContainerLiveReplacingContainer:withError:]: Made container live for com.example.hello at /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Containers/Bundle/Application/8F096F99-3B40-4124-B406-70C907FEA3CE
Oct  1 19:17:42 my-computer.local installd[97570]: 0x10e924000 -[MIInstaller performInstallationWithError:]: Staging: 0.06s; Waiting: 0.00s; Installation: 0.05s; Overall: 0.11s
Oct  1 19:17:42 my-computer.local CoreSimulatorBridge[97582]: LaunchServices: NotifiedObservers <LSApplicationProxy: 0x7fb863f0df70> com.example.hello was installed
Oct  1 19:17:42 my-computer.local lsd[97589]: LaunchServices: Updating identifier store
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: [com.example.hello (1729)] Kill failed. Error: No such process (3)
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: libMobileGestalt MobileGestalt.c:841: still-camera is static and will never generate a notification
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: libMobileGestalt MobileGestalt.c:841: stand-alone-contacts is static and will never generate a notification
Oct  1 19:17:42 my-computer.local /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/libexec/lsd[97589]: LaunchServices: Failed to set the data protection class for /Users/gg4u/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/tmp/com.apple.IconsCache/com.example.hello_CFBundleIcon[15]
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: Installed apps did change.
    Added: {(
    )}
    Removed: {(
    )}
    Modified: {(
        "com.example.hello"
    )}
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.MobileSMS
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: throwing out icon because its isn't visible in the model : node=<SBApplicationIcon: 0x7f9fc8b25e70; nodeID: "com.apple.camera"> com.apple.camera
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.weather
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.mobiletimer
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.videos
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.mobilenotes
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.reminders
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.stocks
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.iBooks
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.MobileStore
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.AppStore
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.Bridge
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.facetime
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.calculator
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.podcasts
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.compass
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.tips
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.VoiceMemos
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.mobilephone
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.mobilemail
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: could not find icon for representation -> com.apple.Music
Oct  1 19:17:42 my-computer.local SpringBoard[97574]: Application 'UIKitApplication:com.example.hello[0xea3f]' exited abnormally via signal.
Oct  1 19:17:42 gg4u-2 assertiond[97578]: assertion failed: 13F34 12D508: assertiond + 12446 [6756D728-8EE6-3DA2-B069-3EA61C107DF8]: 0x1
Oct  1 19:17:43 --- last message repeated 2 times ---
Oct  1 19:17:43 gg4u-2 HelloWorld[1847]: assertion failed: 13F34 12D508: libxpc.dylib + 68972 [701C1196-AADE-335F-B7E6-B42F53982A50]: 0x7d
Oct  1 19:17:43 my-computer.local HelloWorld[1847]: DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/my-computer/Library/Developer/CoreSimulator/Devices/967377E0-2418-4069-8B52-8447DC3C273F/data/Containers/Data/Application/D5CC347D-D8B8-43FF-BFF6-453C3F747481/Library/Cookies/Cookies.binarycookies
Oct  1 19:17:43 gg4u-2 assertiond[97578]: assertion failed: 13F34 12D508: assertiond + 12446 [6756D728-8EE6-3DA2-B069-3EA61C107DF8]: 0x1
Oct  1 19:17:43 my-computer.local SpringBoard[97574]: [MPUSystemMediaControls] Updating supported commands for now playing application.
Oct  1 19:17:43 my-computer.local HelloWorld[1847]: Apache Cordova native platform version 4.0.0 is starting.
Oct  1 19:17:43 my-computer.local HelloWorld[1847]: Multi-tasking -> Device: YES, App: YES
Oct  1 19:17:43 my-computer.local webinspectord[97602]: Unable to get entitlements for client task to verify entitlement com.apple.private.webinspector.allow-remote-inspection. Error: Error Domain=NSPOSIXErrorDomain Code=-1 "The operation couldn’t be completed. (POSIX error -1 - Unknown error: -1)"
链接地址: http://www.djcxy.com/p/61941.html

上一篇: unable to load main object from bundle.js using cordova

下一篇: Cordova Jquery Mobile Local Notification onclick change page