Giter Site home page Giter Site logo

Comments (25)

cvvspb avatar cvvspb commented on May 5, 2024

image

Same

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

How are you building iOS apps on Windows? It's not supported by React Native.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

So you are meaning that I need to have a Mac in order to update a string indicating a version number in some file ;) ?

At least give a meaningful error message.

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

No, but in case you haven't noticed, this package is prefixed with react-native-, so one would assume it would follow the platform support of the react-native package. If you want to "update a string in some file", you can write your own script ;)

I would like to look into this, but before I start spending my free time doing it, it would be nice to have some more info, like the question I asked.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

In case you haven't noticed, I'm not the only one that wants to increase their app version for Android AND iOS at the same time when coding in Windows before using a Mac and building it instantly after pulling the code.

Coding in Windows, building Android on Windows and building iOS on a rented Mac.

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

I noticed and that's why I asked the question.

Anyway, thanks for providing some info about your setup. Now I can see how you're using the tool and how Windows users might be using RN with two machines. It makes sense to support Windows right away and I'll look into it.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

Thanks for your attention to this issue. I'm seeing no reason why this may fail on Windows, maybe the pbxproj parser ?

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

The pbxproj parser should be pretty cross platform. Actually added it to start supporting Linux and move away from Apple's agvtool. But there are some shell commands executed with node that might be causing the issue. There's actually a open PR #44 to deal with Git tag updating not working on Windows. There might be more commands causing the issue.

from react-native-version.

cvvspb avatar cvvspb commented on May 5, 2024

Hi there!
As @VinceBT has already mentioned, it is pretty common for a react-native app developer to have two build machines. Personally, I use Windows 10 notebook to build Android app version and Macbook to build for iOS. I would use the same version number for both platforms and I would like to have an opportunity to bump version on any of the notebooks.

What is interesting: I have 2 react-native apps in a single repository, each of them targeting 2 versions: iOS and Android. For one of the apps, react-native-version fails with the undefined error message mentioned above. For the other one, it updates both android build.gradle and iOS Info.plist/pbxproj just fine.

I'm willing to contribute, so I'm going to have a closer look at this issue today.

from react-native-version.

cvvspb avatar cvvspb commented on May 5, 2024

Looks like it's a pbxproj-dom issue in my case.
Exception is thrown here:
const xcode = Xcode.open(path.join(projectFolder, "project.pbxproj"));

Xcode.js:

Xcode.open = function (path) {
var xcode = new Xcode();
xcode.document = pbx.parse(parser.parse(fs.readFileSync(path).toString()));
xcode.path = path;
return xcode;
};

parser.parse throws this:
SyntaxError: Expected """, "\'", "\"", "\n", or [^\\"] but "\" found.
at peg$buildStructuredError (C:\Users\cvv\Projects\react-native-version\node_modules\pbxproj-dom\parser.js:318:12)
at Object.peg$parse [as parse] (C:\Users\cvv\Projects\react-native-version\node_modules\pbxproj-dom\parser.js:921:11)
at Function.Xcode.open (C:\Users\cvv\Projects\react-native-version\node_modules\pbxproj-dom\xcode.js:16:43)
at C:\Users\cvv\Projects\react-native-version\index.js:241:25
at new Promise ()
at Object.version (C:\Users\cvv\Projects\react-native-version\index.js:170:9)
at Object. (C:\Users\cvv\Projects\react-native-version\cli.js:50:5)
at Module._compile (module.js:632:14)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)

I'm going to double-check pbxproj structure.

It would be great if react-native-version could just pass the error to the console instead of vague "[RNV] undefined" message

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@cvvspb Thanks for looking into it.

For the case of 2 RN projects in one repo. Could you provide a sample tree view to see how the repo is structured and also the method how you execute RNV?

from react-native-version.

cvvspb avatar cvvspb commented on May 5, 2024

@stovmascript, the repo structure is very simple:
/RootFolder/
/RootFolder/Project1 (react-native app 1)
/RootFolder/Project1/js/....
/RootFolder/Project1/android/....
/RootFolder/Project1/ios/....
/RootFolder/Project1/package.json
....
/RootFolder/Project2 (react-native app 2)
/RootFolder/Project2/js/....
/RootFolder/Project2/android/....
/RootFolder/Project2/ios/....
/RootFolder/Project2/package.json
...
/RootFolder/Backend (Project3 - node.js app)
...

I executed RNV in each of the projects separately.
As I've mentioned earlier, the problem was in project.pbxproj file - it got corrupted after some "react-native link" commands. XCode didn't notice invalid entries but pbxproj-dom did throw an exception while parsing.

I've fixed project.pbxproj file and now it works OK!

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@cvvspb Ok. Yeah, I admit error forwarding needs some work (#15).

from react-native-version.

cvvspb avatar cvvspb commented on May 5, 2024

There is one more thing: there is an issue with git tags if someone uses the same approach as I do (two or more separate apps in a single repo with different versions).
Basic setup doesn't allow this, 'cause if the version of, say, app 1 is 0.5.0 and version of app 2 is 0.4.5 and you want to bump app 2 to 0.5.0 git wouldn't allow to have 2 tags like "v0.5.0"
I had to prefix tags with project name to solve the issue, like: "Project1-v0.5.0", "Project2-v0.5.0"
I could write a little how-to if required.

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@VinceBT @cvvspb Hey guys, can you update and test the new version of RNV (2.5.0)? It contains the aforementioned PR #44, which fixes the Git tag issue on Windows. I just started looking into this issue and testing on Windows and everything seems to be working:

clipboard01

Tested on the same fixture I run tests on.

Edit: Updated link to test fixture.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

Having almost the same error than before.

Its is not saying [RNV] undefined anymore now.

$ npm version major
v2.0.0

> [email protected] postversion C:\Users\AdminUser\RandomProject
> react-native-version --never-amend

[RNV] Versioning Android...
[RNV] Android updated
[RNV] Versioning iOS...

  Usage: cli [options] [projectPath]

  Version your React Native app in a `npm version` fashion.

  Options:

    -V, --version                output the version number
    -a, --amend                  Amend the previous commit. Also updates the latest Git tag to point to the amended commit. This is done automatically when react-native-version is run from the "version" or "postversion" npm script. Use "--never-amend" if you never want to amend.
    --skip-tag                   For use with "--amend", if you don't want to update Git tags. Use this option if you have git-tag-version set to false in your npm config or you use "--no-git-tag-version" during npm-version.
    -A, --never-amend            Never amend the previous commit.
    -b, --increment-build        Only increment build number.
    -B, --never-increment-build  Never increment build number.
    -d, --android [path]         Path to your "android/app/build.gradle" file. (default: android/app/build.gradle)
    -i, --ios [path]             Path to your "ios/" folder. (default: ios)
    -L, --legacy                 Version iOS using agvtool (macOS only). Requires Xcode Command Line Tools.
    -q, --quiet                  Be quiet, only report errors.
    -r, --reset-build            Reset build number back to "1" (iOS only). Unlike Android's "versionCode", iOS doesn't require you to bump the "CFBundleVersion", as long as "CFBundleShortVersionString" changes. To make it consistent across platforms, react-native-version bumps both by default. You can use this option if you prefer to keep the build number value at "1" after every version change. If you then need to push another build under the same version, you can use "-bt ios" to increment.
    -s, --set-build <number>     Set a build number. WARNING: Watch out when setting high values. This option follows Android's app versioning specifics - the value has to be an integer and cannot be greater than 2100000000. You cannot decrement this value after publishing to Google Play! More info at: https://developer.android.com/studio/publish/versioning.html#appversioning
    -t, --target <platforms>     Only version specified platforms, eg. "--target android,ios".
    -h, --help                   output usage information
[RNV] Done, with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postversion: `react-native-version --never-amend`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postversion script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\AdminUser\AppData\Roaming\npm-cache\_logs\2018-04-23T15_03_26_167Z-debug.log

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@VinceBT I tried to set up my project like yours, but I'm still not able to reproduce the problem.

clipboard02

Could you provide a sample project?

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

I just tried again on a brand new RN project and again, no problems. There must be something specific that's throwing off the pbxproj parser...

from react-native-version.

suside avatar suside commented on May 5, 2024

In my case I was removing tvos/watch builds from my project and it turned out I somehow still have:

INFOPLIST_FILE = "MyApp-tvOS/Info.plist";

in ios/MyApp.xcodeproj/project.pbxproj while MyApp-tvOS/Info.plist file was already deleted.

I figured that little fix here index.js#L399

log({ ...{ style: 'red', text: String(err) }, ...err });

should print all unexpected errors.

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@suside That would make sense becase the project.pbxproj is used to build a list of Info.plist files which are then read, but there's no error handling in case the file doesn't exist.

Edit: Well now there will be, with your contribution.

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@VinceBT @cvvspb Hey guys, check out the new version (2.5.2) that's out now on npm. It should now print a meaningful error message in the console.

Feel free to reopen, if a Windows related issue still persists.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

After your commit, I finally get the error but I guess it would make more sense to print the full stacktrace.
I replaced err.toString() by err.stack in

Object.assign({ style: "red", text: err.toString() }, err),

Here is what I've got

[RNV] Versioning iOS...
[RNV] SyntaxError: Expected "\"", "\\'", "\\\"", "\\n", or [^\\"] but "\\" found.
    at peg$buildStructuredError (C:\Users\AdminUser\RandomProject\node_modules\pbxproj-dom\parser.js:318:12)
    at Object.peg$parse [as parse] (C:\Users\AdminUser\RandomProject\node_modules\pbxproj-dom\parser.js:921:11)
    at Function.Xcode.open (C:\Users\AdminUser\RandomProject\node_modules\pbxproj-dom\xcode.js:16:43)
    at C:\Users\AdminUser\RandomProject\node_modules\react-native-version\index.js:266:25
    at new Promise (<anonymous>)
    at Object.version (C:\Users\AdminUser\RandomProject\node_modules\react-native-version\index.js:175:9)
    at Object.<anonymous> (C:\Users\AdminUser\RandomProject\node_modules\react-native-version\cli.js:56:5)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)

from react-native-version.

stovmascript avatar stovmascript commented on May 5, 2024

@VinceBT Will look into better error handling in general. Did you find out what that specific error was about?

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

Since the parser doesn't give the line he thinks there is a problem on, I cannot give a look but I've used kin to verify if my pbxproj was correct and it said it was.

from react-native-version.

VinceBT avatar VinceBT commented on May 5, 2024

Found fix in #52 (comment)

from react-native-version.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.