开发工具 编译 ScatterDesktop 源代码,生成对应平台安装包

Surou · 2018年11月02日 · 280 次阅读
本帖已被设为精华帖!

下载源代码

git clone https://github.com/GetScatter/ScatterDesktop.git

Mac系统编译

首先确认下当前机器安装的node的版本为v9.8.0,否则无法编译通过。切换版本,可参考《mac os 安装指定版本 node

开始编译

进入源代码目录,安装依赖

yarn install

编译源码

npm run build

生成对应平台安装包 mac:

npm run release-mac

windows:

npm run release-win

linux:

npm run release-linux

编译成功

suroudeMacBook-Pro:ScatterDesktop surou$ npm run release-mac

> [email protected] release-mac /Users/surou/Documents/github/ScatterDesktop
> electron-builder --mac

  • electron-builder version=20.28.4
  • loaded configuration file=package.json ("build" field)
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config file=release/builder-effective-config.yaml
  • rebuilding native production dependencies platform=darwin arch=x64
  • packaging       platform=darwin arch=x64 electron=2.0.11 appOutDir=release/mac
  • skipped macOS application code signing reason=cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, see https://electron.build/code-signing allIdentities=
                                                  0 identities found

                                               Valid identities only
                                                  0 valid identities found
  • building        target=macOS zip arch=x64 file=release/mac-scatter-9.5.0.zip
  • building        target=DMG arch=x64 file=release/mac-scatter-9.5.0.dmg
  • building block map blockMapFile=release/mac-scatter-9.5.0.dmg.blockmap

常见问题

-cannot find specified resource "static/icons/icon.png cannot find specified resource "static/icons/icon.png", nor relative to "/Users/surou/Documents/github/ScatterDesktop/build", neither relative to project dir ("/Users/surou/Documents/github/ScatterDesktop"), 手动将build/icon.png复制到static/icons

Windows系统编译

  • 下载安装: node v9.8.0 yarn-1.9.4
  • 安装windows编译工具 shell npm install --global windows-build-tools
  • 安装项目依赖 shell yarn install
  • 开始编译,打包 shell npm run build npm run release-win

常见错误

  • iojs.lib : fatal error LNK1106 shell c:\users\surou\desktop\scatterdesktop\node_modules\keccak\src\libkeccak\KeccakSponge.h : warning C4819: ���ļ����������ڵ�ǰ����ҳ(936)�б�ʾ���ַ����뽫���ļ�����Ϊ Unicode ��ʽ�Է�ֹ���ݶ�ʧ (����Դ�ļ� ..\src\libkeccak\KeccakSponge.c) [C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak\build\keccak.vcxproj] C:\Users\Surou\.electron-gyp\.node-gyp\iojs-2.0.11\x64\iojs.lib : fatal error LNK1106: �ļ���Ч���������: �޷����ҵ� 0x29851C [C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak\build\keccak.vcxproj] gyp ERR! build error gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:180:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12) gyp ERR! System Windows_NT 10.0.16299 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Surou\\Desktop\\ScatterDesktop\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=2.0.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" gyp ERR! cwd C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak gyp ERR! node -v v9.8.0 gyp ERR! node-gyp -v v3.8.0 解决方案:删除 C:\Users\Surou\.electron-gyp 参考:https://github.com/electron/electron-rebuild/issues/163
  • app-builder.exe exited with code 1 shell Error: C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code 1 at ChildProcess.childProcess.once.code (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\builder-util\src\util.ts:254:14) at Object.onceWrapper (events.js:272:13) at ChildProcess.emit (events.js:180:13) at maybeClose (internal/child_process.js:936:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5) 解决方案:删除node_modules,重新yarn install 参考:https://github.com/electron-userland/electron-builder/issues/2002
  • .bin\babylon: Error: ENOENT: no such file or directory shell Cannot read file C:\Users\Surou\Desktop\ScatterDesktop\node_modules\babylon\.bin\babylon: Error: ENOENT: no such file or directory, open 'C:\Users\Surou\Desktop\ScatterDesktop\node_modules\babylon\.bin\babylon' at w (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-lib\src\asar\asarUtil.ts:201:11) at writeStream.write (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-lib\src\asar\asarUtil.ts:203:43) at afterWrite (_stream_writable.js:473:3) at onwrite (_stream_writable.js:464:7) at fs.write (fs.js:2252:5)-win: `electron-builder --win` at FSReqWrap.wrapper [as oncomplete] (fs.js:707:5) 解决方案:安装yarn-1.9.4版本 参考:https://github.com/GetScatter/ScatterDesktop/issues/165
  • 编译完,运行,界面空白 经过反编译app.asar,发现缺少dist 解决方案:先运行npm run build,在运行npm run release-win

其他

  • 反编译asar shell npm install -g asar asar extract app.asar ./
共收到 0 条回复
Surou 将本帖设为了精华贴 11月06日 20:52
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册