Swiftpack.co - kfix/MacPin as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by kfix.
kfix/MacPin v2019.5.0
a webapp container & site specific browser made from WebKit.swift and JavaScriptCore
⭐️ 308
🕓 30 weeks ago
iOS macOS
.package(url: "https://github.com/kfix/MacPin.git", from: "v2019.5.0")


MacPin creates pseudo-browsers managed with internal JavaScripts.


While less featureful than Electron-based apps (no Node and Chromium here),
they are slimmer due to nearly-exclusive use of OS-shipped components.

$ du -hs build/macosx-x86_64-apple-macosx10.13/apps/{Slack,MacPin}.app/
2.0M	build/macosx-x86_64-apple-macosx10.13/apps/Slack.app/  (mostly Assets.car icons)
4.0M	build/macosx-x86_64-apple-macosx10.13/apps/MacPin.app/ (icons + 1.5MB MacPin.framework)

Project Status

Uses swift 5.4 & WKWebView. sites/**/main.js tries to support some Electron idioms.

Apps present within a semi-featured Browser UI, having just an "OmniBox" and tab buttons.

MacPin-built apps are normal .app bundles that show in the Dock, App Switcher, & Launchpad.

They are dependent on the core MacPin.app (4.5MB) to be registered on the system, since it contains the MacPin.framework.

Custom URL schemes can also be registered to launch a MacPin App from any other app on your Mac.

Included Apps in the Release



et cetera

Creating an App

Some call these Apps Site-specific Browsers.

"Psuedo-browser" has a better ring to it and MacPin tries to support "normal" browsing behavior,
(address/status bars, middle-click, pop-ups) complementary to any scripts managing the app.

cd ~/src/MacPin
mkdir sites/MySite
$EDITOR sites/MySite/main.js

# find a large & square .png for the app, like an App Store image.
# ideally it should have a transparent back field
cp ~/Pictures/MySite.png sites/MySite/icon.png

make test_MySite
# test, tweak, repeat

make install
open -a MySite.app

Work is ongoing to make editing and creating app scripts easier, without requiring Xcode:CLI tools.

App porting issues

  • DRM: Many sites (Spotify, Netflix) are using Chrome/FF only DRMs (Widevine) but Apple-built WebKit only supports FairPlay DRM.
  • WebRTC: WebKit is compatible with H264 & VP8 codecs, but Google Chrome is pushing hardware-unaccelerated VP9 on all fronts (incl. general <video>).

sample main.js

/*eslint-env es6*/
/*eslint eqeqeq:0, quotes:0, space-infix-ops:0, curly:0*/
"use strict";

const {app, WebView, BrowserWindow} = require("@MacPin");

const browser = new BrowserWindow();

app.on('AppFinishedLaunching', function() {
	browser.tabSelected = new WebView({
		url: "http://vine.co",
		transparent: true

Hacking MacPin

Building main branch requires macOS 11 "Big Sur" with Xcode 12.5+.

All other branches are obsolete & archived for users locked on older macOS (hardware),
but they will recieve no updates.

The UI is fully-programmatic (no NIBs or storyboard) using NSTabViewController APIs to containing tab's WKWebViews.
The AppScriptRuntime that evalutuates main.js scripts is cobbled together from JavaScriptCore's C and ObjC APIs.

MacPin's UI ClassTypes are bridged to ObjC by SwiftCore and once more into Javascript space using the JSWrapperMap facility in the Apple JSC.

Swift Package Manager and GNU Make are the actual builders of the project, Xcode and xxcodebuild are not used or supported.

basic workflow

vim Sources/MacPin/*.swift
vim sites/MacPin/main.js
make test.app
# CTRL-D when finished debugging ...

JavaScript environment

The JavaScript API for *.app/main.js vaguely mimics Electron's main.js.
If you want to play with it, run any MacPin app with the -i argument in Terminal to get a JS console (or make repl).

Debug builds (make test|test.app|apirepl) can also be remotely inspected from Safari->Develop->

  • Remote Inspection appears broken ATM


Some things I just haven't had need to write, but wouldn't mind having:

  • Global history
  • Undo/redo for Tab closings
  • UI wizard to generate MacPin apps from MacPin.app itself (no Command Line Tools or Xcode!)
    • maybe using JavaScript-for-Automation (JXA)?
  • ReactNative, Vue/Weex, or NativeScript bindings in main.js for custom Browser UIs

Other WebKit browsers:


Stars: 308
Last commit: 25 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 years ago

MacPin x86_64 build of version 2019.5.0

Last one that works on El Capitan

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics