Prepare Provisioning profile:
Keychain Access–>Certificate Assistant–>Request a Certificate from a Certificate Authority–>input email address (App ID), saved to disk.
Sign in https://developer.apple.com–>iOS Provisioning Portal–>Certificates–>Request Certificate–>input the certificate you saved to disk–>Submit. (Administrator will approve it.)
From the email you input in keychain access, click the invitation code, and you will be invited to "Apple Developer Program"
Download provisioning profile: Xcode–>Organizer–>Devices–>Library–>Provisioning Profiles
Click Referesh: input App ID, download many profiles, not only yours.
Sign in https://developer.apple.com–>download your profile to disk–>drag it to provisioning profiles–>just your profile list there.
You may have two profiles: one is a specific profile (i.e. it can be just used for specific app), the other is a generic profile. (i.e. it can be used for all apps you develop)
Xcode–>targets–>your app–>change "code signing identity" to your identity. Then you can select you device from scheme, to run/debug/install you app in your device.
Distribute:
Xcode–>Product–>Archive–>generate .xcarchive file to disk, and it is also listed in Organizer–>Archives
Organizer–>Archives–>click one .xcarchive you generated–>Distribute:
Submit to the iOS App store: distribute to app store.
Save for Enterprise or Ad-Hoc Deployment: distribute to other places outside of app store–>Code signing identity(your identity)–>save ipa(build file) file to disk. (not check enterprise distribute)
Distribute to testflight:
Sign in testflight web site (you need register in it first)–>Add a build–>upload the ipa file you saved to disk.
You can install/run you app in your device via testflight.