dgb_nz
dgb_nz

Reputation: 251

cordova-plugin-webserver: app tries to load index.html before server has started

I've inherited a mobile project where I work which is using Ionic to build a hybrid mobile app. In iOS, I'm using the WKWebView instead of the native one, and accordingly a local webserver needs to run on the device in order to access local files.

The problem I'm having is that the app tried to load the index.html page before the web server has started and so I always just end up on a not found error page. The project builds just fine in XCode and loads up fine on emulators and an actual iPhone device. Below is the runtime log in XCode.

Any suggestions? Have spent ages searching trying to figure this out but still none the wiser. The original developer didn't have this issue and didn't know what was going on either, so we're a bit stuck.

objc[15705]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0xd73b400) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0xd5835d0). One of the two will be used. Which one is undefined.
2016-10-18 15:41:24.532393 Pond Mobile[15705:4405101] bundleid: com.networkforlearning.pondmobile, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-10-18 15:41:24.533854 Pond Mobile[15705:4405101] subsystem: com.apple.siri, category: Intents, enable_level: 1, persist_level: 1, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-18 15:41:24.593065 Pond Mobile[15705:4405217] subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.596956 Pond Mobile[15705:4405217] subsystem: com.apple.UIKit, category: HIDEventIncoming, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.624170 Pond Mobile[15705:4405209] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-18 15:41:24.629 Pond Mobile[15705:4405101] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/david/Library/Developer/CoreSimulator/Devices/E9039A9E-072A-4695-BECF-602652B235F1/data/Containers/Data/Application/7064EC16-1336-432A-A63B-8A68F2C83E92/Library/Cookies/com.networkforlearning.pondmobile.binarycookies
2016-10-18 15:41:24.636391 Pond Mobile[15705:4405101] subsystem: com.apple.libsqlite3, category: logging, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.676830 Pond Mobile[15705:4405101] subsystem: com.apple.UIKit, category: StatusBar, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.731 Pond Mobile[15705:4405101] Apache Cordova native platform version 3.9.2 is starting.
2016-10-18 15:41:24.732 Pond Mobile[15705:4405101] Multi-tasking -> Device: YES, App: YES
2016-10-18 15:41:24.740 Pond Mobile[15705:4405101] Unlimited access to network resources
2016-10-18 15:41:24.823 Pond Mobile[15705:4405101] Using a WKWebView
2016-10-18 15:41:24.850863 Pond Mobile[15705:4405101] subsystem: com.apple.SystemConfiguration, category: SCNetworkReachability, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.870598 Pond Mobile[15705:4405101] subsystem: com.apple.UIKit, category: GestureEnvironment, enable_level: 0, persist_level: 0, default_ttl: 1, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-18 15:41:24.879 Pond Mobile[15705:4405101] [CDVTimer][base64togallery] 0.075996ms
2016-10-18 15:41:24.908 Pond Mobile[15705:4405101] [CDVTimer][file] 28.217018ms
2016-10-18 15:41:24.930 Pond Mobile[15705:4405101] [CDVTimer][statusbar] 21.950006ms
2016-10-18 15:41:24.935036 Pond Mobile[15705:4405101] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/david/Library/Developer/CoreSimulator/Devices/E9039A9E-072A-4695-BECF-602652B235F1/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-10-18 15:41:24.937783 Pond Mobile[15705:4405101] [MC] Filtering mail sheet accounts for bundle ID: com.networkforlearning.pondmobile, source account management: 1
2016-10-18 15:41:24.941691 Pond Mobile[15705:4405101] [MC] Result: NO
2016-10-18 15:41:24.941 Pond Mobile[15705:4405101] [CDVTimer][socialsharing] 10.565996ms
2016-10-18 15:41:24.943 Pond Mobile[15705:4405101] [CDVTimer][keyboard] 1.223028ms
2016-10-18 15:41:24.943 Pond Mobile[15705:4405101] [CDVTimer][TotalPluginStartup] 64.150035ms
2016-10-18 15:41:24.943 Pond Mobile[15705:4405101] ERROR: Start Page at 'http://localhost:12344' was not found.
[DEBUG] Did open IPv4 listening socket 9
[DEBUG] Did open IPv6 listening socket 10
[INFO] GCDWebServer started on port 12344 and reachable at http://localhost:12344/
2016-10-18 15:41:24.955 Pond Mobile[15705:4405101] Started http daemon: http://localhost:12344/ 
2016-10-18 15:41:24.955 Pond Mobile[15705:4405101] active
2016-10-18 15:41:24.961319 Pond Mobile[15705:4405101] subsystem: com.apple.BackBoardServices.fence, category: App, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-19 08:35:33.688606 Pond Mobile[15705:4405101] subsystem: com.apple.UIKit, category: Touch, enable_level: 0, persist_level: 0, default_ttl: 1, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-19 08:35:33.785352 Pond Mobile[15705:4405101] subsystem: com.apple.UIKit, category: Gesture, enable_level: 0, persist_level: 0, default_ttl: 1, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-19 08:35:33.927915 Pond Mobile[15705:4405101] subsystem: com.apple.UIKit, category: GestureExclusion, enable_level: 0, persist_level: 0, default_ttl: 1, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0

Upvotes: 0

Views: 647

Answers (2)

dgb_nz
dgb_nz

Reputation: 251

Turns out I had to change <content src="http://localhost:20000" /> to <content src="http://localhost:20000/index.html" /> in my config.xml and now it works

Upvotes: 0

Sam5487
Sam5487

Reputation: 679

This seems to be a common problem now with an xCode/iOS update (probably why you got it and not the previous developer).

From another SO question (link below):

If your app (or dependencies, such as Pods) uses framework, that uses explicit (or implicit) PhotoLibraryServices.framework or AssetsLibraryServices.framework as dependency, Xcode warns you (even if you are using only one of them). It might be Photos/PhotosUI.framework or AssetsLibrary.framework, or another (I don't have full list of dependencies, but it is possible).

What is the problem?

Class with name PLBuildVersion is defined in both PhotoLibraryServices.framework and AssetsLibraryServices.framework. Class name is unique in Objective-C (you can't define 2 classes with same name), so it is undefined which one will be used in runtime.

Checkout this answer from stackoverflow as well as stackoverflow to try and rid this problem. If that doesn't work then take a look at GitHub as well, (someone with similar issues, very recent) could be a bug in your code.

Upvotes: 1

Related Questions