A repository of bitesize articles, tips & tricks
(in both English and French) curated by Mirego’s team.

Using Kin to verify .xcodeproj files

I am not an expert in iOS development so I wanted to share with you a tool that I find useful when dealing with automatic merging issues in .xcodeproj files.

Recently our .xcodeproj file was invalid due to merging issue and it was pretty difficult to identify exactly what was wrong. The pod install command was successful, but when trying to build the iOS app in Xcode there was an error saying:

error: [R.swift] Project file at '[path]/[projectName].xcodeproj/' could not be parsed, is this a valid Xcode project file ending in *.xcodeproj?
The operation couldn’t be completed. (XcodeEdit.AllObjectsError error 0.)

As you can see, there is not much to look for. All it says is that there is an error. So I searched a little bit and found this tool: https://github.com/Karumi/Kin. It was easy to install and by running the command kin in the project’s folder it output:

ERROR: line 6615:10 mismatched input 'settings' expecting {QUOTED_STRING, NON_QUOTED_STRING}
ERROR: line 6858:10 mismatched input 'settings' expecting {QUOTED_STRING, NON_QUOTED_STRING}
ERROR: line 11165:2 mismatched input '}' expecting 'sourceTree'
ERROR: line 12831:3 mismatched input 'name' expecting 'inputPaths'
ERROR: line 12834:3 mismatched input 'runOnlyForDeploymentPostprocessing' expecting 'outputPaths'
ERROR: line 13114:3 mismatched input 'name' expecting 'inputPaths'
ERROR: line 13117:3 mismatched input 'runOnlyForDeploymentPostprocessing' expecting 'outputPaths'
ERROR: line 13151:3 mismatched input 'name' expecting 'inputPaths'
ERROR: line 13154:3 mismatched input 'runOnlyForDeploymentPostprocessing' expecting 'outputPaths'
ERROR: line 13196:3 mismatched input 'name' expecting 'inputPaths'
ERROR: line 13199:3 mismatched input 'runOnlyForDeploymentPostprocessing' expecting 'outputPaths'

I am not exactly sure why there was so many errors, but the interesting one was: ERROR: line 11165:2 mismatched input '}' expecting 'sourceTree'.

When comparing with adjacent nodes, it was clear that the line: sourceTree = "<group>"; was missing.

In summary the Xcode errors are not always that explicit and using third party tools can save you headaches when it comes to fixing the compilation process!