Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve conflicts in `project.pbxproj` file while upgrading react native?

I am using Xcode 9.4 and current react native version @0.54.4 I want to upgrade the version to 0.55.4.

As I upgrade my project using react-native-git-upgrade, I see some un merged conflicts in the project.pbxproj. Some of the settings are my own that are conflicting with the changes in the new version.

I tried all the possible ways in which I could resolve the conflicts. But still X-code shows the error could not load the project, and it does not allow me to build my project.

How do I understand what those conflicts are referring to and how can I safely resolve the conflicts?

like image 899
Kaushik Avatar asked Feb 01 '19 13:02

Kaushik


1 Answers

Unfortunately there is no magic way to resolve conflicts. I wish there was. The file is managed by Xcode and from personal experience I have found that you can easily mess it up performing merges.

Git is definitely your best-friend. Make sure that before you start any merge you are on a new branch and fully committed so that if you mess-up you can easily get back to your original version.

What I usually do is keep the original version of the project.pbxproj and then make the changes manually in Xcode. I know this doesn't sound ideal but it does mean you should be able to open the project in Xcode, though your project may not run - just yet.

If you’re unclear about which version to keep, I would keep ours as that is the original version of your project.pbxproj. From the documentation:

You can think of "ours" as "your team" and "theirs" as "the React Native dev team".

Then I would make the changes manually as detailed below. As that will show their changes and the should hopefully not be that many.

To help me find the changes that I have to make I find that React Native Upgrade Helper is an invaluable resource. There you can find a git diff of any two versions of react-native that you choose. (This saves you having to create two projects and then compare them yourself, a big timesaver.)

Currently you are upgrading from 0.54.4 to 0.55.4 this link shows the diff between those versions

https://react-native-community.github.io/upgrade-helper/?from=0.54.4&to=0.55.4

For additional help you could create a project in a specific react-native version, using the following will create a project for version 0.55.4.

react-native init newproject --version [email protected]

That way you can look inside the Xcode project to see what has been added, and where it was added from, as the git diff doesn't always tell where it came from.

I have never had much luck using react-native-git-upgrade and I have come to prefer doing it manually, as I have had much more success doing it that way.

like image 109
Andrew Avatar answered Oct 23 '22 13:10

Andrew