[LINUX] Relationship between platform constraints and native modules when building and publishing Electron apps

As you all know, you can use Electron for cross-platform development.

However, as you go from build to publish, ** not all of those tasks are completed on one platform **.

Also, ** the story is different when using native modules **.

I would like to explain about that.

Can one platform build and publish for all platforms?

For example, the question is "Can Windows build apps for all OSs?", But it depends on whether or not native modules are used **.

If you are not using a native module

** You can build **.

However, ** Publishing for Mac requires Code Signing, so it can only be done on Mac **.

Therefore, if you run it on a Mac, everything from build to publication will be completed on the Mac.

Docker image

A Docker image is prepared as an environment where electron-builder can be operated.

However, this is the same as running on Linux, so you can only build and publish apps for Windows and Linux.

Also, if you use a native module for Windows, you cannot build it.

Native modules are described in the next section.

If you are using a native module

Native modules need to be built individually for each OS.

Therefore, basically, it is necessary to prepare as many build environments as there are target platforms.

If you want to build native Mac modules, Mac.

For Windows, a Windows build environment is required.

Considering that VMs for Mac are also available these days, it may not be difficult to prepare, but there is no doubt that you will need an actual machine for development.

It's true that you can implement many features without using native modules, but one day you'll run into problems.

I think it's okay if you need it, but you'll need to consider preparing a native module and the associated build / publish environment.

Recommended Posts

Relationship between platform constraints and native modules when building and publishing Electron apps