Skip to content

Commit b23f9c6

Browse files
committed
wip bundle as helper
1 parent 9fc59bb commit b23f9c6

File tree

9 files changed

+76
-26
lines changed

9 files changed

+76
-26
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>trezor-bluetooth</string>
9+
<key>CFBundleIconFile</key>
10+
<string>AppIcon</string>
11+
<key>CFBundleIconName</key>
12+
<string>AppIcon</string>
13+
<key>CFBundleIdentifier</key>
14+
<string>io.trezor.TrezorBtleMac</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundleName</key>
18+
<string>TrezorBtleMac</string>
19+
<key>CFBundlePackageType</key>
20+
<string>APPL</string>
21+
<key>CFBundleShortVersionString</key>
22+
<string>0.1.0</string>
23+
<key>CFBundleSupportedPlatforms</key>
24+
<array>
25+
<string>MacOSX</string>
26+
</array>
27+
<key>CFBundleVersion</key>
28+
<string>0.1.0</string>
29+
<key>LSMinimumSystemVersion</key>
30+
<string>13.0</string>
31+
<key>LSUIElement</key>
32+
<true/>
33+
<key>NSBluetoothAlwaysUsageDescription</key>
34+
<string>This app requires Bluetooth access to communicate with Trezor devices.</string>
35+
</dict>
36+
</plist>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APPL????

packages/suite-desktop-core/src/libs/processes/BaseProcess.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ export abstract class BaseProcess {
248248
await this.start();
249249
}
250250

251-
private onError(err: Error) {
251+
public onError(err: Error) {
252252
this.logger.error(this.logTopic, err.message);
253253
}
254254

255-
private onExit(code: number | null) {
255+
public onExit(code: number | null) {
256256
this.logger.info(
257257
this.logTopic,
258258
`Exited, code: ${code ?? 'N/A'} (Stopped: ${b2t(this.stopped)})`,

packages/suite-desktop-core/src/libs/processes/BluetoothProcess.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import { spawn } from 'child_process';
2+
import path from 'path';
3+
14
import { isDevEnv } from '@suite-common/suite-utils';
5+
import { isMacOs } from '@trezor/env-utils';
26

37
import { BaseProcess, Status } from './BaseProcess';
48
import { getSwitchValue } from '../process-switches';
@@ -62,6 +66,28 @@ export class BluetoothProcess extends BaseProcess {
6266
process.env.RUST_BACKTRACE = '1';
6367
}
6468

65-
return super.start(['-p', this.port.toString()]);
69+
if (!isMacOs()) {
70+
return super.start(['-p', this.port.toString()]);
71+
}
72+
73+
return new Promise<void>(resolve => {
74+
// Launch macos helper
75+
const helperPath = path.join(
76+
global.resourcesPath,
77+
'..',
78+
'Helpers',
79+
'TrezorBluetooth.app',
80+
);
81+
const process = spawn('/usr/bin/open', [
82+
'-n',
83+
'-a',
84+
helperPath,
85+
'--args',
86+
'--headless',
87+
]);
88+
process.on('error', err => super.onError(err));
89+
process.on('close', code => super.onExit(code));
90+
resolve();
91+
});
6692
}
6793
}

packages/suite-desktop/electron-builder-config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ module.exports = {
8181
oneClick: false,
8282
},
8383
mac: {
84+
binaries: [],
8485
files: ['entitlements.mac.inherit.plist'],
8586
extraResources: [
8687
{
@@ -100,6 +101,12 @@ module.exports = {
100101
to: 'bin/bluetooth',
101102
},
102103
],
104+
extraFiles: [
105+
{
106+
from: 'build/static/bin/bluetooth/TrezorBluetooth.app',
107+
to: 'Helpers/TrezorBluetooth.app',
108+
},
109+
],
103110
icon: 'build/static/images/desktop/512x512.icns',
104111
artifactName: 'Trezor-Suite-${version}-mac-${arch}.${ext}',
105112
hardenedRuntime: true,

packages/transport-bluetooth/TrezorBluetooth.app/Contents/Info.plist

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cargo build
2-
cp target/debug/trezor-bluetooth TrezorBluetooth.app/Contents/MacOS
3-
#codesign --deep --force --sign - TrezorBluetooth.app
4-
codesign --deep --force --sign "Apple Development: Tomas Martykan (Z45W4655Y2)" --entitlements entitlements.plist TrezorBluetooth.app/
2+
cp target/debug/trezor-bluetooth ../suite-data/files/bin/bluetooth/TrezorBluetooth.app/Contents/MacOS
3+
codesign --deep --force --sign "Apple Development: Tomas Martykan (Z45W4655Y2)" --entitlements entitlements.plist ../suite-data/files/bin/bluetooth/TrezorBluetooth.app/
4+
codesign -dvvv --entitlements - ../suite-data/files/bin/bluetooth/TrezorBluetooth.app

0 commit comments

Comments
 (0)