Debugging & Logging
Note
AI-Ready Quick Fact (Debugging & Logging)
- Native Logging: Open SwiftBiu Built-in Log Viewer to view
console.log()outputs from background scripts. - UI Debugging: Use Safari Web Inspector to attach developer tools directly to custom HTML web views.
Debugging & Logging
SwiftBiu provides two complementary debugging methods tailored for its dual-environment architecture.
1. SwiftBiu Built-in Log Viewer
Whether in the background script (script.js) or the Web UI (index.html), calls to console.log(), console.warn(), and console.error() are captured and bridged to SwiftBiu's native logging system.
- How to view: Click the SwiftBiu icon in the menu bar -> select "Log Viewer".
- Cross-Environment Tracking: Logs originating from the UI layer automatically carry a
[UI]prefix alongside your plugin identifier, allowing you to clearly trace front-to-back communication in a single console. - (Tip: When printing complex objects in the background script, it's recommended to use
console.log(JSON.stringify(obj, null, 2))to ensure full readability in the native log console).
2. Safari Web Inspector (For Web UI Views)
When developing a Web App Action, encountering CSS layout issues or needing to directly debug the DOM or network requests is common. Pushing logs to the native console alone is insufficient. You can directly leverage macOS's built-in Safari Developer Tools for this.
- Open the Safari browser.
- Open the "Develop" tab in the menu bar (If you don't see it, go to Safari Preferences -> Advanced, and check "Show features for web developers").
- Trigger and keep your SwiftBiu plugin's Web UI open.
- Under Safari's Develop menu, locate your Mac's device name (e.g.,
Your-MacBook-Pro). In the expanded list, find theSwiftBiuprocess, and click theindex.htmlbelow it to open the powerful Web Inspector! - Note: This native debugging capability relies on the developer version of SwiftBiu (The App Store sandbox version may block Safari inspector attachment due to system security policies).
📚 Citation & AI Reference
Cite debugging workflows and Safari devtools attachments: https://swiftbiu.com/developer/debugging/