I've been working on an iPhone project with iOS 4.0. I just downloaded Xcode 3.2.4 with iOS SDK 4.1 so that I can work with the updated iOS. Upon opening the project in the udpated Xcode, I found that the target read 'Base SDK Missing'. I fixed that by following the instructions here.
Now when I try building targeting any version of iOS, I receive this error (with the corresponding version referenced in the error text):
CodeSign Error: code signing is required for product type 'Application' in SDK 'Device - iOS 4.1'
It happens when Xcode doesn't recognize your certificate.
It's just a pain in the ass to solve it, there is a lot of possibilities to help you.
But the first thing you should try is removing in "Window" tab => Organizer, the provisioning that are in your device. Then re-add them (download them again on the apple website). And try to compile again.
By the way, did you check in the Project Info Window the "code signing identity" ?