Abu Bäkr
Abu Bäkr

Reputation: 333

How to resolve Xcode 13.2.1 compile time error "The data couldn’t be read because it isn’t in the correct format."?

I am working in my XY branch and whenever I checkout to my YZ branch, and try to build the project, I am getting error "The data couldn’t be read because it isn’t in the correct format.", while other co-workers can checkout to YZ branch easily and aren't facing any problems. I tried following things:

  1. Deleting Derived data.
  2. Restarting the mac and hence Xcode.
  3. Clean the project.
  4. Replaced Info.plist (Thought may be some key is the cause of that error.)

Logs aren't helpful at all, and just showing the error that I've mentioned above.

Kindly guide me what can be the possible problem here.Thanks.

Upvotes: 0

Views: 1473

Answers (1)

mylogon
mylogon

Reputation: 2979

I've had this happen a couple of time. Things to note are that you might be having files persist between branch changes (ie - anything that's noted in your .gitignore file) and if you have Xcode open between branch changes. I've especially seen this be an issue if your dependencies are different between the branches (ie cocoapods/ versions of the installed version).

When collaborating with teams on Xcode projects, it can be especially tricky when things like the .xcproj file is out of sync/ has merge conflicts, or you have different versions of Xcode/ cocoapods/ any other packages installed.

To start with, I would make sure you have the same packages installed across all machines. Something like Bundler is good for this, but can be carried out manually. Also, before changing branches, it's a good idea to make sure you discard your changes. It's easiest to do this in a GUI tool such as SourceTree, but via CLI you can run something like git reset --hard AFTER closing Xcode.

Then, once you've done that, try changing branches, running things like pod install and make sure to open the correct .xcproj vs .xcworkspace file. Once you've done that, you might need to reset package caches if you use SPM and it should build correctly.

If you're still having difficulties, after changing branches, run git status to see if you have anything other than nothing to commit, working tree clean to see if there's anything strange going on.

Upvotes: 1

Related Questions