How to use device instead of Simulator

2019-01-15 21:27发布

问题:

I am a new with iphone development and want to test my application on my iphone . I have paid $100 but can not find any way to workout how to do that . There are some references around but they are for xcode 3.

Any help would be much appreciated.

回答1:

First you have to get your developer certificate/keys set up on your mac. See the developer portal where there are detailed instructions on how to get this set up.

Once you have your certificate, plug in your device, and press cmd + shift + 2 in XCode - to load up the organizer. Select the devices pane, click on your device, and click the 'use for development' button. It will ask you to put your username/password in for your dev account, and then it will enable your device for development. After it has been enabled, you simply select it as the target to build to in the top-left of the main Xcode window.



回答2:

I know this question has been answered already, but I have had a lot of hair pulling trying to get XCode4 to install directly to my device. Heaven help you if you are trying to get multiple machines to install to the same device.

My best advice, let XCode4 do all the work for you. Trying to manually configure your certificates will only lead you to bashing your computer or device to smithereens.

If you get stuck, or only get half of it working, follow these steps.

  1. Delete all of your certificates from Keychain. You can leave the Apple Dev certificate, but everything else must go.
  2. Set your project to No Code Signing for everything. If you have any old provisioning profiles you've used, you don't want your project looking at anything.
  3. In Organizer, delete any provisioning profiles you have there. For XCode4 as well as your device.
  4. I usually close my project, but this could be an option step.
  5. Delete your developer certificate in the Apple Developer Portal. It will complain, but too bad.
  6. DO NOT DELETE ANY PROVISIONING PROFILES ON THE WEBSITE. You'll need these later. They should all be configured already to your devices and testing team. They are fine.
  7. Open Organizer and under Provisioning Profiles there should be the Import button and check box to let XCode4 do the work for you. Use that button to let XCode set it all up.
  8. It should tell you that you don't have a developer certificate and auto request one, let XCode request it. It will probably prompt you for your developer credentials at some point.
  9. It will take a few seconds, but it should pull in any Provisioning Profiles associated with your account, create the developer certificate in your keychain, and if your device is plugged in, copy the most current provisioning profile to your device.
  10. Open your project, select iPhone Developer for your build. If it is blank, select it anyway, it should associate with the correct profile for running.
  11. Run your build with your device selected and you should be good to go.

I had a terrible run of trial and error to get these working as I was working between the normal Xcode and the beta build. I don't wish code signing issues on my worst enemy. Hopefully this will work for you and anyone else that runs into issues with it. Good luck!