Are subversion conflicts in project.pbxproj normal? - iphone

If I add files to my project, and my co-worker adds files to his project, and we both check our files in, should we expect to have conflicts? What's the best way to handle this?

This happens often enough to me that I have a shell script to fix these things - almost all the time merge conflicts are just because you and another person have both added new files to the project, and so you just want to keep both sides of the merge. Run this script in the main project directory (where the build and Classes directory is) any time you have a merge conflict, go to XCode to make sure it can load the merged project before you commit the fixed merge!
Note that I use this with git, you may want to check whatever merge conflict markers there are in your code use the characters below to show sections in conflict (==== is the middle divider).
mergeproj.sh
#!/bin/sh
projectfile=`find -d . -name 'project.pbxproj'`
projectdir=`echo *.xcodeproj`
projectfile="${projectdir}/project.pbxproj"
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile
cp $projectfile $savefile
mv $tempfile $projectfile

Yes, this is common.
I usually just resolve the conflicts by hand in a text editor; the project format isn't actually that hard to read. If the changes are small (just adding or removing a few files) you could just reappy the change through the Xcode UI if you prefer.

Yes there will be conflicts. The best way to fix this is to open the .prxproj in a text editor like TextMate, and search for the lines with >>>. Just remove the svn merge stuff (the lines with arrows and the line telling you which branch it came from). Then save the file and mark it as resolved. You're done!

You could use FileMerge which comes with XCode. You can find it under the developer folder under Applications and then Utilities.
When you open FileMerge drag the 2 files you need to compare one into the left and one into the right. Go through and select the arrows indicating differences and choose left, right or both on the bottom right.
After you have completed this do a save as and save the file with the changes to the original file name.

Related

How to add retina images to svn

I need to help for you.
I made images for retina display like "****#2x.png".
but it can not add to svn like this.
******-no-iMac-2:baz shunter$ svn add retina_images/foo#2x.png
svn: warning: 'retina_images/foo' not found
I know how to add resource each like this.
******-no-iMac-2:baz shunter$ svn add retina_images/foo#2x.png#
A (bin) retina_images/foo#2x.png
but I made many images, so I feel so bad to do this way.
I really want to know how to add like this.
******-no-iMac-2:baz shunter$ svn add retina_images/bar/*.png
Please help!!
http://developers.enormego.com/view/add_2x_ios4_resources_svn
This is due to internal path recognizers in SVN. It expects the last at symbol to specify a revision. This is easily corrected by adding an at symbol to the end of your file:
$ svn add Default#2x.png#
A (bin) Default#2x.png
By Shuan (not me:)
The svn command interprets the # as an attempt to specify an SVN revision number (#REV format), so...
To add a single file:
svn add filename#2x.png#
Now svn sees the final # as the #REV specifier instead of the first one.
To add multiple files: (each with the # symbol added to the end of the file-name)
ls *2x.png | xargs -I x svn add x#
This lists *2x.png which will list all your retina images (in the current directory) and the output goes through xargs, which executes the svn add command for each file. The -I x tells xargs to replace 'x' with the file-name, so svn add x# becomes the correct file-name with the '#' symbol added to the end.
I had this exact problem a few days ago and solved it this way:
berry$ for i in retina_images/bar/*.png
do
svn add $i#
done
A (bin) retina_images/bar/foo1#2x.png
A (bin) retina_images/bar/foo2#2x.png
A (bin) retina_images/bar/foo3#2x.png
A (bin) retina_images/bar/foo4#2x.png
berry$ svn commit
It's not, perhaps, an ideal solution to the problem, but it worked and I could move on.
I did it like this (in terminal)
svn add Images/icon#2x.png#
Or
The best way is go to Xcode, right click on the image>source control add. It adds the images without showing any error.
This question is a bit old now but I notice nobody had yet posted a truly easy one-liner for adding, via terminal, ALL new image files, regardless of extension or "#2x" status - or for removing them. I have these lines in my bash_profile:
alias svn_addall="svn st | grep '^?' | sed -e 's/#2x.*/&#/' | awk '{print \$2}' | xargs svn add"
alias svn_delall="svn st | grep '^\!' | sed -e 's/#2x.*/&#/' | awk '{print \$2}' | xargs svn rm"
Then if you run svn_addall from any subfolder in your project, it will add ALL files, recursively, whether or not they have #2x in the name.
e.g. all of the below would be added in one go:
? header_bar.png
? bg#2x.jpg
? bg.jpg
? header_bar#2x.png
svn_delall, in the same way, removes all those pesky !-marked files that you've deleted via Finder but not yet from svn ;)
Note, these are modified a bit from other people's scripts I've found online, but the others were always either png specific (what about #2x.jpg?), or they only add retina files without also adding other missing "normal" image files.
Do it like this much easier...
Example:
svn add default#2x.png#2x
The best way I have found is through Subversion integration within XCode. Once you have SVN integration setup (XCode>SCM>Configure SCM), Command+click on the item in the Groups & Files window and choose "Add to Repository". To delete an item, hit delete and choose select YES when prompted if you want to remove from source control.

Eclipse's local history...where are files saved?

Can someone explain how Eclipse's local history works?
I accidentally overwrote a file in a project but need to revert to an earlier version.
Is there a chance that Eclipse has the older file cached somewhere?
To complete CurtainDog's answer: from eclipse FAQ
Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history. At any time, you can compare or replace a file with any older version from the history.
Although this is no replacement for a real code repository, it can help you out when you change or delete a file by accident.
Local history also has an advantage that it wasn’t really designed for: The history can also help you out when your workspace has a catastrophic problem or if you get disk errors that corrupt your workspace files.
As a last resort, you can manually browse the local history folder to find copies of the files you lost, which is a bit like using Google’s cache to browse Web pages that no longer exist.
Each file revision is stored in a separate file with a random file name inside the history folder. The path of the history folder inside your workspace is
.metadata/.plugins/org.eclipse.core.resources/.history/
You can use your operating system’s search tool to locate the files you are looking for.
Note, if your need to import your local history into a new workspace, you will need both:
.metadata/.plugins/org.eclipse.core.resources/.history
.metadata/.plugins/org.eclipse.core.resources/.project
to have a functional local history in that new workspace.
Try right-clicking on the file in eclipse, and choose Replace With->Local History.
If there's history available, it'll show up as a list of edit times.
But more importantly, as pointed out in other answers, be sure to put your files in version control! SVN is pretty easy to set up (you don't need a server; it can just use the file system); use it even if you aren't sharing with others.
A tip: whenever you hear yourself say "yes!", check in all of your code. 10 minutes later, you'll be saying "how did I mess that up?"
If you have lost a full package structure due to accidental deletion or svn/cvs override, select the project> right click> Restore from local history => select the files.
VonC's answer has all the information you need for finding the location of your code backups. I would simply add that if you are on a Mac or Linux, you can do something like this:
$ cd [WORKSPACE]/.metadata/.plugins/org.eclipse.core.resources/.history/
$ grep -rl "class Foo" . | xargs ls -lt
This will find all the versions of a file that contains a particular string (ie. "class Foo"), and sort them by date/time to easily find the most recent version.
You can use the link http://wiki.eclipse.org/FAQ_Where_is_the_workspace_local_history_stored%3F is very helpfull
Open the CVS view and you should see a filter for local history. You should then be able to right-click on the correct version and Get Contents or do a manual compare and merge. I'm not sure what the eclipse defaults are for keeping local history but there is a decent chance you'll be able to get your stuff back if you act quickly.

Unable to open project... cannot be opened because the project file cannot be parsed

I have been working for a while to create an iPhone app. Today when my battery was low, I was working and constantly saving my source files then the power went out...
Now when I plugged my computer back in and it is getting good power I try to open my project file and I get an error:
Unable to Open Project
Project ... cannot be opened because the project file cannot be parsed.
Is there a way that people know of that I can recover from this? I tried using an older project file and re inserting it and then compiling. It gives me a funky error which is probably because it isn't finding all the files it wants...
I really don't want to rebuild my project from scratch if possible.
EDIT
Ok, I did a diff between this and a slightly older project file that worked and saw that there was some corruption in the file. After merging them (the good and newest parts) it is now working.
Great points about the SVN. I have one, but there has been some funkiness trying to sync XCode with it. I'll definitely spend more time with it now... ;-)
I came across this problem and my senior told me about a solution i.e:
Right click on your projectname.xcodeproj file here projectname will be the name of your project. Now after right clicked select Show Packages Contents. After that open your projectname.pbxproj file in a text editor. Now search for the line containing <<<<<<< .mine, ======= and >>>>>>> .r. For example in my case it looked liked this
<<<<<<< .mine
   9ADAAC6A15DCEF6A0019ACA8 .... in Resources */,
=======
   52FD7F3D15DCEAEF009E9322 ... in Resources */,
>>>>>>> .r269
Now remove those <<<<<<< .mine, ======= and >>>>>>> .r lines so it would look like this
   9ADAAC6A15DCEF6A0019ACA8 /* BuyPriceBtn.png in Resources */,
   52FD7F3D15DCEAEF009E9322 /* discussionForm.zip in Resources */,
Now save and open your Xcode project and build it. Everything will be fine.
Muhammad's answer was very helpful (and helped lead to my fix). However, simply removing the >>>>>>> ======= <<<<<<< wasn't enough to fix the parse issue in the project.pbxproj (for me) when keeping changes from both branches after a merge.
I had a merge conflict in the PBXGroup section (whose beginning is indicated by a block comment like this: /* Begin PBXGroup section */) of the project.pbxproj file. However, the problem I encountered can occur in other places in the project.pbxproj file as well.
Below is a simplification of the merge conflict I encountered:
<<<<<<< HEAD
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
=======
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
>>>>>>> branch name
sourceTree = "<group>";
};
When i removed the merge conflict markers this is what I was left with:
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
Normally, removing the merge conflict markers would fix the parse issue in the project.pbxproj file and restore the workspace integrity. This time it didn't.
Below is what I did to solve the issue:
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
I actually had to add 2 lines at the end of the first PBXGroup.
You can see that if I would have chosen to discard the changes from either Head or the merging branch, there wouldn't have been a parse issue! However, in my case I wanted to keep both groups I added from each branch and simply removing the merge markers wasn't enough; I had to add extra lines to the project.pbxproj file in order to maintain correct formatting.
So, if you're running into parsing issues after you thought you'd resolved all you're merge conflicts, you might want to take a closer look at the .pbxproj and make sure there aren't any formatting problems!
I got this exact same error because Cordova will allow you to create a project with spaces in it, and Xcode doesn't know how to deal.
I had similar issue.
Below are steps to resolve it:
Navigate to folder where your projectName.xcodeproj.
Right click and select 'Show Package Contents'. You will be able to see list of files with .pbxproj extension.
Select project.pbxproj. Right click and open this file using 'Text Edit'.
You will be able to see <<<<<< .mine , ============ and >>>>>>>>>> .r123. These are generally conflicts that arise when you take update from SVN.
Delete these and save file.
Now, you'll be able to open project without any error message.
Visual analysis of the Xcode project file did not help me to locate error after merging. After looking to syslog found such line when Xcode trying to parse the file:
2/7/14 12:39:12.792 PM Xcode[9949]: CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 4426. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
After fixing that project can be opened ok.
Analyse the syntax of your project file. Check it inside your project in terminal:
plutil -lint project.pbxproj
This will show you the errors from the parser.
Possible problem: Some projects set git merging strategy union for project files. This works for most of the times, but will silently kill your project file if it fails. This strategy is defined in the .gitattributes file in your repository.
I faced the same problem recently when trying to merge my branch with a remote branch. However, none of the above solutions seemed appropriate to my problem.
There were no merge conflicts between the project.pbxproj file in my branch or the remote branch. However, my projectName.xcodeproj file would refuse to open for the same reason as shown in the asked question.
My solution was to look through the project.pbxproj using a text editor and find if there were any irregularities in the file syntax (for e.g. an extra curly bracket). I sped this process up by focusing on the lines which were inserted or deleted in old file as compared to the merged file. On closer examination, I found the cause of my problem was the repetition of the following line :
xxxxxxxxxxxxx /* [CP] Check Pods Manifest.lock */ = {
in my merged file. This led to an unclosed curly bracket and consequent invalid pbxproj syntax. Deleting the above line fixed my problem.
Steps to be followed:-
1.Navigate to folder where your projectName.xcodeproj
2.Right click and select 'Show Package Contents'. You will be able to see list of files with .pbxproj extension.
3.Select project.pbxproj. Right click and open this file using 'Text Edit'.
4.You will be able to see <<<<<<, ============ and >>>>>>>>>>. These are generally conflicts that arise when you take update from Sourcetree/SVN/GITLAB. Delete these and save file.
5.Now, you'll be able to open project without any error message.
I just ran into same problem. I removed generated strings by git as always but Xcode still refused to open .xcodeproj file. But everything was correct, no missing brackets etc. Finally I tried to quit Xcode and open project when Xcode was closed.. then it worked. I hope this helps someone.
EDIT:
for resolving conflicts in your .xcodeproj file you can use this handy script:
Create empty .sh file in your project directory ( e.g. resolve_conflicts.sh )
Here is the script:
projectfile=find -d . -name 'project.pbxproj'
projectdir=echo *.xcodeproj
projectfile="${projectdir}/project.pbxproj"
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile
mv $tempfile $projectfile
Run it from terminal using sh command: sh resolve_conflicts.sh
Revert the project.pbxproj
svn revert --filename--
If you ever merge and still get problems that dont know what they are, I mean not the obvious marks of a diff
<<<<<
....
======
>>>>>>
Then you can analise your project files with https://github.com/Karumi/Kin, install it and use it
kin project.pbxproj
It has make extrange erros that doesn't allow open the project more easy to understand and solve (ones of hashes, groups and so on).
And by the way, this could also be helpful, thought I have not used it try to diff 2 versions of your project files https://github.com/bloomberg/xcdiff so this will give you really what is going on.
In my experience, I needed a combination of tactics for this:
A-
1-Use git merge from the command line to figure out what files need to be resolved
2-Use git add or git rm as appropriate with those files
3-Use git commit to finish the merger
B-
1-for the .pbxproj I removed the <<<< , >>>> and the =====
2- used https://github.com/Serchinastico/Kin to find merging errors, and using SnoopyProtocol's answer I fixed those issues
Note: at one point the only error Kin was showing was: ERROR: line 1197:40 mismatched input '1' expecting NON_QUOTED_STRING
which didn't need to be fixed for the Xcode project to be openable
It sounds like you're going to have to create a new project in Xcode, go into the old directory, and drag all your source files, nibs, and resources into the Xcode files sidebar in the new project. It shouldn't take more than a few minutes, unless you really did a lot of work with custom build settings or targets. Either that, or revert to the last check-in in your source control and manually add any code files which changed between now and then.
And once you get things working again you should look into using something like subversion or mercurial for backup and revision control. Remember that he electrons don't always go where they are supposed to, backup early and often!
change your current project folder nam and checkout module the same project.then add the current file changes.
Just check the project.pbproject file and do a diff against a working version of the project file.
Often times this happens when you have conflicts from a version control system like posted here: User file cannot be parsed in subversion in MAC iphone SDK
Try to find HEAD and _HEAD between the lines and delete this words in project.pbxproj.
Backup this file before doing this..
Goto PhoneGapTest>>platform
Then delete the folder ios
after that go to terminal
then type:
sudo phonegap build ios
after that you can run the project
By reverting, you can undo pulled code.
If you want to undo that pull request just put this command on project path
--> git merge --abort
In case if you did not find in Text === or <<< or >>>> like was for me problem was really simple and fun...
I change name of App in Xcode, but not change it in UnityProjectSettings before build - that was the problem...
subversion will corrupt my project file after a svn up on an almost weekly basis. I'm trying to figure out why it does this right now and came across this problem.

How can I use ClearCase to "add to source control ..." recursively?

I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree?
(I'm on a Windows system, but have Cygwin installed.)
I would rather go with the clearfsimport script, better equipped to import multiple times the same set of files, and automatically:
add new files,
make new version of existing files previously imported (but modified in the source set of files re-imported)
remove files already imported but no longer present in the source set of files.
make a clear log of all operations made during the import process.
So if your 'zip-file delivery needs to be updated on a regularly basis, clearfsimport is the way to go, but with the following options:
clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory
Note the :
-preview option: it will allow to check what would happen without actually doing anything.
'*' used only in Windows environment, in order to import the content of a directory
-nset option.
From CMWiki, about that 'nset' option:
By default, clearfsimport is meant to be used by the vob owner or a privileged user, but users often overlook the -nsetevent option, with which it may be used by any user.
This option drives clearfsimport not to set the time stamps of elements to this of the source file object outside the vob (which requires privileged access).
There is a minor non-obvious side-effect with this: once a version will have been created with a current time stamp, even the vob owner will not be able to import on top of it a version with an older (as it would be) time stamp, without this -nsetevent option. I.e. once you use this option, normal or privileged user, you are more or less bound to use it in the continuation.
Here is one other way I found by using the Windows Explorer:
Select Search... from the context menu on the target directory.
Search for *.
Select all (Ctrl-A) files/directories in the result list.
Select ClearCase > Add to source control... from the context menu on an item in the result list.
There you go ...
Since I did not have access to clearfsimport , I added the files/directories in a two step process:
1.) find . ! -path . -type d | xargs cleartool mkelem -mkpath -nc
This will create nodes for all new directories recursively
2.) find ./ -type f | xargs cleartool mkelem -nc
This will create nodes for all new files recursively
ClearTeam Explorer, version 8 (maybe earlier as well), has recursive add of subdirectories/files when you select "Add to Source Control". When the "Add to Source Control" dialog box appears, check the "Include descendant artifacts of the selected directories" checkbox and uncheck the "Checkout descendant files only, do not checkout descendant directories" checkbox.
You have to use the commandline. The Context menu in Explorer doesnt do this recursively!
clearfsimport –recurse /usr/src/projectx /vobs/projectx/src
Heres a script to do it
And tips to integrate the script from Explorer
http://www.ibm.com/developerworks/rational/library/4687.html
Had a similar requirement to add a directory recursively to ClearCase. Since I did not have access to clearfsimport tool nor do I have ClearCase integrated with Windows Explorer, found an easy solution within ClearCase GUI.
1) Add the root directory using "Add to Source Control" menu option.
2) Click on this directory and then use "ClearCase Search" to search for all Private Files in this directory.
3) Select all from the Search Results and "Add to Source Control"
There you go ! The entire directory is recursively added from within ClearCase GUI
you can get a fix at
http://www-01.ibm.com/support/docview.wss?ratlid=cctocbody&rs=984&uid=swg21117629
You can also add this command to your context menu with a small script...
Ten best Triggers
edit: oh, sorry. didn't saw that this was already suggested...
I agree,
find+select+add-to-source-control from Windows explorer is not a good option if the number of files to be version controlled is huge. As already mentioned above, explorer.exe crashes if we try to add a large number of files.
clearfsimport is the best and the most hassle free utility for this task.
-GP

Can you "ignore" a file in Perforce?

I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.
I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature?
As of version 2012.1, Perforce supports the P4IGNORE environment variable. I updated my answer to this question about ignoring directories with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.
Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this:
-//depot/foo/*.dll //CLIENT/foo/*.dll
-//depot/foo/.../*.dll //CLIENT/foo/.../*.dll
The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the .dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to.
You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter).
-//depot/foo.../*.dll //CLIENT/foo.../*.dll
Yes, But.
Perforce version 2012.1 added a feature known as p4ignore, inspired by Git. However the Perforce developers made a change to the behaviour, without justification, that happens to make the feature a lot less useful.
Whilst Git takes rules from all .gitignore files, Perforce doesn't know where to look until you specify a filename in an environment variable P4IGNORE. This freedom is a curse. You can't hack on two repositories that use different names for their ignore files.
Also, Perforce's ignore feature doesn't work out the box. You can set it up easily enough for yourself, but others don't benefit unless they explicitly opt-in. A contributor who hasn't may accidentally commit unwelcome files (eg. a bin folder created by a build script).
Git's ignore feature is great because it works out the box. If the .gitignore files are added to the repository (everyone does this), they'll work out the box for everyone. No-one will accidentally publish their private key.
Amusingly, the Perforce docs shows '.p4ignore' as an example ignore rule, which is backwards! If the rules are useful, they should be shared as part of the repository.
Perforce could still make good on the feature. Choose a convention for the file names, say p4ignore.txt, so the feature works out the box. Drop the P4IGNORE environment variable, it's counterproductive. Edit the docs, to encourage developers to share useful rules. Let users write personal rules in a file in their home folder, as Git does.
If you know anyone at Perforce, please email them this post.
This works as of Perforce 2013.1, the new P4IGNORE mechanism was first added in release, 2012.1, described on the Perforce blog here:
https://www.perforce.com/blog/new-20121-p4ignore
As it's currently described, you set an environment variable "P4IGNORE" to a filename which contains a list of the files to ignore.
So you can check it out to see how you like it.
If you want a solution that will apply to all work-spaces without needing to be copied around, you (or your sysadmin) can refuse submission of those file-types through using lines like the below in the p4 protect table:
write user * * -//.../*.suo
write user * * -//.../*.obj
write user * * -//.../*.ccscc
I remember doing this before, but I don't have the necessary permissions to test this here. Check out Perforce's Sysadmin guide and try it out
Perforce Streams makes ignoring files much easier, as of version 2011.1. According to the documentation, you can ignore certain extensions or certain paths in your directory.
From p4 help stream
Ignored: Optional; a list of file or directory names to be ignored in
client views. For example:
/tmp # ignores files named 'tmp'
/tmp/... # ignores dirs named 'tmp'
.tmp # ignores file names ending in '.tmp'
Lines in the Ignored field may appear in any order. Ignored
names are inherited by child stream client views.
This essentially does what #raven's answer specifies, but is done easier with streams, as it automatically propagates to every work-space using that stream. It also applies to any streams inheriting from the stream in which you specify the ignore types.
You can edit the stream via p4 stream //stream_depot/stream_name or right-clicking the stream in p4v's stream view.
And as #svec noted, the ability to specify ignore files per workspace is coming soon, and is in fact in P4 2012.1 beta.
Will's suggestion of using .p4ignore only seems to work with the WebSphere Studio (P4WSAD) plugin. I just tried it on my local windows box and any files and directories that I listed were not ignored.
Raven's suggestion of modifying your client spec is the correct way under Perforce. Proper organization of your code/data/executables and generated output files will make the process of excluding files from being checked in much easier.
As a more draconian approach, you can always write a submit trigger which will reject submission of change-lists if they contain a certain file or files with a certain extension, etc.
HISTORICAL ANSWER - no longer correct. At the time this was written originally it was true;
You can not write and check in a file that the server will use to make ignore rules; general glob or regexp file pattern ignore in perforce.
Other answers have global server configurations that are global (and not per folder).
The other answers show things that might work for you, if you want one line in your view per folder times number of extensions you want to ignore in that single folder, or that provide this capability in WebSphere Studio plugins only, or provide capability for server administrators, but not available to users.
In short, I find Perforce really weak in this area. While I appreciate that those who use the Eclipse Plugin can use .p4ignore, and I think that's great, it leaves those of us that don't, out in the dark.
UPDATE: See accepted answer for new P4IGNORE capability added mid-2012.
I have found it easiest to reconcile offline work using a BASH script like this one:
#!/bin/bash
# reconcile P4 offline work, assuming P4CLIENT is set
if [ -z "$P4CLIENT" ] ; then echo "P4CLIENT is not set"; exit 1; fi
unset PWD # confuses P4 on Windows/CYGWIN
# delete filew that are no longer present
p4 diff -sd ... | p4 -x - delete
# checkout files that have been changed.
# I don't run this step. Instead I just checkout everything,
# then revert unchanged files before committing.
p4 diff -se ... | pr -x - edit
# Add new files, ignoring subversion info, EMACS backups, log files
# Filter output to see only added files and real errors
find . -type f \
| grep -v -E '(\.svn)|(/build.*/)|(/\.settings)|~|#|(\.log)' \
| p4 -x - add \
| grep -v -E '(currently opened for add)|(existing file)|(already opened for edit)'
I adapted this from this Perforce Knowledge Base article.
I'm looking for a .p4ignore like solution as well (and not one tied to a particular IDE). Thus far, the closest thing I've found is p4delta. It sounds like it will do exactly what the original poster was asking, albeit through another layer of indirection.
http://p4delta.sourceforge.net
Unfortunately, while this does seem to produce the proper list of files, I can't get "p4delta --execute" to work ("Can't modify a frozen string") and the project has not been updated in year. Perhaps others will have better luck.
If you are using the Eclipse Perforce plugin, then the plugin documentation lists several ways to ignore files.