views:

34

answers:

2
+1  Q: 

Resources check

hey I am frequently uploading my XCode iPhone projects to an svn repository to be build on another machine.

My problem is that when I add resources to my project sometimes I forget to add the resource as relative to the project.

I know one answer is to be more careful (not easy when your tired!) but if there was a way to run a script to check my resource paths are relative when I build and warn me if they are not it would be a great time saver for me.

How would I go about doing this?

Thanks

Chris

+1  A: 

You can select all the files in your project and set the Path Type for all of them in one go. While this isn't a script this does save a lot of time over doing the files individually

I think the best approach to script this would be to look in the .xcodeproj file - the file paths are listed in there. If your project is called MyProject you need to open (either by using Show Package Contents in Finder or just the usual cd in Terminal) the MyProject.xcodeproj directory.

In here you'll find a file called project.pbxproj - open this in a editor that won't mess up your formatting and have a peek around the file. If you search for one of your files in the project you should be able to see how Xcode stores references to the project files.

Look for a section named /* Begin PBXFileReference section */. In here all your files are listed, along with where they are relative to the project, e.g.:

... path = Classes/MyClass.h; sourceTree = SOURCE_ROOT

If you can parse this file you should be able to acheive what you want - but remember to back up the file, otherwise you might corrupt your project.

pheelicks
yeh its an option.. would really like to know more about how to script such a thing though.
Chris
A: 

How would it be if you instead write a script that asks the SCM if anything in the project is not committed? For example, think of this scenario

Project Root

  Codex

    Project.xcodeproj
    …

  Design

    anImage.png

where anImage.png being outside of Codex, where the Xcode project sits (its path starts with a ../). A strong .pbxproj parser would have to support all the variants in which Xcode references files to know exactly if there are stray files.

OTOH, the SCM knows where everything is all the time (you mentioned up-ping to a SVN server), so why not ask it instead.

  • We have a Ruby script that prints a warning in Xcode’s Build Log if anything in the project is not committed.
Evadne Wu