react-native-set-version icon indicating copy to clipboard operation
react-native-set-version copied to clipboard

Only allow setting Android Version

Open kngoyal opened this issue 3 years ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

While trying to Set Version in shell script with setVersion command while creating a build for an Android app. It gives following error as it also sets sequentially the iOS app version as well, though I am not building an iOS app. As a HOT FIX, I have commented the subsequent call to setIosApplicationVersion. Ideally this should take a CLI flag for app platform, say --platform=android|ios.

WARNING: Cannot find attribute versionCode in file .../android/app/build.gradle. Android version configuration will be skipped
WARNING: Cannot find key CFBundleShortVersionString in file .../ios/employee-app/Info.plist. IOS version configuration will be skipped .../node_modules/react-native-set-version/build/index.js:78
  const bundleVersion = `${version.major}.${version.minor}.${version.patch}.${version.build}`;
                                   ^
                                   
TypeError: Cannot read properties of null (reading 'major')
    at setIosApplicationVersion (...i/node_modules/react-native-set-version/build/index.js:78:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async changeVersion (.../node_modules/react-native-set-version/build/index.js:176:3)

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-set-version/build/index.js b/node_modules/react-native-set-version/build/index.js
index 60baf53..5fde60b 100755
--- a/node_modules/react-native-set-version/build/index.js
+++ b/node_modules/react-native-set-version/build/index.js
@@ -173,7 +173,7 @@ const changeVersion = async () => {
   const appName = setPackageVersion(versionText).name;
   paths.infoPlist = paths.infoPlist.replace('<APP_NAME>', appName);
   await setAndroidApplicationVersion(versionText);
-  await setIosApplicationVersion(versionText);
+  // await setIosApplicationVersion(versionText);
   display('');
 };
 

This issue body was partially generated by patch-package.

kngoyal avatar Dec 01 '22 10:12 kngoyal