appcenter-sdk-react-native icon indicating copy to clipboard operation
appcenter-sdk-react-native copied to clipboard

Builds are breaking if NPM packages are not pinned to specific version

Open ElektrojungeAtWork opened this issue 7 years ago • 4 comments

Hey everyone,

We had a few customers who experienced the following issue recently and think it's a good idea to open a GH issue for better visibility:

If your RN builds for iOS (either locally or in App Center build) are breaking without you doing any change, it can be caused by NPM's default setting for semantic versioning.

You might see an error like this (could be other APIs):

/Users/vsts/agent/2.140.2/work/1/s/node_modules/appcenter-analytics/ios/AppCenterReactNativeAnalytics/AppCenterReactNativeAnalytics.m:221:44: error: no visible @interface for 'MSPropertyConfigurator' declares the selector 'collectDeviceId'
[transmissionTarget.propertyConfigurator collectDeviceId];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~

TL;DR

Follow our guide on how to update the AppCenter SDK for RN at https://docs.microsoft.com/en-us/appcenter/sdk/troubleshooting/react-native#how-to-update-react-native-sdk-to-the-latest-version and update the SDK to the latest version.

1. Why does NPM/YARN update my dependencies in the first place?

By default, dependencies are added added to your package.json like this: "appcenter-analytics": "^1.8.1" Note the caret ^. It means that NPM will update to the most recent minor version of the dependency (also see https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json). Of course it's up to anyone to decide if that's okay for them, but we recommend using the tilde ~ instead and pin your dependencies to a specific version.

2. Why is this an issue for App Center packages?

The App Center SDK for RN rely on native iOS packages that are usually resolved by react-native link which uses Cocoapods to manage those dependencies. If NPM packages get updated, those native packages need to be updated, too. NPM does not do that and will cause a version mismatch between NPM and native iOS packages. Hence you need to follow our guide on how to update the AppCenter SDK for RN at https://docs.microsoft.com/en-us/appcenter/sdk/troubleshooting/react-native#how-to-update-react-native-sdk-to-the-latest-version to the latest version.

3. Why aren't you doing anything about this?

We have updated our documentation to use --save-exact to pin the AppCenter packages to a specific version so it doesn't affect new integrations.

ElektrojungeAtWork avatar Oct 19 '18 22:10 ElektrojungeAtWork

How about using yarn which have the same problem too

BANG88 avatar Oct 22 '18 01:10 BANG88

@bang88, To get latest appcenter package with exact version (without caret ^ or tilde ~ in the version), use npm install appcenter --save-exact or yarn add appcenter --exact.

dhei avatar Oct 22 '18 16:10 dhei

@dhei 1.9.0 is the latest version ? I have installed the latest version and still can not build. I have to downgrade to 1.8.1 for now

BANG88 avatar Oct 23 '18 01:10 BANG88

@bang88 please create a separate issue using the template if you have problem building with 1.9.0 specifically.

guperrot avatar Oct 23 '18 01:10 guperrot

As we do not have plans to fix this bug in the next year, I'm closing the issue.

DmitriyKirakosyan avatar Apr 15 '24 04:04 DmitriyKirakosyan