Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4 project: utility to clean up pbxproj file?

Tags:

xcode

xcode4

I have an Xcode 4 project with 2 targets, one for iPhone and one for iPad. If I click on the iPad target and try to go to Build Settings Xcode 4 crashes:

Encountered multiple assertions. First assertion was: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-269/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/FileTypes/../PBXFileType.m:594 Details: filename should be a non-empty string, but it is nil

Obviously the pbxproj file has a bad reference in there somewhere -- likely caused by the many manual merges I've been forced to do by git. Is there some way to clean up the pbxproj file so it works correctly again or to tell which line is causing the problem?? I'd really really prefer not to have to recreate the project from scratch.

like image 420
memmons Avatar asked May 19 '11 20:05

memmons


People also ask

Where is Project Pbxproj in Xcode?

Usually it is situated inside corresponding YourProjectName. xcodeproj package - it is a folder but looks like an ordinary file in MacOS's Finder - you can go into it right-clicking and choosing 'show package contents' option.

What is Project Pbxproj?

pbxproj. project. pbxproj is an important file in the Xcode configuration bundle. It is responsible for maintaining references to all of the linked files and their groupings, linked frameworks, and most importantly, the project's build settings.


5 Answers

I tried gorbster's method with no success (though it has solved similar problems for me in the past).

I went into my project.pbxproj file (inside the .xcodeproj package for the project) and found two lines that looked a little suspicious, both of the form:

53A45F8F138FE6F40077017F /* (null) in Resources */ = {isa = PBXBuildFile; }; 

I deleted the lines, and voilà: I can access my build settings for this target again.

No idea how they got in there in the first place. I would guess something to do with a faulty merge under SVN.

like image 94
Ben Mosher Avatar answered Sep 19 '22 15:09

Ben Mosher


Ran into the same issue this morning after pulling a colleague's merge.

I was able to fix this with the following:

  1. Close Xcode
  2. Open the .xcodeproj package in Finder
  3. Delete the project.xcworkspace file/package
  4. Open the xcuserdata folder and delete your user-specific .xcuserdatad folder.
  5. Re-Open Xcode and project

I lost some minor user preferences (file and tab history, etc), but can now click all (9) of my targets without issue. Turns out my colleague was on an earlier version of Xcode, but I'm not sure if this contributed to the IDE crashing.

like image 39
gorbster Avatar answered Sep 22 '22 15:09

gorbster


Ben Mosher found the solution. And yes it is due to SVN merge problem.

As we working in team with SVN the error occur often so I wrote a bash script:

#!/bin/bash
sed "/(null) in/d" project.pbxproj > tmp_project.pbxproj
mv tmp_project.pbxproj project.pbxproj
like image 22
Martin Magakian Avatar answered Sep 18 '22 15:09

Martin Magakian


Try the following steps while your Xcode is closed.

  1. Go to your {YOUR_PROJECT}.xcodeproj file in finder.

  2. Right click on the {YOUR_PROJECT}.xcodeproj file.

  3. Choose Show Package Contents ... this will open the contents in another Finder screen.

  4. Open file project.pbxproj and search for all lines having string "(null) in"

  5. Delete all lines having (null) in ... no worries.... delete confidently.

  6. Save your file.

Now open your project using Xcode and try to open the Build Settings tab... hopefully your problem will be solved.

Thanks, Mohamed.

like image 39
Mohamed A.Karim Avatar answered Sep 19 '22 15:09

Mohamed A.Karim


Right click your .xcodeproj file and "Show Package Contents".

Then open project.pbxproj file with TextEdit and duplicate.

Save duplicate file anywhere with same name and extension. (project.pbxproj)

And replace with the old file.

like image 35
Batu Avatar answered Sep 21 '22 15:09

Batu