Xcode 4 project: utility to clean up pbxproj file? - xcode

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.

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.

Ran into the same issue this morning after pulling a colleague's merge.
I was able to fix this with the following:
Close Xcode
Open the .xcodeproj package in Finder
Delete the project.xcworkspace file/package
Open the xcuserdata folder and delete your user-specific .xcuserdatad folder.
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.

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

Try the following steps while your Xcode is closed.
Go to your {YOUR_PROJECT}.xcodeproj file in finder.
Right click on the {YOUR_PROJECT}.xcodeproj file.
Choose Show Package Contents ... this will open the contents in another Finder screen.
Open file project.pbxproj and search for all lines having string "(null) in"
Delete all lines having (null) in ... no worries.... delete confidently.
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.

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.

In case you also tried the remove (null) reference lines and deleting the user-specific .xcuserdatad folder, and those did not work, here is a potential solution. FYI... This was experienced on Xcode 7.3.1 .
Here is the scenario I faced:
I experienced this issue that was triggered by having "twin" branches in a git repo... (i.e. one branch BRANCH_A is a development branch with some features not due for release, and another that had the same commits except for the new features, call it BRANCH_B).
The development work flow is as follows: start with BRANCH_B, create a commit branch CHANGE_C, make changes and commit, then checkout BRANCH_A, create a commit branch, then cherry-pick changes from CHANGE_C. BRANCH_A is tracking BRANCH_B in this way, with its additional feature files.
In my case, (for some reason during rebasing on co-worker changes from the remote that BRANCH_B tracks, the project file for BRANCH_B got corrupted.
In this case, the solution is to save a copy of the project file for BRANCH_A (which is good and compiles), then checkout BRANCH_B, and replace its project file with the copy.
Initially, it will not compile, until all references to the feature files (from BRANCH_A) are removed from Target's Build Phases > Compile Sources.
Works great.

Related

Xcode 7.3 - Throwing "directory not found for option" Even if The Directory Did Exists

I am getting this warning a couple of times stating that the library directory is not found. I've tripled check the directory, and IT IS THERE. I tried to clean the project but still didn't work.
The strange thing is, when I remove the library(The whole folder) and copy-paste a new one, it will work - What I mean here is I deleted the source file from the main directory of the project and copy-paste a new one from another directory, then I will add the files to the project.
But after building a project for a couple of times without editing the directory or the contents of the library, this error will happen again.
It's like, when I fix this problem, it will be OK for now, but when I rebuild the project next time without editing anytime, the error will occur again.
I am not sure if this case has something to do with path containing spaces.
Instead of copying and pasting the directory you should: File > Add Files ... to your project. Xcode is likely losing the reference to it because the files are not "added" to the project.
I solved this problem by removing the space within the directory name. My directory name before was Name Name, Then I changed to NameName. Now the problem is gone. It's really strange, I don't think spacing would produce such problem.

Git ignore xcodeproj file

I am setting up a team project under git source control, and all members of the team will be using different IDE-s. The project is a basic command line application written in C. Personally I want to work within Xcode7, but I have a problem with the xcodeproj file (or folder) which is also being committed. I dont want this, since other team members dont work with Xcode and this xcodeproj file just does a mess when they checkout. I just want to be able to commit my regular source files to git and nothing else. What should I do? If the answer is .gitignore file, how should it look?
Just add these two lines to .gitignore:
*.xcodeproj/
DerivedData/
The first line excludes the Xcode project directory. The second excludes the default directory created for object files and other build data.

unable to open executable Library/Developer/Xcode/DerivedData/ myAppTests.xctest/MyApp For AppTests': No such file or directory

I get an error when I'm trying to build my App saying that Xcode is unable to find some file (xctest files i believe).
FYI: I recently changed the name of the project from the sidebar in Xcode and it asked me if wanted to update the name of all the other files as well and I said yes so it probably has something to do with that.
Anyone ever experienced that?
It's a very nominal error. To solve the error:
Clean the project
Delete the derived data
Can I safely delete contents of Xcode Derived data folder?
Delete "XCTest.Framework" file from Project Navigator > Targets >
'Project Name' > Build Phases
Try cmd + shift + K to clean

Exclamation (!) sign against a file in Xcode

I have check out an SVN repository from XCode. I have moved some files from one project to another in workspace. Its showing exclamation sign against some files.
When I click on that file in XCode commit window it says :
The revision HEAD was not found for the file ".../RequestLogger.h".
What should I do for that, do I need to commit those files as well?
You will have to delete that file and add a new file with a new name(even a single character change in name will work). would get updated in repository then.

XCode 3.1.2, header file not found

I have been trying to build a code that has dependencies with other header files that are not in the project directory. I added the paths to these header files in both HEADER_PATH and USER_PATH. However, I still see error while building. It says that the file is not found. I verified that the file exist in the path added to the header search path in project settings.
How do I make sure that all my header files referenced in the project is included and the paths are being picked by Xcode during compilation?
I tried copying all the files to the project with no luck. This is the first time iam using Xcode, so its kind of frustrating. Iam a linux guy and comfortable with make files. Is there a Make file for xcode which i can modify to include the header file directories.
You might want to check the order of your source files in your target's build phases to ensure that your dependencies are compiled before your source files that reference them.
Select your project in the Project Navigator.
Select your target.
Click on the Build Phases tab.
Click on Compile Sources to expand the section.
Drag the dependencies to the top of the list.
Are you sure you spelled the header file name correctly ? Is the case correct ? Did you use user quotes "" rather than system quotes <> ?
Assuming you've checked all the obvious things such as the above then one other thing to try is to quit Xcode, delete the "build" folder in your project directory, and try again - sometimes the build folder gets in a pickle internally.

Resources