【问题标题】:CFBundleIdentifier Collision while uploading a macOS app developed with Electron and built with electron-builder上传使用 Electron 开发并使用 electron-builder 构建的 macOS 应用程序时发生 CFBundleIdentifier 冲突
【发布时间】:2019-02-20 05:13:56
【问题描述】:

我目前正在开发一个 Electron 应用程序,我能够为 macOS 操作系统生成 .app 和 .pkg。虽然我可以从生成的 .app 运行它,但当我尝试上传 .pkg (ma​​s) 时,我在 AppStore Connect 上收到以下错误:

CFBundleIdentifier Collision - 
The Info.plist CFBundleIdentifier value 'org.phantomjs' of 'phantomjs'
is already in use by another application.

我已尝试将 Electron 更新到最新的稳定版本 (2.0.9),并将 electron-builder 更新到最新版本 (20.28.4)。我尝试在生成的 .app 中搜索 org.phantomjs 字符串,但无法找到带有该捆绑标识符的 Info.plist

在这里我附上我的 package.json 以防它有用:

{
  "name": "myAppName",
  "version": "0.0.1",
  "author": "Me <me@mymail.com>",
  "description": "My Description",
  "license": "MIT",
  "main": "./dist/electron/main.js",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/****.git"
  },
  "scripts": {
    "build": "node .electron-vue/build.js && electron-builder",
    "build:dir": "node .electron-vue/build.js && electron-builder --dir",
    "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
    "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
    "dev": "node .electron-vue/dev-runner.js",
    "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src",
    "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src",
    "pack": "npm run pack:main && npm run pack:renderer",
    "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
    "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
    "postinstall": "npm run lint:fix"
  },
  "build": {
    "productName": "myAppName",
    "appId": "this.is.a.real.appid",
    "buildVersion": "5",
    "directories": {
      "output": "build"
    },
    "files": [
      "dist/electron/**/*"
    ],
    "dmg": {
      "contents": [
        {
          "x": 410,
          "y": 150,
          "type": "link",
          "path": "/Applications"
        },
        {
          "x": 130,
          "y": 150,
          "type": "file"
        }
      ]
    },
    "mac": {
      "icon": "build/icons/icon.icns",
      "category": "public.app-category.developer-tools",
      "target": [
        {
          "target": "mas"
        }
      ]
    },
    "mas": {
      "entitlements": "build/entitlements.mas.plist",
      "entitlementsInherit": "build/entitlements.mas.inherit.plist",
      "icon": "build/icons/icon.icns",
      "category": "public.app-category.developer-tools"
    },
    "win": {
      "icon": "build/icons/icon.ico",
      "target": [
        {
          "target": "nsis"
        },
        {
          "target": "appx"
        }
      ]
    },
    "linux": {
      "icon": "build/icons"
    },
    "fileAssociations": [
      {
        "ext": "myExtension",
        "name": "My Project",
        "description": "File containing a My Project.",
        "icon": "build/icons/Project.icns",
        "role": "Editor",
        "isPackage": true
      }
    ],
    "copyright": "Copyright © 2018 Me"
  },
  "dependencies": {
    "@appshuttle.io/bell": "0.0.12",
    "@appshuttle.io/pollock": "0.0.28",
    "@appshuttle.io/turing": "0.0.16",
    "@fortawesome/fontawesome-svg-core": "^1.2.2",
    "@fortawesome/free-brands-svg-icons": "^5.0.13",
    "@fortawesome/free-regular-svg-icons": "^5.0.13",
    "@fortawesome/free-solid-svg-icons": "^5.0.13",
    "@fortawesome/vue-fontawesome": "0.1.1",
    "axios": "^0.16.1",
    "electron-updater": "^3.0.3",
    "email-validator": "^2.0.4",
    "grunt": "^1.0.3",
    "nedb": "^1.8.0",
    "p5": "^0.6.1",
    "path": "^0.12.7",
    "spectre.css": "^0.5.3",
    "vue": "^2.3.3",
    "vue-color": "^2.4.6",
    "vue-electron": "^1.0.6",
    "vue-router": "^2.5.3",
    "vuedraggable": "^2.16.0",
    "vuex": "^2.3.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-eslint": "^7.2.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.24.1",
    "babili-webpack-plugin": "^0.1.2",
    "cfonts": "^1.2.0",
    "chalk": "^2.4.1",
    "copy-webpack-plugin": "^4.5.2",
    "cross-env": "^5.2.0",
    "css-loader": "^0.28.11",
    "del": "^3.0.0",
    "devtron": "^1.4.0",
    "electron": "^2.0.0",
    "electron-builder": "20.28.4",
    "electron-debug": "^2.0.0",
    "electron-devtools-installer": "^2.2.4",
    "eslint": "^4.19.1",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-html": "^3.1.1",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-node": "^5.1.1",
    "eslint-plugin-promise": "^3.8.0",
    "eslint-plugin-standard": "^3.1.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^0.11.2",
    "html-webpack-plugin": "^2.30.1",
    "mini-css-extract-plugin": "^0.4.1",
    "multispinner": "^0.2.1",
    "node-loader": "^0.6.0",
    "node-sass": "^4.9.2",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.18.2",
    "url-loader": "^0.5.9",
    "vue-html-loader": "^1.2.4",
    "vue-loader": "^15.4.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.4.2",
    "webpack": "^3.12.0",
    "webpack-dev-server": "^2.7.1",
    "webpack-hot-middleware": "^2.22.3"
  }
}

提前非常感谢!

【问题讨论】:

    标签: macos phantomjs electron mac-app-store electron-builder


    【解决方案1】:

    找到了解决方案(正如@countravioli 在此Github Issue 中提到的那样):

    我发现有一个名为app.asar.unpacked 的文件在创建并签名.pkg 后包含多个捆绑标识符。在.app 中删除此文件,然后创建.pkg 对我不起作用,因此我使用了 Github 问题中建议的 Build Hook。防止文件被插入到.pkg 文件中。为此,我在 package.json 其余内容的末尾添加了一个钩子:

    package.json
    { //package.json Root ...
       build: {
          // build content ...
          "afterPack": "./afterPack.js"
       }
    }
    

    然后在我的package.json所在的文件夹中创建了一个名为afterPack.js的文件,内容如下:

    const fs = require('fs');
    const fse = require('fs-extra');
    const path = require('path');
    module.exports = function (params) {
        const unpackFile = path.join(params.appOutDir, 'YOUR_APP_NAME.app/Contents/Resources/app.asar.unpacked');
        console.log('EXISTS?', fs.existsSync(unpackFile));
        console.log("REMOVE", unpackFile);
        fse.removeSync(unpackFile);
    };
    

    我能够毫无问题地将包上传到 AppStore Connect。

    【讨论】:

      猜你喜欢
      • 2021-09-21
      • 2020-02-03
      • 1970-01-01
      • 2016-07-23
      • 2017-01-29
      • 2021-01-13
      • 2018-02-06
      • 2021-02-17
      • 2017-11-17
      相关资源
      最近更新 更多