Swiftpack.co - Package - kfix/MacPin

MacPin

MacPin creates pseudo-browsers managed with internal JavaScripts.

screenie

The produced apps can be run on any Mac with Safari 11.1 installed.

While less featureful than Electron (no Node and Chromium here),
they are slim and fast like MacGap, thanks to use of macOS-shipped components.

Each app is about 15MB, which is mostly SwiftSupport libraries.
When Swift reaches ABI stability, those could be stripped away to leave behind only a 2MiB binary!

Project Status

Uses swift 4.0 & WKWebView instead of ObjC & WebView like ye old MacGap.
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 (or Springboard on iOS), tabbing App Switcher, & Launchpad.
They are fully self-sufficient, so you can copy them to other systems without needing a base App.

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

Building swift4.0 branch requires OSX 10.12 "Sierra" with Xcode 9 installed.
All other branches are obsolete.

Included Apps in the Release

da G-Suite

Face Holes

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 scripting controlling 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

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

Its written in Swift using WKWebView and NSTabViewController with a fully programmatic NIB-less UI layout.
You need Xcode 9 installed on macOS 12.12+ to get the Swift compiler and Cocoa headers.
make & $EDITOR are your hammer and chisel.

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

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|repl) can also be remotely inspected from Safari->Develop->

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

use MacPin to make hybrid apps from existing projects

cd ~/src/SomeWebApp
test -d browser/SomeWebApp.com &&
  make -C ~/src/MacPin macpin_sites=$PWD/browser appdir=$PWD/hybrid xcassetdir=$PWD/hybrid $PWD/hybrid/SomeWebApp.com.app
open hybrid/SomeWebApp.com.app

iOS

~~Basic support has landed for generating iOS apps.~~
iOS has not been migrated to swift4 yet.

Anyhow, its kinda pointless for most of sites/* since native apps exist for all of them.
But maybe you want to quickly package a React.js application for offline mobile use...

iOS 10 has some PWA support now... so I may or may not revive */iOS/*
Perhaps when macOS 10.14 ships with "Marzipan" (UIKit)...

can i haz LinPin? WinPin?

Ok! A stubby port running /Lin/main.swift + AppScriptRuntime() using a "JSConly" build of JavaScriptCore
would be a good proof of concept for new MacPin platforms to spawn from.

(lol, y u no like V8 google?)

Swift runs on Lin/Win now and so do platform-ports of JavaScriptCore and WebKit, although without supported/prebuilt libs.

However, ObjC bindings for both Swift and the WebKit frameworks are not enabled (or possible?) outside of macOS.
So some additional pure-Swift bindings to the WebKit C/++ APIs will be needed before implementing symmetric platform-classes
And a some refactoring in AppScriptRuntime.swift to totally strip it of ObjC...

Also NSWindow & NSTabViewController aren't cross-platform but could be straightforwardly implement equivalent UIs from MFC or GTK.
Swift bindings to those toolkits would also be needed.

tvPin? No WKWebView on tvOS officially

Other WebKit browsers:

Github

link
Stars: 230
Help us keep the lights on

Dependencies

Used By

Total:

Releases

v1.4.0 - Dec 6, 2015

MacPin x86_64 build of version 1.4.0

v1.3.0 - Jun 30, 2015

MacPin x86_64 build of version 1.3.0

v1.2.1 - Mar 12, 2015

MacPin build of version 1.2.1

v1.2.0 - Feb 26, 2015

MacPin build of version 1.2.0

v1.1.0 - Feb 12, 2015

MacPin build of version 1.1.0