Skip to content

DeepBhupatkar/macOS-Chrome-Extension-Bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

macOS & Chrome Extension Native Messaging Chat

This project is a complete, working example of a real-time chat application that communicates between a native macOS application (built with Swift and SwiftUI) and a Google Chrome extension (built with JavaScript, HTML, and CSS).

It serves as a clear, modern template for developers looking to implement Chrome's Native Messaging API on macOS. The user interfaces for both the app and the extension popup.

Features

  • Real-time Bidirectional Communication: Send messages from the Chrome extension to the macOS app, and vice-versa.

Technologies Used

  • macOS App:
    • Swift
    • SwiftUI
    • Combine Framework for state management
  • Chrome Extension:
    • JavaScript (ES6)
    • HTML5
    • CSS3
  • Communication Protocol:
    • Native Messaging API (using Standard I/O)
    • JSON for message formatting

Setup and Running Instructions

This project includes an automated setup script to simplify the configuration process.

Step 1: Run the Setup Script

  1. Open your Terminal.
  2. Make the script executable by running the following command:
    chmod +x setup.sh
  3. Execute the script:
    ./setup.sh

The script will handle the following automatically:

  • Building the native macOS application in Xcode.
  • Finding the correct path to the app executable.
  • Configuring the native messaging manifest with this path.
  • Installing the manifest into the required Chrome directory.

Step 2: Configure the Extension ID

After the script finishes, it will print the final manual steps required. You just need to tell Chrome which extension is allowed to connect to the native app.

  1. Load the Extension: Open Chrome and go to chrome://extensions. Enable "Developer mode" and click "Load unpacked." Select the chrome-extension directory.
  2. Copy the ID: The "Native App Communicator" will appear. Copy its Extension ID.
  3. Update the Manifest: Open the installed manifest file by running the open ... command provided by the script.
  4. Paste the ID: In the file that opens, replace YOUR_CHROME_EXTENSION_ID with the ID you copied.
  5. Save the file.

Step 3: Run the Application!

  1. Run the macOS app from Xcode by selecting Product > Run (Cmd+R).
  2. In Chrome, click the extension's icon in the toolbar to open the chat popup.
  3. You can now send messages back and forth!

About

Demonstrates how to implement Chrome's Native Messaging API to connect a macOS application with a Chrome Extension.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors