ошибка: exportArchive: данные не могут быть прочитаны, потому что они не в правильном формате - PullRequest
1 голос
/ 07 октября 2019

У меня есть сценарий, который я не написал, который должен собирать .ipa с различными вариантами сборки:

import path from "path";
import { execSync } from "child_process";
import { name, iosDirectory } from "../../app.json";
import { version } from "../../package.json";
import { resolveFromRoot, distDir, createLogger } from "../build";

const getProcessOptions = () => {
  return {
    env: Object.assign({}, process.env, {
      // used to skip packager, since we default to release bundler is built in
      RCT_NO_LAUNCH_PACKAGER: true,
      CI_IOS_VERSION_NAME: version
      // CI_IOS_BUILD_NUMBER: build,
    })
  };
};

const buildProcess = ({ xcodebuildArgs }) => {
  return `xcodebuild ${xcodebuildArgs.join(" ")}`;
};

const archiveProject = ({
  xcodeProject,
  scheme,
  configuration = "Release",
  buildPath,
  archivePath
}) => {
  const xcodebuildArgs = [
    xcodeProject.isWorkspace ? "-workspace" : "-project",
    xcodeProject.name,
    "-configuration",
    configuration,
    "-scheme",
    scheme,
    "-derivedDataPath",
    buildPath,
    "-archivePath",
    archivePath,
    "archive",
    "-UseModernBuildSystem=NO"
  ];

  return buildProcess({
    xcodebuildArgs
  });
};

const exportProject = ({ archivePath, exportOptionsPlist }) => {
  const xcodebuildArgs = [
    "-archivePath",
    archivePath,
    "-exportPath",
    distDir,
    "-exportOptionsPlist",
    exportOptionsPlist,
    "-exportArchive"
  ];

  return buildProcess({
    xcodebuildArgs
  });
};

const run = () => {
  const logger = createLogger("ios builds");

  const projectPath = resolveFromRoot(
    path.join(iosDirectory, `${name}.xcworkspace`)
  );

  const release = process.env.GitVersion_MajorMinorPatch || "1.0.0";
  const buildNumber = process.env.Build || 1;
  const fullAppVersion = `${release}-${buildNumber}`;

  const setVersion = `agvtool new-marketing-version ${release}`;
  const setBuild = `agvtool new-version -all ${buildNumber}`;

  const setBuildAndVersion = `cd ios && ${setVersion} && ${setBuild} && cd ..`;

  execSync(setBuildAndVersion, {}, error => {
    logger.logHeader("Error setting version and build numbers iOS", {
      repeatChar: "#"
    });
    logger.log(error);
  });

  const flavours = [
    {
      endpoint: "dv",
      flavour: "DEV",
      appcenterKey: "<hash>"
    },
    {
      endpoint: "in",
      flavour: "INTG",
      appcenterKey: "<hash>"
    },
    {
      endpoint: "qa",
      flavour: "QA",
      appcenterKey: "<hash>"
    },
    {
      endpoint: "ua",
      flavour: "UA",
      appcenterKey: "<hash>"
    },
    {
      endpoint: "prod",
      flavour: "PROD",
      appcenterKey: "<hash>"
    }
  ];

  const devFlav = flavours.find(f => f.flavour.toLocaleLowerCase() === "dev");

  const buildFlavour = process.env.GitVersion_BranchName.startsWith("release/")
    ? flavours
    : [devFlav];

  buildFlavour.forEach(f => {
    const scheme = f.flavour;

    const devPList = path.resolve(__dirname, "dev.plist");
    const appStorePList = path.resolve(__dirname, "app-store.plist");
    // if PROD scheme, then use app-store.plist.  Else, dev.list
    const exportOptionsPlist = scheme === "PROD" ? appStorePList : devPList;

    logger.logHeader(`${scheme} Build IOS Start`, { repeatChar: "#" });
    const buildPath = path.resolve(iosDirectory, "build");
    const archivePath =
      path.resolve(buildPath, "Archive", scheme) + ".xcarchive";

    //prettier-ignore
    const engaInfo = `ENGAGE_VERSION=${fullAppVersion}`;
    const engaEndpoint = `ENGAGE_ENDPOINT=${f.endpoint}`;
    const engaCenter = `APPCENTER_KEY=${f.appcenterKey}`;
    const engaPlatform = "APPCENTER_PLATFORM=ios";
    //prettier-ignore
    const prepare = `${engaEndpoint} ${engaCenter} ${engaInfo} ${engaPlatform} npm run setup`;
    const archiveCmd = archiveProject({
      xcodeProject: {
        name: path.relative(".", projectPath),
        isWorkspace: path.extname(projectPath) === ".xcworkspace"
      },
      scheme,
      buildPath,
      archivePath
    });
    const exportCmd = exportProject({
      archivePath,
      exportOptionsPlist
    });

    logger.logHeader(`${prepare} && ${archiveCmd} && ${exportCmd}`, {
      repeatChar: "#"
    });

    execSync(
      `${prepare} && ${archiveCmd} && ${exportCmd}`,
      getProcessOptions,
      error => {
        logger.logHeader(`Error --- ${scheme} IOS `, { repeatChar: "#" });
        logger.log(error);
      }
    );
  });
};

run();

Я не знаю, есть ли проблема со сценарием, ноэто терпит неудачу с ошибкой ниже:

nps is executing `ios.build` : node node_modules/rimraf/bin.js dist/*.ipa && babel-node scripts/ios/build.js
############################# DEV Build IOS Start #############################
ENGAGE_ENDPOINT=dv APPCENTER_KEY=<hash> ENGAGE_VERSION=1.0.0-1 APPCENTER_PLATFORM=ios npm run setup && xcodebuild -workspace ios/NFIBEngage.xcworkspace -configuration Release -scheme DEV -derivedDataPath path/to/ios/build -archivePath path/to/ios/build/Archive/DEV.xcarchive archive -UseModernBuildSystem=NO && xcodebuild -archivePath path/to/ios/build/Archive/DEV.xcarchive -exportPath path/to/dist -exportOptionsPlist path/to/scripts/ios/dev.plist -exportArchive
 2019-10-07 10:23:07.730 xcodebuild[15084:16992455] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/nd/6b67gs7n3wg6714rx36q0r140000gn/T/ENGAL-DEV_2019-10-07_10-23-07.728.xcdistributionlogs'.
error: exportArchive: The data couldn’t be read because it isn’t in the correct format.

Что это означает, что данные не в правильном формате? Где я должен искать, чтобы отладить это?

Когда я просматриваю логи, я получаю эту неясную ошибку:

Error Domain=NSCocoaErrorDomain Code=3840 "No value."

Я видел один ответ, который сказал, что янужно добавить compileBitcode, но у меня есть это в моем файле dev.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>method</key>
    <string>enterprise</string>
    <key>teamID</key>
    <string>1234ABCD</string>
    <key>uploadBitcode</key>
    <true/>
    <key>compileBitcode</key>
    <true/>
    <key>uploadSymbols</key>
    <true/>
    <key>signingStyle</key>
    <string>manual</string>
    <key>signingCertificate</key>
    <string>iOS Distribution</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.nfib-enterprise.engage-dv</key>
        <string>ENGA - DEV - Dist</string>
        <key>com.nfib-enterprise.engage-in</key>
        <string>ENGA - INT - Dist</string>
        <key>com.nfib-enterprise.engage-qa</key>
        <string>ENGA - QA - Dist</string>
        <key>com.nfib-enterprise.engage-ua</key>
        <string>ENGA - UA - Dist</string>
    </dict>
</dict>
</plist>
...