Skip to content

release-react iOS version detection treats CURRENT_PROJECT_VERSION = 0 as missing ("key doesn't exist") #41

Description

@iujisato

Environment

@revopush/code-push-cli 0.0.13, react-native 0.84.1, macOS. Project uses the modern Xcode versioning style: Info.plist contains $(MARKETING_VERSION) / $(CURRENT_PROJECT_VERSION) placeholders, actual values live in project.pbxproj.

Symptom

Running release-react for iOS without --target-binary-version fails during version auto-detection:

Detecting ios app version:

[Error]  The "CURRENT_PROJECT_VERSION" key doesn't exist in the "ios/<App>.xcodeproj/project.pbxproj" file.

…even though the key exists in every build configuration. The trigger: our project's build number is literally 0 (CURRENT_PROJECT_VERSION = 0;).

Root cause

In getAppVersionFromXcodeProject (bin/script/command-executor.js, line ~779 in 0.0.13):

const currentProjectVersion = xcodeProj.getBuildProperty("CURRENT_PROJECT_VERSION", ...);
if (!currentProjectVersion) {
    throw new Error(`The "CURRENT_PROJECT_VERSION" key doesn't exist ...`);
}

The xcode package returns the number 0 for CURRENT_PROJECT_VERSION = 0;, and !0 is true — so a present-and-parsed value is reported as a missing key.

Verification (A/B with the CLI's own code)

We invoked the CLI's getReactNativeProjectVersionInfo directly against two copies of the same project differing only in that one value:

  • CURRENT_PROJECT_VERSION = 0; → throws the error above.
  • CURRENT_PROJECT_VERSION = 1;{"appVersion":"4.0.0","buildNumber":"1"} — detection succeeds.

Suggested fix

Check for absence rather than falsiness, e.g.:

if (currentProjectVersion == null) { ... }
return Q({ appVersion: marketingVersion, buildNumber: String(currentProjectVersion) });

(The existing String(currentProjectVersion) on the return already handles the numeric type; only the guard is wrong.) A clearer error message distinguishing "key not found" from "value invalid" would also help — the current one sent us hunting for a missing key that wasn't missing.

Workaround

Pass --target-binary-version explicitly, which skips detection entirely.

Context: found while hardening our release scripts after #40 — same app, different code path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions