You'll first need to obtain an Apple Developer Certificate. See apple documentation for this.
Open the Keychain Access application (in the Applications/Utilities folder).
If you have not already added the certificate to Keychain, select File > Import. Then navigate to the certificate file (the .cer file) you obtained from Apple.
Select the Keys category in Keychain Access.
Select the private key associated with your iPhone Development Certificate. The private key is identified by the iPhone Developer: public certificate that is paired with it.
Command-click the iPhone Developer certificate and select, Export "iPhone Developer: Name...". as p12 and don't forget to add a password to it:
2. Create provisioing profile:
Open this link: https://developer.apple.com/account/ios/profile/
Create new profile and choose the certficate you exported above and the your device.
Now you should have 2 files,
cert.p12 with a password and
click on add a key and select the 2 files you've already generated
Click on the lock and enter the p12 file password, then submit the key:
You should now have the ipa file ready to be downloaded:
To install the ipa file using xcode:
click on window > Devices and Simulators:
Then click on add and choose the ipa file: