How to Sign iOS Apps on Windows: p12 Certificates and Profiles
You can build without a certificate, but you can't install on a device. Put your .p12 and .mobileprovision in the keychain folder and every build signs automatically. Also covers choosing a certificate in the project and overriding it on the command line.
Last updated
To sign iOS apps on Windows you need three files: a .p12 certificate and a .mobileprovision profile from your Apple Developer account, plus a password.properties file with the certificate passwords. Put them in a keychain folder and you're done. From then on kxbuild picks the right certificate from the project's signing settings, every build comes out signed and ready to install on an iPhone, and Release builds produce an .ipa you can upload. WSL, Linux and macOS work the same way.
How do I set up a signing certificate for an iOS app on Windows?
Put your .p12 certificate, .mobileprovision profile and the password file password.properties together into a keychain folder, and signing is set up. If you don't have a certificate and profile yet, see Create a certificate and provisioning profile below.
The keychain folder can be in two places, and certificates from both are used together:
- <project>/keychain/: for that project only
- KXBUILD_HOME/keychain/: shared by all projects. By default %USERPROFILE%\kxbuild\keychain\ on Windows and ~/kxbuild/keychain/ on WSL, Linux and macOS
On macOS, certificates in the system keychain can also be used directly.
password.properties has one line per certificate in the form file=password. The file name must match the .p12 exactly, and the password has no quotes.
development.p12=123456
distribution.p12=123456From then on, every build signs automatically according to the project's signing settings. There's nothing to configure in KXBuild. Without a certificate the project still builds, but the product is unsigned and won't install on an iPhone.
Where do signing certificates and passwords go when I build in WSL?
When you build in WSL, the keychain folder is ~/kxbuild/keychain/ inside WSL. Certificate files are usually downloaded on Windows. Copy them in with either method below, then edit password.properties to add the passwords.
1. Open the folder in Windows Explorer
In a WSL terminal, go to the keychain folder and open it with explorer.exe, then drag your .p12 and .mobileprovision files in:
$ mkdir -p ~/kxbuild/keychain && cd ~/kxbuild/keychain && explorer.exe .Or type \\wsl.localhost\Ubuntu\home\<user>\kxbuild\keychain into the Explorer address bar (replace Ubuntu with your distribution name and <user> with your WSL login name).
2. Copy from a Windows folder inside WSL
Windows drives appear in WSL under /mnt/c/, /mnt/d/ and so on. For example, if the files are in your Windows Downloads folder:
$ cp /mnt/c/Users/<you>/Downloads/*.p12 /mnt/c/Users/<you>/Downloads/*.mobileprovision ~/kxbuild/keychain/3. Set the passwords
Open password.properties in VS Code or a terminal editor and add one file=password line per certificate, as described above. Save it and you're done. There's nothing to restart:
$ code ~/kxbuild/keychain/password.properties$ nano ~/kxbuild/keychain/password.propertiesIf you edit password.properties with Windows Notepad, save it as UTF-8 and make sure no trailing spaces are left at the end of a line.
How do I create a .p12 certificate and provisioning profile on Windows?
You need two files: a .p12 certificate that contains your private key, and a .mobileprovision profile. See the certificate and profile type tables at the end of this page. When you switch to a new iPhone with a Development profile, add its UDID in your developer account and download the profile again.
Both files come from your Apple Developer account. On Windows there are three ways to get them.
1. Generate them with kxstore (recommended)
kxstore is the App Store Connect command line that ships with KXBuild, and it runs on Windows, Linux and macOS. Sign in once first: in App Store Connect, open Users and Access → Integrations → Team Keys, generate an API key, download it and run kxstore login --api-key-file AuthKey_ABC123.json. Then run the three commands below to create the certificate, register your iPhone and create the profile. The private key and CSR are generated on your own computer, and the .p12 and .mobileprovision are saved to the folder you name; point it at the project's keychain folder and the next build uses them. For App Store builds, use the types IOS_DISTRIBUTION and IOS_APP_STORE instead.
> kxstore cert create --type IOS_DEVELOPMENT --out .\keychain> kxstore device add <UDID> --name <name>> kxstore profile create --name "MyApp Dev" --type IOS_APP_DEVELOPMENTYou also upload the .ipa with kxstore when you submit to the App Store.
2. Export them from a Mac
In Keychain Access, export the certificate together with its private key as a .p12, then download the profile from developer.apple.com. A .cer file alone won't work because it has no private key.
3. Generate them with OpenSSL
Generate a private key and a CSR, upload the CSR on the Certificates page at developer.apple.com, download the .cer, then combine them into a .p12.
> openssl req -new -newkey rsa:2048 -nodes -keyout ios.key -out ios.csr -subj "/emailAddress=you@example.com/CN=Your Name/C=CN"> openssl x509 -in development.cer -inform DER -out development.pem> openssl pkcs12 -export -inkey ios.key -in development.pem -out development.p12Which signing certificate does a build use?
kxbuild is compatible with Xcode project signing settings: it follows the project's configuration (General > Signing in the Project Settings Editor) and picks from the keychain folder in three steps:
1. Certificate type
If the signing identity CODE_SIGN_IDENTITY is Apple Development, a development certificate is used; if it is Apple Distribution, a distribution certificate.
2. Team
Only certificates and profiles of the team in DEVELOPMENT_TEAM are used.
3. Provisioning profile
With automatic signing, the profile is matched by Bundle ID and team; with manual signing, it is looked up by the name in PROVISIONING_PROFILE_SPECIFIER.
New projects use Apple Development with automatic signing, so there is nothing to change for day-to-day work.
For an App Store or TestFlight .ipa, run KXBuild: Build for App Store (.ipa) in VS Code, or add --export app-store on the command line. It signs with the Apple Distribution certificate and App Store provisioning profile in the keychain folder, whatever the project's signing settings say:
> kxbuild build .\MyApp.xcodeproj -c Release --export app-storeTo avoid editing the project file on the command line, override settings with -D:
Sign with a different certificate type or team:
> kxbuild build .\MyApp.xcodeproj -D CODE_SIGN_IDENTITY="Apple Development" -D DEVELOPMENT_TEAM=ABCDE12345Build without signing:
> kxbuild build .\MyApp.xcodeproj -D CODE_SIGNING_ALLOWED=NOIf a build fails with No signing certificate matching '…' found, the keychain folder has no certificate of the type or team the project asks for. Add the matching .p12, or use -D as above to switch to a certificate you already have.
What types of iOS signing certificates are there, and which one do I need?
The certificate (.p12) identifies who signed the app. The common types:
| Certificate | Used for | Goes with profile |
|---|---|---|
| Apple Development | Development: run and debug on a test iPhone | Development |
| Apple Distribution | Release: upload to the App Store / TestFlight, Ad Hoc test distribution, in-house distribution with an Enterprise account | App Store Connect, Ad Hoc, In-House |
| iOS App Development | Older development certificate, same use as Apple Development, still works | Development |
| iOS Distribution | Older distribution certificate, same use as Apple Distribution, still works | App Store Connect, Ad Hoc, In-House |
| Apple Push Notification service SSL | Lets your server send push notifications. It does not sign apps, so don't put it in the keychain folder | — |
What types of provisioning profiles are there, and which devices do they allow?
The provisioning profile (.mobileprovision) says which certificate may sign the app and which devices it may be installed on. It is tied to a Bundle ID, which must match the project. The common types:
| Profile | Used for | Certificate | Devices |
|---|---|---|---|
| Development | Development and debugging; Debug builds | Apple Development | Only iPhones whose UDID is registered in the profile |
| Ad Hoc | Send a test build to a few testers outside the App Store | Apple Distribution | Only registered UDIDs, up to 100 per device type per year |
| App Store Connect | Upload to App Store Connect for TestFlight and App Store release | Apple Distribution | Not installed directly; installed via TestFlight or the App Store |
| In-House | In-house distribution with an Enterprise account; employees install directly | Apple Distribution (Enterprise account) | Any device, internal use only |
For everyday development, pair an Apple Development certificate with a Development profile. To send builds to testers or ship, switch to an Apple Distribution certificate with an Ad Hoc or App Store Connect profile. Once the right files from the two tables above are in the keychain folder, you can sign iOS apps on Windows for every build. For packaging and upload, see publish to the App Store from Windows.
Next steps
Set up your device
Get your computer to recognize your iPhone. Install the driver, trust the computer and turn on Developer Mode, download device symbols before your first debug session, and choose between multiple devices.
Troubleshooting
Run kxbuild doctor first. Then look up your error message by category: install, project, signing, device, release or extension. Also covers where to find the logs.