The app works fine in the simulator, builds and runs.
When I attach my device (iPhone 3GS running iOS 4.3) and target the iPhone, the result is \"Build failed\" with
Go to Organizer in xcode. And in Project Tab, delete that project. Let xcode rebuild the derived data again fix my problem.
This happened to me with my UnitTest target. Was working and then stopped. I'd forgotten i'd just deleted a .h/.m on the file system and not removed it from the project file, however XCode didn't report it.
I figured it out by running the project on the command line, which told me the error:
/usr/bin/xcodebuild -target "UnitTest"
Run this in the folder you have your project file, and replace UnitTest with your target - or just don't pass in a target to build the default target.
I had this problem too, but the cause was a different one:
I have a workspace with one project in it. In this project I use a framework which is included by adding it's Xcode project to my project. I imported the framework's header file in my prefix header (.pch). This was stupid.
The solution was to remove the #import of the framework header file from my prefix header file and add it only where needed.
Same problem here when building for device. Build failed, but my log all is green checkmarks. Cleaning/deleting build folder doesn't fix it. I read elsewhere that someone solved this problem by deleting and recreating the target, but I haven't completely figured out how to do that yet in XCode 4.
My temporary solution has been to download and install XCode 3.2.6 w/iOS 4.3. I didn't realized that Apple had also released a version of XCode 3 that includes iOS 4.3, allowing you to postpone the upgrade to XCode 4. I filed a bug report with Apple about the Build Failed issue.
udpate from Apple:
When we build this project - albeit on a post-Xcode 4.0 version - we see the following in the ProcessProductPackaging step in the build log:
(null): error: CFBundleIdentifier 'com.yourcompany.Magic_Carpet' contains illegal character '_' invalid bundle identifier 'com.yourcompany.Magic_Carpet'
The ProcessProductPackaging code got an overhaul fairly recently, so we suspect it just wasn't emitting errors properly in Xcode 4.0. Take a look at the transcript of your own build, and if so, then this will likely be fixed in a future release of Xcode (we cannot comment further until a fix has been released).
I switched from an underscore to a dash and it fixed the problem.
Same thing just happened to me with a different cause.
I removed get-task-allow from my Entitlements.plist file, leaving an empty plist. Build settings still had Entitlements.plist file specified as my Entitlements file. Chose to run using my Ad-Hoc build settings on iOS device with my iPhone connected, and saw the behavior described in this bug. Adding get-task-allow back fixed it.
I just had a similar problem. Could not find an error anywhere. Deleted all my provisioning profiles and added new ones.
Then I tried building another test app to my device and I got this error message:
Code Sign error: Certificate identity 'iPhone Developer: xxxxxx' appears more than once in the keychain. The codesign tool requires there only be one.
So I went into Keychain, found a couple of expired certificates with the same name, and deleted them, and that did the trick.
Pretty random, but perhaps if you try building another app to the device like i did, you might be lucky enough to get an error message, as i did, to help diagnose the problem.