<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Varis</title>
    <description>The latest articles on DEV Community by Varis (@varisbhalala).</description>
    <link>https://dev.to/varisbhalala</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F230472%2F63bb63ba-07d8-48d9-8929-da0795009aa4.jpeg</url>
      <title>DEV Community: Varis</title>
      <link>https://dev.to/varisbhalala</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varisbhalala"/>
    <language>en</language>
    <item>
      <title>Publishing Electron App to Mac App Store</title>
      <dc:creator>Varis</dc:creator>
      <pubDate>Mon, 21 Oct 2019 07:43:53 +0000</pubDate>
      <link>https://dev.to/varisbhalala/publishing-electron-app-to-mac-app-store-2oci</link>
      <guid>https://dev.to/varisbhalala/publishing-electron-app-to-mac-app-store-2oci</guid>
      <description>&lt;p&gt;As this process is not documented properly anywhere so here is my try to simplify this process for you.&lt;/p&gt;

&lt;p&gt;You can go through my &lt;a href="https://github.com/varisbhalala/electron-react"&gt;repository&lt;/a&gt; which uses the latest version of electron and electron-builder.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The whole process can be divided into the below steps.&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Building an electron app&lt;/li&gt;
&lt;li&gt;Sign the build with certificates&lt;/li&gt;
&lt;li&gt;Publish the app&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Prerequisites&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="//developer.apple.com"&gt;Apple developer account&lt;/a&gt; -&amp;gt; in which you need 
to enroll in their Apple Developer Program (which may cost you some 
bucks);).&lt;/li&gt;
&lt;li&gt;From &lt;code&gt;developer.apple.com -&amp;gt; account -&amp;gt; Certificates, Identifiers and 
Profile&lt;/code&gt;  we can get certificates, identifier and provision profile 
for our app.&lt;/li&gt;
&lt;li&gt;After enrolling yourself you need following certificates from your 
  account. &lt;a href="https://github.com/nwjs/nw.js/wiki/MAS%3A-Requesting-certificates"&gt;for more reference&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;3rd Party Mac Developer Application certi&lt;/li&gt;
&lt;li&gt;3rd Party Mac Installer certi&lt;/li&gt;
&lt;li&gt;Developer ID application certi&lt;/li&gt;
&lt;li&gt;Developer ID Installer certi&lt;/li&gt;
&lt;li&gt;Mac Developer certi&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;provision profile -&amp;gt; which also you can download from your apple account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For now, we are building the desktop app using an electron-builder later in this blog will show you how to make the build using an &lt;a href="https://github.com/electron/electron-packager"&gt;electron-packager&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So now install all the certificates in your mac system's keychain.&lt;/p&gt;

&lt;p&gt;First of all please go through the file structure which I am following.&lt;/p&gt;

&lt;pre&gt;
src/
public/
     electron.js
     icon.icns
     entitlements.mas.plist
embedded.provisionprofile
&lt;/pre&gt;

&lt;p&gt;Note that we need embedded.provisionprofile file at the root of the project.&lt;/p&gt;

&lt;p&gt;Here is the example of my entitlements.mas.plist file&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Update the &lt;code&gt;TEAM_ID&lt;/code&gt; with your &lt;code&gt;TEAM_ID&lt;/code&gt; which you can get from your apple account and update necessary entitlements according to your project's requirement. You can find the documentation of entitlements &lt;a href="https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For building the electron app let's configure &lt;code&gt;package.json&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;As mentioned in above gist you have to change target for mac to mas which is short term for &lt;strong&gt;Mac App Store&lt;/strong&gt;. With that you need to provide path for provision profile and mas plist file. Change the type parameter to &lt;strong&gt;&lt;em&gt;distribution&lt;/em&gt;&lt;/strong&gt;, as we are signing the app for public distribution on mac app store. &lt;/p&gt;

&lt;p&gt;Now all we want is right here, So let's build the app. &lt;/p&gt;

&lt;p&gt;Fire your mac build command according to your package.json configuration. &lt;/p&gt;

&lt;p&gt;As you seen in my &lt;a href="https://github.com/varisbhalala/electron-react/blob/master/package.json"&gt;repository&lt;/a&gt;'s package.json script, I have to fire&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;yarn build&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 command to generate MAS build.&lt;/p&gt;

&lt;p&gt;Main thing is that &lt;strong&gt;&lt;em&gt;electron-builder&lt;/em&gt;&lt;/strong&gt; is using &lt;code&gt;[electron-osx-sign](https://github.com/electron/electron-osx-sign)&lt;/code&gt; package to sign your &lt;code&gt;.app&lt;/code&gt; file internally so you don't have to worry about it. &lt;/p&gt;

&lt;p&gt;Now you can see &lt;code&gt;.pkg&lt;/code&gt; file in your output folder which we are going to use for publication.&lt;/p&gt;

&lt;p&gt;Now you can see &lt;code&gt;.pkg&lt;/code&gt; file in your output folder which we are going to use for publication.&lt;/p&gt;

&lt;p&gt;Finally, It's time to upload the build to Mac App Store.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Follow below give path:

&lt;ol&gt;
&lt;li&gt;Open Xcode in your mac.&lt;/li&gt;
&lt;li&gt;From Xcode menu bar, open Xcode Menu -&amp;gt; Open developer tool -&amp;gt; 
Application Loader.&lt;/li&gt;
&lt;li&gt;From given 2 options, choose &lt;code&gt;deliver your app&lt;/code&gt; option and choose 
.pkg file of your application.&lt;/li&gt;
&lt;li&gt;Next screen will look like &lt;a href="http://files.simformsolutions.com.s3.amazonaws.com/simformscreen/Deliver_Your_App_2019-10-21_11-01-27.png"&gt;this&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click on next and it will upload your build.&lt;/li&gt;
&lt;li&gt;Go to appstoreconnect.apple.com and fill up all the necessary 
fields. &lt;/li&gt;
&lt;li&gt;Find the &lt;code&gt;Build&lt;/code&gt; section in that form from which you can select 
your uploaded build version for submitting for review. (After 
uploading the build it will be in processing state for some time)&lt;/li&gt;
&lt;li&gt;After submitting the build successfully. It will take around 24 
hours for reviewing the build.&lt;/li&gt;
&lt;li&gt;Your app will be ready for sale now :)&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Build the electron app with electron-packager&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I recently faced one issue like I am not able to build and upload build to Mac App Store with electron latest version 6.0.12 and electron-builder version 21.2.0. It was giving me helpers error while uploading build from Xcode. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I chose another way to upload build which is electron-packager.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Steps:

&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;electron-packager&lt;/code&gt; via yarn or npm.&lt;/li&gt;
&lt;li&gt;Now let's build app with following command.
&lt;pre&gt;electron-packager . "MyApp" --app-bundle-id=com.myapp.macapp -- 
helper-bundle-id=com.myapp.macapp.helper --app-version=2.0.7 -- 
build-version=2.0.7 --platform=mas --arch=x64 --electron- 
version=6.0.12 --icon=path/to/icns --overwrite&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;After successfully building .app file let's sign the app with 
following command.
&lt;pre&gt;electron-osx-sign MyApp-mas-x64/MyApp.app --provisioning- 
profile=embedded.provisionprofile -- 
entitlements=public/entitlements.mas.plist&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Now if you noticed, we are still playing with .app file, so let's 
build .pkg file to upload it to the Mac App Store. For generating 
.pkg file we are going to use &lt;a href="https://github.com/electron/electron-osx-sign/blob/master/bin/electron-osx-flat-usage.txt"&gt;electron-osx-flat&lt;/a&gt;.
&lt;pre&gt;electron-osx-flat MyApp-mas-x64/MyApp.app --verbose&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Now you have signed .pkg file, so follow upload procedure as 
mentioned earlier in this post.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to publish electron app to windows store &lt;a href="https://medium.com/@sangamrajpara/publishing-electron-app-to-windows-store-3cadeed26a32"&gt;here&lt;/a&gt; is my friend's article.&lt;/p&gt;

&lt;p&gt;Thank you for reading.&lt;br&gt;
Keep exploring :)&lt;/p&gt;

</description>
      <category>electronjs</category>
      <category>mas</category>
      <category>electronbuilder</category>
      <category>react</category>
    </item>
  </channel>
</rss>
