null-dev / firefox-profile-switcher-connector

Native connector software for the 'Profile Switcher for Firefox' extension.
GNU General Public License v3.0
125 stars 25 forks source link

macos support #1

Closed pfriesch closed 3 years ago

pfriesch commented 3 years ago

What is currently missing for macos support? (except signing the executable) I am also happy to take a look and create a pull request, but I would appreciate some hints on the current state then 👍

ghost commented 3 years ago

ikr. I really hope a macos version comes out soon

th3fallen commented 3 years ago

+1 to this

rinkjames commented 3 years ago

+1

MattHardcastle commented 3 years ago

I compiled the connector on macOS and manually linked the manifest in Firefox. After that, I used the plugin to create a new profile and launch it. Looks like the guts work fine on macOS.

@null-dev created a Homebrew tap repository for the plugin. I bet they just need to wrap that and the macOS build up to get this running.

I’ll take a stab at replicating the macOS build and setting up the tap.

In case it’s helpful, here’s my quick and dirty approach to get it working:

git clone git@github.com:null-dev/firefox-profile-switcher-connector.git
cd firefox-profile-switcher-connector
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
cargo build
ln $(pwd)/target/debug/firefox_profile_switcher_connector /usr/local/bin/ff-pswitch-connector
ln $(pwd)/manifest/manifest-mac.json ~/Library/Application\ Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json

And the following is the version macOS I’m running:

$ sw_vers
ProductName:    macOS
ProductVersion: 11.3.1
BuildVersion:   20E241
MattHardcastle commented 3 years ago

I've added newer install instructions below.

I've been able to get the connector building and installing with the follow Formula:

# Formula/firefox-profile-switcher-connector.rb
class FirefoxProfileSwitcherConnector < Formula
  desc "The native component of the Profile Switcher for Firefox extension."
  homepage "https://github.com/null-dev/firefox-profile-switcher-connector"
  url "https://github.com/null-dev/firefox-profile-switcher-connector/archive/refs/tags/v0.0.6.tar.gz"
  sha256 "40f0429f2aeebd128072a75674e132477ef1f16ce03d77704fa55395624a62fc"
  version "0.0.6"
  depends_on "rust" => :build

  def install
    system "cargo", "build", "--release", "--bin", "firefox_profile_switcher_connector"
    prefix.install "manifest/manifest-mac.json" => "ax.nd.profile_switcher_ff.json"
    bin.install "target/release/firefox_profile_switcher_connector" => "ff-pswitch-connector"
  end

  def caveats
    <<~EOS
       The plugin manifest needs to be installed in Firefox. Run the following to install it:
        "ln -s #{HOMEBREW_CELLAR}/firefox-profile-switcher-connector/0.0.6/ax.nd.profile_switcher_ff.json /Users/#{ENV["USER"]}/Library/Application\ Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json"
    EOS
  end

end

(I'd add that as a PR to homebrew-firefox-profile-switcher but I can't create a PR on an empty repository. 🥲)

The issue is, I can't install the manifest in Firefox with Homebrew. When I attempt to copy it I get a "Operation not permitted" error. That error is probably SIP blocking full disk access for brew.

I'm going to see if I can get cargo to produce a pkg file that will install the manifest in the correct place. 🤞🏻

(edit: updated Formula w/caveat to link manifest.)

th3fallen commented 3 years ago

I compiled the connector on macOS and manually linked the manifest in Firefox. After that, I used the plugin to create a new profile and launch it. Looks like the guts work fine on macOS.

@null-dev created a Homebrew tap repository for the plugin. I bet they just need to wrap that and the macOS build up to get this running.

I’ll take a stab at replicating the macOS build and setting up the tap.

In case it’s helpful, here’s my quick and dirty approach to get it working:

git clone git@github.com:null-dev/firefox-profile-switcher-connector.git
cd firefox-profile-switcher-connector
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
cargo build
ln $(pwd)/target/debug/firefox_profile_switcher_connector /usr/local/bin/ff-pswitch-connector
ln $(pwd)/manifest/manifest-mac.json ~/Library/Application\ Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json

And the following is the version macOS I’m running:

$ sw_vers
ProductName:  macOS
ProductVersion:   11.3.1
BuildVersion: 20E241

can confirm this worked for me

null-dev commented 3 years ago

@MattHardcastle Wow, thank you so much for writing the formula! I'm a total noob regarding packaging apps for Mac OS so this is a big help. I've added an empty commit to the repo so now you should be able to open a PR.

MattHardcastle commented 3 years ago

@null-dev No problem. Thanks for making the plugin! I create a PR for the formula. It's not able to install the manifest. I have to ask the installer to manually link it, but it does the build and installs the connector.

MattHardcastle commented 3 years ago

The tap is live. To install the connector w/Homebrew run the following:

brew tap null-dev/firefox-profile-switcher
brew install firefox-profile-switcher-connector

Pay special attention to the caveat section while installing.

The connector is not working on Apple Silicon. It works in Rosetta.

MattHardcastle commented 3 years ago

I asked the Homebrew folks if it's possible to create a file in ~/Library. It's not. The other option is to bundle this as a pkg, have the pkg create the manifest, then install the package as a cask.

The problem is, Rust doesn't appear to support universal binaries -- they are working on it -- so creating a pkg that works on Apple Silicon and Intel Macs may not be possible until Rust supports them. (This isn't an issue with the current Homebrew install because it's built from source on every install.) Creating a universal binary is possible by compiling a aarch64-apple-darwin and x86_64-apple-darwin target and using the lipo command to merge them.

I see a couple of options (in no particular order):

  1. Reimplement in a language that's supported on all platforms and uses the Clang toolchain, which supports universal binaries, on macOS. Maybe C++ and CMake. Lipo supports rust compiled binaries. There is no need to use the full clang toolchain.
  2. Deal with the caveat message and call it supported(ish). Then reevaluate once Rust supports universal binaries.
  3. Create a package for each architecture universal app package, add them to the downloads page, and forget about Homebrew.

(Edited: I learned more about universal binaries and how to build them.)

null-dev commented 3 years ago

The latest version now includes instructions on how to install the connector on Mac OS. Thanks again Matt!