最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - error: exportArchive: The data couldn’t be read because it isn’t in the correct format - Stack Overflow

programmeradmin5浏览0评论

I have this script that I did not write, that is supposed to build .ipas of different build flavours:

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();

I do not know if there is a problem with the script, but it fails with the error below:

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.

What does it mean by the data is not in the correct format? Where should I be looking to debug this in?

When I look at the logs I get this obscure error:

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

I saw one answer that said I needed a pileBitcode added but I have that in my dev.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ".0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>enterprise</string>
    <key>teamID</key>
    <string>1234ABCD</string>
    <key>uploadBitcode</key>
    <true/>
    <key>pileBitcode</key>
    <true/>
    <key>uploadSymbols</key>
    <true/>
    <key>signingStyle</key>
    <string>manual</string>
    <key>signingCertificate</key>
    <string>iOS Distribution</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>.nfib-enterprise.engage-dv</key>
        <string>ENGA - DEV - Dist</string>
        <key>.nfib-enterprise.engage-in</key>
        <string>ENGA - INT - Dist</string>
        <key>.nfib-enterprise.engage-qa</key>
        <string>ENGA - QA - Dist</string>
        <key>.nfib-enterprise.engage-ua</key>
        <string>ENGA - UA - Dist</string>
    </dict>
</dict>
</plist>

I have this script that I did not write, that is supposed to build .ipas of different build flavours:

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();

I do not know if there is a problem with the script, but it fails with the error below:

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.

What does it mean by the data is not in the correct format? Where should I be looking to debug this in?

When I look at the logs I get this obscure error:

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

I saw one answer that said I needed a pileBitcode added but I have that in my dev.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple./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>pileBitcode</key>
    <true/>
    <key>uploadSymbols</key>
    <true/>
    <key>signingStyle</key>
    <string>manual</string>
    <key>signingCertificate</key>
    <string>iOS Distribution</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>.nfib-enterprise.engage-dv</key>
        <string>ENGA - DEV - Dist</string>
        <key>.nfib-enterprise.engage-in</key>
        <string>ENGA - INT - Dist</string>
        <key>.nfib-enterprise.engage-qa</key>
        <string>ENGA - QA - Dist</string>
        <key>.nfib-enterprise.engage-ua</key>
        <string>ENGA - UA - Dist</string>
    </dict>
</dict>
</plist>
Share Improve this question edited Oct 7, 2019 at 19:45 Daniel asked Oct 7, 2019 at 15:29 DanielDaniel 15.5k19 gold badges112 silver badges181 bronze badges 4
  • Did you get it resolved yet? – der_michael Commented Oct 22, 2019 at 18:42
  • @der_michael, I did get this resolved with lots of help. – Daniel Commented Oct 22, 2019 at 19:08
  • 1 @Daniel can you please add some solution, I am also stuck with the same issue. – Satish Mavani Commented Dec 18, 2019 at 7:48
  • @SatishMavani, I could never 100% pinpoint what the problem was, but it seemed that it had to do with not having the correct cer files and pem files. As I mentioned before I got a lot of help from the people who originated these files. They went in and installed the correct files. – Daniel Commented Dec 18, 2019 at 14:50
Add a ment  | 

1 Answer 1

Reset to default 10

I fixed this issue by running the following mands:

gem list | grep sqlite3
gem install sqlite3 --platform=ruby
rvm use system --default

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论