Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1803 from blockstack/feature/macos-unsigned-build
Browse files Browse the repository at this point in the history
Support for unsigned builds of the MacOS app
  • Loading branch information
zone117x committed Jan 30, 2019
2 parents 8976c99 + 0072c68 commit b3dd8a9
Show file tree
Hide file tree
Showing 8 changed files with 4,043 additions and 4,544 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ native/windows/BlockstackBrowser/Resources/node.exe
native/windows/BlockstackBrowser/Resources/cors-proxy/corsproxy.js
native/windows/BlockstackSetup/obj/
native/windows/BlockstackSetup/bin/
native/macos/Blockstack/Blockstack/server/corsproxy.js
native/macos/Blockstack/Blockstack/server/blockstackProxy.js
native/macos/Blockstack/Blockstack/server/node
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,17 @@ reload the page. For example, if your `auth=` query looks like

## Building for macOS

1. Make sure you have a working installation of Xcode 9 or higher & valid Mac Developer signing certificate
1. Make sure you have an OpenSSL ready for bottling by homebrew by running `brew install openssl --build-bottle`
1. Make sure you have `hg` installed by running `brew install hg`
1. Run `npm install nexe -g` to install the "node to native" binary tool globally
1. Open the Blockstack macOS project in Xcode and configure your code signing development team (You only need to do this once)
1. Run `npm run mac` to build a debug release signed with your Mac Developer certificate

*Note: You only need to run `nexe` once but the first build will take a while as `nexe` downloads and compiles a source copy of node. Then it creates and copies the needed proxy binaries into place and copies a built version of the browser web app into the source tree.*
1. Make sure you have a working installation of Xcode >=9 and Node.js >=10.
1. Run `npm run mac:release:dev` to build an unsigned application bundle.
1. The output bundle is located at `native/macos/export/Blockstack.app`.

*Note: This has only been tested on macOS High Sierra 10.13*

### Building a macOS release for distribution

1. Ensure you have valid Developer ID signing credentials in your Keychain. (See https://developer.apple.com/developer-id/ for more information)
1. Follow the instructions in the above section for building for macOS.
1. Open the Blockstack macOS project in Xcode and configure your code signing development team (You only need to do this once)
1. Make sure you have an OpenSSL ready for bottling by homebrew by running `brew install openssl --build-bottle`
1. Open the Blockstack macOS project in Xcode.
1. Select the Product menu and click Archive.
1. When the archive build completes, the Organizer window will open. Select your new build.
Expand Down
12 changes: 4 additions & 8 deletions native/macos/Blockstack/Blockstack.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
03D84AF47B48C8D13A44AB1F /* Pods_BlockstackUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 151BBEEEC2F6FF783F2FB820 /* Pods_BlockstackUITests.framework */; };
4612AE971E87E20600AC866A /* export.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4612AE961E87E20600AC866A /* export.plist */; };
464C43A81E9A5B2500533529 /* PortalLogServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 464C43A71E9A5B2500533529 /* PortalLogServer.swift */; };
467AF8CC1E85397200216B2A /* corsproxy in Resources */ = {isa = PBXBuildFile; fileRef = 467AF8CB1E85397200216B2A /* corsproxy */; };
467AF8CE1E85398300216B2A /* blockstackProxy in Resources */ = {isa = PBXBuildFile; fileRef = 467AF8CD1E85398300216B2A /* blockstackProxy */; };
46AB7B3C1E632F08004DACD8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AB7B3B1E632F08004DACD8 /* AppDelegate.swift */; };
46AB7B3E1E632F08004DACD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46AB7B3D1E632F08004DACD8 /* Assets.xcassets */; };
46AB7B411E632F08004DACD8 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 46AB7B3F1E632F08004DACD8 /* MainMenu.xib */; };
Expand All @@ -24,6 +22,7 @@
628865811F3FFC900008B17F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6288657F1F3FFC900008B17F /* Main.storyboard */; };
628865861F3FFD2C0008B17F /* BlockstackLauncher.app in Copy Files */ = {isa = PBXBuildFile; fileRef = 628865771F3FFC900008B17F /* BlockstackLauncher.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
62F5E53C1F3F9316003E139B /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F5E53A1F3F92B3003E139B /* ServiceManagement.framework */; };
8F4DA57121FBAF380059236E /* server in Resources */ = {isa = PBXBuildFile; fileRef = 8F4DA57021FBAF380059236E /* server */; };
F9416162CBC2093412EF41D3 /* Pods_Blockstack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86F85987ACADDDC03CDA8F87 /* Pods_Blockstack.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -63,8 +62,6 @@
253C1468E9D7BB9D0C6ABA2E /* Pods-BlockstackTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockstackTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BlockstackTests/Pods-BlockstackTests.debug.xcconfig"; sourceTree = "<group>"; };
4612AE961E87E20600AC866A /* export.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = export.plist; path = ../export.plist; sourceTree = "<group>"; };
464C43A71E9A5B2500533529 /* PortalLogServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PortalLogServer.swift; sourceTree = "<group>"; };
467AF8CB1E85397200216B2A /* corsproxy */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = corsproxy; sourceTree = "<group>"; };
467AF8CD1E85398300216B2A /* blockstackProxy */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = blockstackProxy; sourceTree = "<group>"; };
46AB7B381E632F08004DACD8 /* Blockstack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Blockstack.app; sourceTree = BUILT_PRODUCTS_DIR; };
46AB7B3B1E632F08004DACD8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
46AB7B3D1E632F08004DACD8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand All @@ -89,6 +86,7 @@
691A869DEA8D7683DE5BE4A0 /* Pods-Blockstack.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Blockstack.release.xcconfig"; path = "Pods/Target Support Files/Pods-Blockstack/Pods-Blockstack.release.xcconfig"; sourceTree = "<group>"; };
7F565C3ED6B9C73792D704DC /* Pods-BlockstackUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockstackUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-BlockstackUITests/Pods-BlockstackUITests.release.xcconfig"; sourceTree = "<group>"; };
86F85987ACADDDC03CDA8F87 /* Pods_Blockstack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Blockstack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8F4DA57021FBAF380059236E /* server */ = {isa = PBXFileReference; lastKnownFileType = folder; name = server; path = Blockstack/server; sourceTree = "<group>"; };
B8C5A3A739A7149580AFBD43 /* Pods-BlockstackTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockstackTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-BlockstackTests/Pods-BlockstackTests.release.xcconfig"; sourceTree = "<group>"; };
D8DB2C2D533E703048FE31F8 /* Pods_BlockstackTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BlockstackTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -188,9 +186,8 @@
46AB7B681E643643004DACD8 /* Binaries */ = {
isa = PBXGroup;
children = (
467AF8CD1E85398300216B2A /* blockstackProxy */,
8F4DA57021FBAF380059236E /* server */,
46CA5EA41E81BEDC00CF6E38 /* browser */,
467AF8CB1E85397200216B2A /* corsproxy */,
);
name = Binaries;
sourceTree = "<group>";
Expand Down Expand Up @@ -383,9 +380,8 @@
buildActionMask = 2147483647;
files = (
46AB7B3E1E632F08004DACD8 /* Assets.xcassets in Resources */,
467AF8CE1E85398300216B2A /* blockstackProxy in Resources */,
46CA5EA51E81BEDD00CF6E38 /* browser in Resources */,
467AF8CC1E85397200216B2A /* corsproxy in Resources */,
8F4DA57121FBAF380059236E /* server in Resources */,
46AB7B411E632F08004DACD8 /* MainMenu.xib in Resources */,
4612AE971E87E20600AC866A /* export.plist in Resources */,
);
Expand Down
50 changes: 41 additions & 9 deletions native/macos/Blockstack/Blockstack/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
os_log("devModeClick", log: log, type: .debug)
isDevModeEnabled = !isDevModeEnabled
}

func regTestModeClick(sender: AnyObject?) {
os_log("regTestModeClick", log: log, type: .debug)
if(!isRegTestModeChanging) {
Expand Down Expand Up @@ -376,7 +376,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func startPortalProxy(complete: @escaping () -> Void) {
let proxyPath = Bundle.main.path(forResource: "blockstackProxy", ofType: "")
let nodeBinPath = Bundle.main.path(forResource: "node", ofType: "", inDirectory: "server")
let proxyPath = Bundle.main.path(forResource: "blockstackProxy.js", ofType: "", inDirectory: "server")
let portalPath = Bundle.main.path(forResource: "browser", ofType: "")

os_log("Portal proxy path: %{public}@", log: log, type: .info, proxyPath!)
Expand All @@ -397,27 +398,58 @@ class AppDelegate: NSObject, NSApplicationDelegate {
os_log("Can't copy Portal code to the run path: %{public}@", log: log, type: .error, portalRunPath())
}

self.portalProxyProcess.launchPath = nodeBinPath

self.portalProxyProcess.launchPath = proxyPath

self.portalProxyProcess.arguments = [String(self.productionModePortalPort), self.portalRunPath()]
self.portalProxyProcess.arguments = [proxyPath!, String(self.productionModePortalPort), self.portalRunPath()]

os_log("Starting Blockstack Portal proxy...", log: log, type: .default)


let stdErrorPipe = Pipe()
self.portalProxyProcess.standardError = stdErrorPipe
self.portalProxyProcess.terminationHandler = {
task in
DispatchQueue.main.async(execute: {
let errorData = stdErrorPipe.fileHandleForReading.readDataToEndOfFile()
let errorString = NSString(data: errorData, encoding: String.Encoding.utf8.rawValue)! as String
let alert = NSAlert()
alert.messageText = "Blockstack Error: Portal server was terminated"
alert.informativeText = errorString
alert.alertStyle = NSAlertStyle.warning
alert.runModal()
})
}

self.portalProxyProcess.launch()
complete()

}

func startCorsProxy(complete: @escaping () -> Void) {
let corsProxyPath = Bundle.main.path(forResource: "corsproxy", ofType: "")
let nodeBinPath = Bundle.main.path(forResource: "node", ofType: "", inDirectory: "server")
let corsProxyPath = Bundle.main.path(forResource: "corsproxy.js", ofType: "", inDirectory: "server")

os_log("CORS proxy Path: %{public}@", log: log, type: .info, corsProxyPath!)

corsProxyProcess.launchPath = corsProxyPath
corsProxyProcess.arguments = [corsProxyPath!]
corsProxyProcess.launchPath = nodeBinPath

os_log("Starting CORS proxy...", log: log, type: .default)

let stdErrorPipe = Pipe()
corsProxyProcess.standardError = stdErrorPipe
corsProxyProcess.terminationHandler = {
task in
DispatchQueue.main.async(execute: {
let errorData = stdErrorPipe.fileHandleForReading.readDataToEndOfFile()
let errorString = NSString(data: errorData, encoding: String.Encoding.utf8.rawValue)! as String
let alert = NSAlert()
alert.messageText = "Blockstack Error: CORS proxy was terminated"
alert.informativeText = errorString
alert.alertStyle = NSAlertStyle.warning
alert.runModal()
})
}

corsProxyProcess.launch()
complete()
}
Expand Down Expand Up @@ -455,7 +487,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if(isRegTestModeEnabled && !isRegTestModeChanging) {
return regTestCoreAPIPassword
}

return generatePassword()

let serviceNameData = (keychainServiceName as NSString).utf8String
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions native/macos/Blockstack/export_dev.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>mac-application</string>
</dict>
</plist>
Loading

0 comments on commit b3dd8a9

Please sign in to comment.