Skip to content

Fix plugin crash and preserve infoPlist values when props are omitted#353

Merged
robertherber merged 5 commits into
masterfrom
copilot/fix-nshealthshareusage-description
Jun 3, 2026
Merged

Fix plugin crash and preserve infoPlist values when props are omitted#353
robertherber merged 5 commits into
masterfrom
copilot/fix-nshealthshareusage-description

Conversation

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Using the plugin without an options array ("@kingstinct/react-native-healthkit") causes a crash because props is undefined, and accessing props.NSHealthShareUsageDescription throws. Additionally, values set via expo.ios.infoPlist were always silently overwritten by the plugin's hardcoded defaults.

Changes

  • app.plugin.ts / app.plugin.js: In withInfoPlistPlugin, use optional chaining on props and add a fallback to the existing modResults value before the hardcoded default

The fallback chain is now:

  1. Plugin prop value (explicit string passed to the plugin)
  2. Existing infoPlist value (set via expo.ios.infoPlist in app.json)
  3. Hardcoded default ("<AppName> wants to read/update your health data")

This means both of the following configurations now work correctly without conflict:

{
  "expo": {
    "plugins": ["@kingstinct/react-native-healthkit"],
    "ios": {
      "infoPlist": {
        "NSHealthShareUsageDescription": "Share activity data with $(PRODUCT_NAME)",
        "NSHealthUpdateUsageDescription": "Share activity data from $(PRODUCT_NAME)"
      }
    }
  }
}

@changeset-bot

changeset-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e28d5f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kingstinct/react-native-healthkit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI changed the title [WIP] Fix package not finding NSHealthShareUsageDescription in app.json Fix plugin crash and preserve infoPlist values when props are omitted Jun 3, 2026
Copilot AI requested a review from robertherber June 3, 2026 04:18
Work in progress to address missing NSHealthShareUsageDescription in app.json.
@robertherber robertherber marked this pull request as ready for review June 3, 2026 04:19
Copilot AI review requested due to automatic review settings June 3, 2026 04:19
@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/kingstinct/react-native-healthkit/@kingstinct/react-native-healthkit@353

commit: e28d5f7

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Expo config plugin for @kingstinct/react-native-healthkit to (1) avoid crashing when the plugin is configured without an options object and (2) stop overwriting expo.ios.infoPlist usage-description values unless explicitly overridden by plugin props.

Changes:

  • Guard plugin option access with optional chaining so props can be omitted safely.
  • Prefer plugin-provided usage description strings, otherwise keep any existing infoPlist strings, otherwise fall back to defaults.
  • Add a patch changeset for publishing the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
packages/react-native-healthkit/app.plugin.ts Updates TS config plugin logic to handle omitted props and preserve existing Info.plist usage descriptions.
packages/react-native-healthkit/app.plugin.js Updates the published JS config plugin with the same omitted-props and fallback behavior.
.changeset/kind-ties-know.md Adds a patch changeset entry for releasing the fix.

Comment thread packages/react-native-healthkit/app.plugin.ts Outdated
Comment thread packages/react-native-healthkit/app.plugin.ts Outdated
Comment thread packages/react-native-healthkit/app.plugin.ts Outdated
Comment thread packages/react-native-healthkit/app.plugin.js Outdated
Comment thread packages/react-native-healthkit/app.plugin.js Outdated
Comment thread .changeset/kind-ties-know.md Outdated
claude added 2 commits June 3, 2026 04:48
…eck and clean up changeset

- Replace `as string | undefined` cast + `??` with explicit `typeof === 'string'` runtime check
  so non-string infoPlist values (booleans, objects) are never written back as usage descriptions
- Remove misleading comment about `false` handling that no longer reflects actual behavior
- Update changeset to remove [WIP] prefix and describe both fixes (crash + value preservation)

https://claude.ai/code/session_01XRdixDjYwJajsMBdddVHrT
….plist

Apps that only read health data don't need NSHealthUpdateUsageDescription.
Passing false skips writing the key entirely, mirroring the existing false
opt-out pattern used by the background-delivery entitlement.

https://claude.ai/code/session_01XRdixDjYwJajsMBdddVHrT
@robertherber robertherber merged commit e60b88a into master Jun 3, 2026
8 checks passed
@robertherber robertherber deleted the copilot/fix-nshealthshareusage-description branch June 3, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package not finding NSHealthShareUsageDescription in app.json

4 participants