diff --git a/test-apps/ios-test-app/App/App/ViewController.swift b/test-apps/ios-test-app/App/App/ViewController.swift index 304064d..1b69351 100644 --- a/test-apps/ios-test-app/App/App/ViewController.swift +++ b/test-apps/ios-test-app/App/App/ViewController.swift @@ -12,6 +12,7 @@ import UIKit import Capacitor +import WebKit /** * Main view controller extending Capacitor's bridge view controller @@ -22,6 +23,14 @@ class ViewController: CAPBridgeViewController { override func viewDidLoad() { super.viewDidLoad() + // SANITY CHECK: Try loading a simple HTML file directly + print("ViewController: Starting sanity check...") + + // Wait a moment for Capacitor to initialize, then check + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { + self.performSanityCheck() + } + // Debug: Print bridge configuration print("ViewController: Bridge initialized") if let bridge = self.bridge { @@ -41,6 +50,60 @@ class ViewController: CAPBridgeViewController { initializePlugin() } + /** + * Sanity check: Try to load a simple HTML file to verify WebView works + */ + private func performSanityCheck() { + print("ViewController: Performing sanity check...") + + // Check if we have a bridge and webView + guard let bridge = self.bridge else { + print("❌ SANITY CHECK FAILED: Bridge is nil!") + return + } + + guard let webView = bridge.webView else { + print("❌ SANITY CHECK FAILED: WebView is nil!") + return + } + + print("✅ Bridge and WebView exist") + print("WebView URL: \(webView.url?.absoluteString ?? "nil")") + + // Try to load test.html directly + if let bundlePath = Bundle.main.resourcePath, + let testHtmlPath = bundlePath.appending("/public/test.html") as String?, + FileManager.default.fileExists(atPath: testHtmlPath) { + let fileURL = URL(fileURLWithPath: testHtmlPath) + print("✅ Found test.html at: \(fileURL.path)") + webView.loadFileURL(fileURL, allowingReadAccessTo: fileURL.deletingLastPathComponent()) + } else { + print("❌ test.html not found in bundle") + // Try index.html instead + if let bundlePath = Bundle.main.resourcePath, + let indexHtmlPath = bundlePath.appending("/public/index.html") as String?, + FileManager.default.fileExists(atPath: indexHtmlPath) { + let fileURL = URL(fileURLWithPath: indexHtmlPath) + print("✅ Found index.html at: \(fileURL.path)") + webView.loadFileURL(fileURL, allowingReadAccessTo: fileURL.deletingLastPathComponent()) + } else { + print("❌ index.html also not found") + // List what's actually in the bundle + if let bundlePath = Bundle.main.resourcePath { + print("Bundle resource path: \(bundlePath)") + if let contents = try? FileManager.default.contentsOfDirectory(atPath: bundlePath) { + print("Bundle contents: \(contents)") + } + if let publicPath = bundlePath.appending("/public") as String?, + FileManager.default.fileExists(atPath: publicPath), + let publicContents = try? FileManager.default.contentsOfDirectory(atPath: publicPath) { + print("public/ contents: \(publicContents)") + } + } + } + } + } + /** * Initialize plugin and register native fetcher * Equivalent to PluginApplication.onCreate() on Android diff --git a/test-apps/ios-test-app/App/App/public/test.html b/test-apps/ios-test-app/App/App/public/test.html new file mode 100644 index 0000000..14cea6c --- /dev/null +++ b/test-apps/ios-test-app/App/App/public/test.html @@ -0,0 +1,24 @@ + + +
+ + +If you see this, the WebView is working!
+HTML is loading correctly!
+ + +