ElectronJS IOS build for the apple store internet not working when enable sandbox

Viewed 135

I have an issue with the created macOS build for the apple store in which the internet not working.

For apple, store submission enables sandbox mode. For that added com.apple.security.app-sandbox into the entitlements file which one required while submit application to the store. After adding this line can't able to use the internet in generated .app file. As per the document added below keys in build/entitlements.mas.plist file to enable network.

<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>

After added above key, still can't able to access the internet.

Below steps refere from the https://github.com/electron-userland/electron-builder/issues/4553#issuecomment-623451338 link.

package.json

"mac": {
  "appId": "com.xyx.io",
  "target": [
    "mas"
  ]
},
"mas":{
  "hardenedRuntime": false,
  "type": "distribution",
  "category": "public.app-category.productivity",
  "provisioningProfile": "build/embedded.provisionprofile",
  "entitlements": "build/entitlements.mas.plist",
  "entitlementsInherit": "build/entitlements.mas.inherit.plist"
}

build/entitlements.mas.plist

<?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>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.automation.apple-events</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>APP_ID.com.xyz.io</string>
    </array> 
  </dict>
</plist>

build/entitlements.mas.inherit.plist

<?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>com.apple.security.inherit</key>
      <true/>
        <key>com.apple.security.network.client</key>
        <true/>
        <key>com.apple.security.network.server</key>
        <true/>
    </dict>
</plist>

build/resignAndPackage.sh

#!/bin/bash

printf "......................\nresignAndPackage start\n\n"

# Name of your app.
APP="XYZ"
# The path of your app to sign.
APP_PATH="release/mas/XYZ.app"
# The path to the location you want to put the signed package.
RESULT_PATH="$APP.pkg"

# The name of certificates you requested.
APP_KEY="Apple Distributio"
INSTALLER_KEY="3rd Party Mac Developer Installer"

# The path of your plist files.
PARENT_PLIST="build/entitlements.mas.plist"
CHILD_PLIST="build/entitlements.mas.inherit.plist"
LOGINHELPER_PLIST="build/entitlements.mas.loginhelper.plist"


FRAMEWORKS_PATH="$APP_PATH/Contents/Frameworks"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Electron Framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Libraries/libffmpeg.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/Contents/MacOS/$APP Helper"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/MacOS/$APP"
codesign -s "$APP_KEY" -f --entitlements "$PARENT_PLIST" "$APP_PATH"
productbuild --component "$APP_PATH" /Applications --sign "$INSTALLER_KEY" "$RESULT_PATH"


printf "\nresignAndPackage end\n......................\n"

version

"electron": "^11.4.8",
"electron-builder": "^22.10.5",

The command for the create build:

electron-builder build --mac  --publish never && sh build/resignAndPackage.sh
0 Answers
Related