-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading with react-native-git-upgrade makes no sense to me #12261
Comments
I had the same problem during my upgrade. project.pbxproj is very touchy, and like you - I thought I knew how to resolve those conflicts and ended up with Xcode not being able to open the project. When you open with Xcode there should be an error with a corresponding stack. (mine was that _referenceProxy was NULL - meaning I had a line that didn't point to any existing entry PBXReferenceProxy section). The whole thing was a mess and I had to roll back to my previous version in git. One thing I will do differently going forward is make a back up copy of project.pbxproj BEFORE resolving conflicts. |
i had the same issue and then i resolved this by remove |
Ugh, I'm trying to upgrade from 39 to 41, and even though I've not modified the at all since I've still got loads of conflicts in the project.pbxproj file. It just doesn't work, I think the only answer is to rebuild your project from scratch |
What is even a virgin Ugh. |
Prior to RN40 (i think) you could get a virgin project file by using react-native upgrade. I think it's gone now though, and I suspect we really need it back. Merging this file by hand simply isn't possible, at least not for me. I've got maybe a hundred conflicts in there, and I've barley changed it. There's just no way to upgrade now. |
I use these 2 regexes to replace the conflicted project file, to take out the ours sections and leave only the theirs: ^<<<<<<< ours\n[^>]*=======\n
^>>>>>>> theirs\n This should, like I suggested, be an option in the new upgrade script. To add "all ours" and "all theirs", besides the current option of leaving all conflicts for in files. |
@fungilation @npomfret There is nothing stopping you from using |
Sure. But this issue is about this being 2 steps forward 1 step back, when
it can be just 2 steps forward.
On Sun, Feb 19, 2017 at 12:11 PM Nicolas Cuillery ***@***.***> wrote:
@fungilation <https://github.com/fungilation> @npomfret
<https://github.com/npomfret> There is nothing stopping you from using react-native
upgrade. The command still exists.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADoJSl6DD95gdOzV9u17Sbny_uEGjxLBks5reKHHgaJpZM4L5q4q>
.
--
Cheers,
Gary
|
I was excited about the new upgrade workflow until I had to use it. xcodeproj files are notorious for being really awkward to merge. I spent hours trying to manually fix about 25 conflicts and every single time I ended up with an unreadable file. I've been thinking that approaching this issue by merging xcodeproj files is just not going to pan out. I think a better approach would be to programmatically re-construct your xcodeproj. I assume the majority if not all of the conflicts come from customizing your xcode project by adding frameworks, changing compile targets, signing certificates, etc and then trying to apply the changes that the RN team makes on each release. So the idea is to apply your changes to the xcodeproj programmatically with something like https://github.com/CocoaPods/Xcodeproj This way you'd maintain a script that takes the latest xcodeproj unmodified as it comes from RN and then applies a set of deterministic changes to it. It could:
It could also apply any changes required by RN packages that need xcode project changes. I haven't had any time to tackle this, but I think it's a promising approach. The first step would be to write a script that retrieves the corresponding unmodified xcodeproj from RN instead of trying to diff the current one. Also worth noting that https://github.com/CocoaPods/Xcodeproj has an xcodeproj differ, which may also be useful. Thoughts? Critique? |
This would be the much better approach for xcodeproj alone.
On Sun, Feb 19, 2017 at 10:10 PM thatjuan ***@***.***> wrote:
I was excited about the new upgrade workflow until I had to use it.
xcodeproj files are notorious for being really awkward to merge. I spent
hours trying to manually fix about 25 conflicts and every single time I
ended up with an unreadable file.
I've been thinking that approaching this issue by merging xcodeproj files
is just not going to pan out. I think a better approach would be to
programmatically re-construct your xcodeproj.
I assume the majority if not all of the conflicts come from customizing
your xcode project by adding frameworks, changing compile targets, signing
certificates, etc and then trying to apply the changes that the RN team
makes on each release.
So the idea is to apply your changes to the xcodeproj programmatically
with something like https://github.com/CocoaPods/Xcodeproj
This way you'd maintain a script that takes the latest xcodeproj
unmodified as it comes from RN and then applies a set of deterministic
changes to it. It could:
- Add custom fonts
- Add files
- Set your codesign settings
- Add targets
- Add frameworks
- etc.
It could also apply any changes required by RN packages that need xcode
project changes.
I haven't had any time to tackle this, but I think it's a promising
approach.
The first step would be to write a script that retrieves the corresponding
unmodified xcodeproj from RN instead of trying to diff the current one.
Also worth noting that https://github.com/CocoaPods/Xcodeproj has an
xcodeproj differ, which may also be useful.
Thoughts? Critique?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADoJSlXsjY_E4puYkP9upeGs_GkJr8BOks5reS5SgaJpZM4L5q4q>
.
--
Cheers,
Gary
|
A programatic way of adding my changes to a virgin Xcode project file would be ideal. |
@ncuillery any comments on the above? |
@thatjuan I got lucky and merged it right the first time. I agree its a pain. What I did was look for duplicate hashes and merge them by hand. If I didn't see a duplicate then I would just include both. Seemed to work. I really took my time and read through the code though. |
The If you want to be able to rewrite all the changes you need in the In fact, Of course, this approach is the most user-friendly (who likes resolving Git conflicts?), it could work on a simple project. If it's working on your project, go with it. But, like I said, not everything can be handled with 3rd-party librairies and If you don't want to use Let me share some pieces of advice about the merge approach, I hope it would help resolving the conflicts:
To conclude, I'd say that the We could improve the Upgrade guide by adding:
Let met bring @mkonicek @grabbou who could have an enlightened opinion about RN upgrades into this conversation. |
Close, but no. I look at diffs per file in the interactive
My process going forward would be to This is my process in what I see is the path of least resistance. Give my comment a like if others feel the same. If this is true then it makes sense for RN to add in further automation in resolving conflicts based on this, in special consideration of |
I've never thought about that. Sounds good, I'll definitely test that. |
Just to put an additional context: there was an attempt prior to git-upgrade to create codemods-like mechanism for upgrading pbxproject. We wanted to use built-in ability to modify `pbxproj` to manually apply tweaks and changes to it (e.g. the initial beta was manually adding missing flags to build products). It didn't work out as there was too much overheat to write upgrade paths for every single braking commit and there were just too many weird combinations of project setup in the wild to handle.
I guess that if you want a smooth upgrade, try `create-react-native-app` or `exponent`. Otherwise, React Native is at the stage where braking changes can happen and none of the tools will save us from doing fixes manually (e.g. import paths that changed). The tools we have now may be helpful in the future, but that's only to happen when the framework itself stabilises.
The approach I use on regular basis is rather simple: I don't upgrade `pbxproject`. What I do is I upgrade `react-native` and hit `run`. In most cases, it works w/o any additional changes. When I hit into errors, I look in changelog to find out that e.g. a new flag has to be added. That works in 99% cases except when import paths change.
|
I ended up downgrading back to the my previous RN version. My xcodeproject works at least for now, only as a temporary solution. It would be really good to see if someone can solve a workaround regarding the merging conflicts. |
cc @mkonicek We're also working on a |
I have the simplest project ever (https://github.com/wachunei/wifiuc-react-native), almost no linked libraries. I've tried to run But no, I can't do it. It's driving me nuts 😫. I'd gladly take a PR that resolves |
Here's what finally worked for me. I took some suggestions from this thread and finally got my project up from 0.40 to 0.42 (I meant it to be 0.43, but didn't realize 42 is still "latest"). 1. Create a new branch (e.g. upgrades/0_40-0_42) (optional)This is to facilitate the process of undoing steps if needed. 2. Unlink all packagesAs suggested by @fungilation, unlinking all packages reduces the number of differences between your project and the master project. In theory, this facilitates the merge. The easiest way I found to do this was to copy all packages from
Then just paste them all in the console. If you created a branch for the upgrade, commit now. 3. Run upgrade
Follow the upgrade instructions. 4. MergeThis is when you're likely to run into merge conflicts. The output of There are two main issues that are common after merging pbxproj manually. The first is that xcode can no longer open it with an error similar to "...xcodeproj cannot be opened because the project file cannot be parsed". In other words, there's a syntax error in it. The second common issue is xcode crashing right after opening the project. This is technically an xcode bug, as it should never crash, but it generally means something in the file doesn't make sense. I ran into both of these scenarios during this merge, and I found some tools that helped a lot in resolving them. Resolving pbxproj syntax errors It's easy to miss adding a closing I used xcodeprojer's
If there are no errors, it won't output. Resolving xcode crashes What I found the most useful in finding errors was to run
I went in the file and looked for 5. Re-link your packagesAfter you're able to open your project in xcode again, re-link your packages: Do the opposite of step 2.
6. Merge upgrade branch (optional)If you created an upgrade branch, test running your project first, and then merge it back. Final thoughtsThis process took about 2.5 hours. Perhaps because I was finding the tools and figuring things out while doing it. It's still not ideal and I don't look forward to the next upgrade. I am thinking that a combination of a custom ios framework to hold things like assets, fonts, and other customizations that can be easily linked + unlinked, plus the process I described earlier in this thread to programmatically re-construct an xcodeproj for the project from RN's master is still the best solution. I hope this is helpful for now, though. |
If you want to try @thatjuan's technique of unlinking your project before attempting the upgrade, then there's a node script here that will help with the unlinking process. I tried, and still had loads of conflicts. I attempted to resolve them by hand but the resulting Xcode project wouldn't compile, it had some sort of low level linking error that I just couldn't figure out. I ended up copying the virgin Xcode file from a clean AwesomeProject, replaced the name with my project name and then used Xcode to rebuild the whole project from scratch (I made and checked in plenty of notes for next time). I also noticed that there were changes in the default |
If you are still having issues after fixing syntax errors complaining about BundleIdentifier not found, here's what I did to solve it:
Now running |
Note that I did |
You guys haven't tried upgrading when using cocoapods, it will take IBM watson to fix pbxproj file. I am leaning toward cutting the tie with react-native upgrades with ios changes. No more automated xcode changes, try to figure out what changed and if it is really important then manually make the change in xcode. Just curious if anyone already done that, how is your experience with upgrades? I wish the react-native team releases changes made in xcode proj as instructions. |
You can use the following cmd if you want to accept
(works well if you do |
Rn-diff saved me! https://github.com/ncuillery/rn-diff
You can alternatively branch out copy xcode all file and then merge it back to your main branch and resolve conflicts with some tools, but then it's step 1 anyway |
@npomfret Can confirm that init-ing a new project (with the new upgraded react native locally) kind of worked. at least xcode isn't crashing anymore. I'm in the process of relinking all of the necessary libraries, but i feel pretty confident about it edit: 3 hours of work total, but no issues. this is the way to go imo. @OriginalYellow I did the same thing with linting and all. To clarify, the steps I took were:
|
I've got to agree with @npomfret and @cwRichardKim. I did everything @thatjuan said to do up to step 4, and the linter gave me the all clear after I fixed every merge conflict and applied the patch it generated. But in the end it still caused xcode to crash every time I tried to open the project. The safest way to do this seems to be just remaking the project from scratch. |
@cwRichardKim yes, creating a brand new project from scratch worked. After linking I had to do a bunch of manual steps, (which I've added to to some documentation now) such as
It sounds like a lot, but now I've got it all noted down I'm confident I can have it all done in about an hour next time. |
I wonder about react-native-git-upgrade is never upgrading the package.json-file, even if the RN-folders in node-modules point to the newest version then, in package.json the old ones remains. |
"react-native ugprade" is able to rewrite all files without merging anything, why react-natiev-git-upgrade doesn't have such option?? i have no idea what should i merge in here, android and ios folders are autogenerated anyway.. |
@holms "Hey! With this tech you can forget about native code... Well, unless you want to update at any time" 🥇 |
It seems like the pain is about resolving conflict for |
Parsing project and doing things manually was what I am referring to in
this thread as one of historical solutions. `react-native` uses that parser
behind the scenes to make `link` and others work.
…On Wed, 26 Apr 2017 at 06:18 Rudy Huynh ***@***.***> wrote:
It seems like the pain is about resolving conflict for project.pbxproj
then make sure xcode can parse it successfully.
My idea is using a parser (like this one:
https://github.com/apache/cordova-node-xcode) to help identify parsing
error of project.pbxproj, then we can fix it.
It would be great if xcode can show more informative error instead of just
"Project [...] cannot be opened because the project file cannot be parsed."
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWcxti49YUns-xEIpxpMN15f0ymKwI5ks5rzsWIgaJpZM4L5q4q>
.
|
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
Just to add to the conversation, i found out that
Seeing this in the end was really satisfying
|
Hi, I got same error and this is how I fixed it after 3-4 attempts.
|
@fforres Kin worked amazingly for us. If only it could automatically fix those instead of just pointing them out... I've pretty much added |
I tried to update rn from 0.41.2 to 0.50.3, spent couple of days and lots of hours merging all this shit and trying to successfully build my project, but I stepped back and returned to 0.41.2 I faced with react-native-maps building problems (It happens in every f***ing update of react-native), react-native-fbsdk problems, and many other magical building errors with CocoaPods and BatchedBridge (or CxxBridge), Folly, Glog,.... oh my God! I just want to work with my awesome product, and don't want to struggle with frameworks! But I need this update :( And soon I will try again. |
I used xcodeprojer as mentionned by @thatjuan to solve this ! I first deleted all the <<<< ours, >>>>> theirs and ==== I had. Eventually replacing the ==== by }; Saved pbxproj file. Then I copied my project.pbxproj file to a temporary folder and applied the |
I was able to resolve this conflict first backing up the file with conflict and then carefully resolving each conflict by hand. If my case I kept all the changes ("their" and "ours") but made sure that the }; were all correctly closed. In some of cases I had to copy complete closures by copying line from earlier closures. For example:
became
|
Complexity of upgrade is still a major issue. I can understand that it is not top priority but this issue shall stay open and believe some of the advices here shall find their way to the official guide. |
Kin: https://github.com/Karumi/Kin Solved the problem for me. Just blindly added and removed lines as suggested by KIN. |
I think that if this issue doesn't get solved and/or mitigated in some way the React Native upgrade process is so frustrating that developers should think twice to use this platform in the next project. At leas this is the case for me, I've already spent a few hours trying to merge conflicts in project.bkxproj and I haven't got anything close to working yet. So frustrating! Trying to upgrade from RN 0.50.1 to RN 0.55.3. |
Works fine for me. Upgrade 1 minor version at a time with |
Upgrading with react-native-git-upgrade makes no sense to me.
I'm getting lots of conflicts in project.pbxproj which also makes no sense.
I try to solve them but Xcode keeps telling me it can't be opened.
I don't se how this can be a conflict:
There are lines above the seems more similar to the theirs par but that is not treated as a conflict.
Is there some tool or some person that could help me with this or am I down to re-init the whole project?
The text was updated successfully, but these errors were encountered: