title: error: exportArchive: The data couldn’t be read because it isn’t in the correct format
body: <p>I have this script that I did not write, that is supposed to build <code>.ipa</code>s of different build flavours:</p>
  
  <pre><code>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 = () =&gt; {
    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 }) =&gt; {
    return `xcodebuild ${xcodebuildArgs.join(" ")}`;
  };
  
  const archiveProject = ({
    xcodeProject,
    scheme,
    configuration = "Release",
    buildPath,
    archivePath
  }) =&gt; {
    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 }) =&gt; {
    const xcodebuildArgs = [
      "-archivePath",
      archivePath,
      "-exportPath",
      distDir,
      "-exportOptionsPlist",
      exportOptionsPlist,
      "-exportArchive"
    ];
  
    return buildProcess({
      xcodebuildArgs
    });
  };
  
  const run = () =&gt; {
    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 &amp;&amp; ${setVersion} &amp;&amp; ${setBuild} &amp;&amp; cd ..`;
  
    execSync(setBuildAndVersion, {}, error =&gt; {
      logger.logHeader("Error setting version and build numbers iOS", {
        repeatChar: "#"
      });
      logger.log(error);
    });
  
    const flavours = [
      {
        endpoint: "dv",
        flavour: "DEV",
        appcenterKey: "&lt;hash&gt;"
      },
      {
        endpoint: "in",
        flavour: "INTG",
        appcenterKey: "&lt;hash&gt;"
      },
      {
        endpoint: "qa",
        flavour: "QA",
        appcenterKey: "&lt;hash&gt;"
      },
      {
        endpoint: "ua",
        flavour: "UA",
        appcenterKey: "&lt;hash&gt;"
      },
      {
        endpoint: "prod",
        flavour: "PROD",
        appcenterKey: "&lt;hash&gt;"
      }
    ];
  
    const devFlav = flavours.find(f =&gt; f.flavour.toLocaleLowerCase() === "dev");
  
    const buildFlavour = process.env.GitVersion_BranchName.startsWith("release/")
      ? flavours
      : [devFlav];
  
    buildFlavour.forEach(f =&gt; {
      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} &amp;&amp; ${archiveCmd} &amp;&amp; ${exportCmd}`, {
        repeatChar: "#"
      });
  
      execSync(
        `${prepare} &amp;&amp; ${archiveCmd} &amp;&amp; ${exportCmd}`,
        getProcessOptions,
        error =&gt; {
          logger.logHeader(`Error --- ${scheme} IOS `, { repeatChar: "#" });
          logger.log(error);
        }
      );
    });
  };
  
  run();
  </code></pre>
  
  <p>I do not know if there is a problem with the script, but it fails with the error below:</p>
  
  <pre><code>nps is executing `ios.build` : node node_modules/rimraf/bin.js dist/*.ipa &amp;&amp; babel-node scripts/ios/build.js
  ############################# DEV Build IOS Start #############################
  ENGAGE_ENDPOINT=dv APPCENTER_KEY=&lt;hash&gt; ENGAGE_VERSION=1.0.0-1 APPCENTER_PLATFORM=ios npm run setup &amp;&amp; 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 &amp;&amp; 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.
  </code></pre>
  
  <p>What does it mean by the data is not in the correct format? Where should I be looking to debug this in?</p>
  
  <p>When I look at the logs I get this obscure error:</p>
  
  <p><code>Error Domain=NSCocoaErrorDomain Code=3840 "No value."</code></p>
  
  <p>I saw one answer that said I needed a <code>compileBitcode</code> added but I have that in my <code>dev.plist</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;method&lt;/key&gt;
      &lt;string&gt;enterprise&lt;/string&gt;
      &lt;key&gt;teamID&lt;/key&gt;
      &lt;string&gt;1234ABCD&lt;/string&gt;
      &lt;key&gt;uploadBitcode&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;compileBitcode&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;uploadSymbols&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;signingStyle&lt;/key&gt;
      &lt;string&gt;manual&lt;/string&gt;
      &lt;key&gt;signingCertificate&lt;/key&gt;
      &lt;string&gt;iOS Distribution&lt;/string&gt;
      &lt;key&gt;provisioningProfiles&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;com.nfib-enterprise.engage-dv&lt;/key&gt;
          &lt;string&gt;ENGA - DEV - Dist&lt;/string&gt;
          &lt;key&gt;com.nfib-enterprise.engage-in&lt;/key&gt;
          &lt;string&gt;ENGA - INT - Dist&lt;/string&gt;
          &lt;key&gt;com.nfib-enterprise.engage-qa&lt;/key&gt;
          &lt;string&gt;ENGA - QA - Dist&lt;/string&gt;
          &lt;key&gt;com.nfib-enterprise.engage-ua&lt;/key&gt;
          &lt;string&gt;ENGA - UA - Dist&lt;/string&gt;
      &lt;/dict&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>