I have added my iphone as device and associate it with provisioning. Then I download the newest provisioning and install it (I have successed added ipad as test device before).
Now, in the “Organizer”, I can see the iphone device but when I connect iphone device I can not find the iphone device to run my app. My software version is 4.2.1, is it the version not the latest that lead to this problem? Or what is the possible reason?
Yes, the software version of the iPhone matters. It has to be within the range of the minimum deployment target outlined in your project. So:
If you pull up your “project” settings (click on the top most folder at the root of the list of all of the source files tree structure in the project navigator panel on the left, then in the main panel click on your project name underneath “PROJECT” and the select the “Info” tab, there’s something there that says “iOS Deployment Target”. If that iOS version is greater than the iOS version of your device, you won’t see the device listed in Xcode’s schemes (where you select devices v simulators). By the way, it’s ok if your app’s “base SDK” is a higher number (just make sure you don’t use any iOS 5-only method, or if you do, make sure your program programmatically tests for the existence/support of those methods), just make sure the deployment target is low enough for your device. Anyway, if you change the “iOS Deployment Target”, your device should show up. (Also, by the way, if you altered your target’s minimum deployment (i.e. if you ever changed it so it no longer defaults to the project’s minimum “iOS Deployment Target”), you might have to tweak that setting, too.)
Also, if your iOS version is 4.2.1, I wonder if you’re dealing with an iPhone 3G (the model before the 3GS). I say that because 4.2.1 is the maximum iOS version on that old hardware. Anyway, if this is the case, you should understand that the iPhone 3G and early iPod touches use the ARMV6 processor, rather than the ARMV7 processor. So even if you change the “iOS Deployment Target” to iOS 4.0, for example, you’ll see your iPhone 3G show up on the list of devices for which you can build, but it won’t work (and it won’t give you any meaningful error message). This is only a concern if you’re dealing with the 3G or earlier. To support those older devices (if this is a concern), in addition to the “iOS Deployment Target” setting discussed above, you also have to go to the “Build Settings” tab, find the “Architectures” entry, and make sure you add “armv6” as another option (click on the value next to “Architectures” (it might say something like “Standard (armv7) – $(ARCHS_STANDARD_32_BIT)”, click on “Other…”, and when you get the dialog box, click on “+” and add “armv6” (without quotes) as an acceptable value.
Once you do this, you may want to click on the button about “Validate Settings”, because there’s a cpu related fix that it suggests. Don’t know if you need it, but I let it fix my project.
Finally, you will want to go back to your Project Navigator panel on the left (where you see all of your source files), find your app’s plist (easiest to just type “plist” in the search box in the bottom left corner underneath the files), and go to the “Required device capabilities”. Expand that list and if you see armv7 there, just get rid of the armv7 entry.
Points 2-4 are only required if you need to support older hardware, but this is unnecessarily complicated and unintuitive. Hopefully this helps.