uni-app iOS Build on Windows: Local Offline .ipa, No Queue
With the KXBuild HBuilderX plugin, run on your iPhone, push pages and build an .ipa, with no cloud packaging and no waiting in a queue. Offline packaging is no longer a hassle.
Last updated
Build uni-app for iOS locally on Windows with no DCloud cloud packaging, no queue and no build count: with the KXBuild plugin for HBuilderX, you run the app on a USB-connected iPhone straight from HBuilderX, push changed pages to the phone in seconds and build the release .ipa there too. Before you start, get a DCloud offline packaging AppKey, the iOS offline SDK that matches your HBuilderX version, and your own Apple certificate and provisioning profile.
How do I install the KXBuild plugin in HBuilderX on Windows?
- Install KXBuild, then run
kxbuild doctoronce. If HBuilderX is already on your computer, the plugin is installed along with it; runningkxbuild doctoragain later updates the plugin to the latest version. - Quit HBuilderX completely and open it again.
- Sign in to your DCloud account in HBuilderX and get an AppID under "基础配置" (basic settings) in manifest.json.
The plugin's commands are under right-click on the uni-app project in the Project Manager → KXBuild iOS, and the common ones are also in the top menu. The top-menu items appear only after you select a uni-app project in the Project Manager.
If the Run menu still has no 运行到 iPhone 真机 (KXBuild) after you select a uni-app project, download the plugin, unzip kxbuild-hbuilderx-plugin.zip into the plugins folder of your HBuilderX installation so you get plugins\kxbuild-hbuilderx-plugin, then quit HBuilderX completely and open it again.
| Menu | What it does |
|---|---|
| 运行 → 运行到 iPhone 真机 (KXBuild) Run on iPhone | Compiles the pages and the app, installs it on the connected iPhone and launches it |
| 运行 → 推送页面到 iPhone (KXBuild) Push pages to iPhone | Compiles only the pages, replaces the app's pages on the phone and relaunches it. Nothing is reinstalled and the app's data is kept |
| 发行 → 生成 iOS App Store ipa (KXBuild) Build iOS App Store .ipa (KXBuild) | Builds an .ipa signed with your Apple Distribution certificate and App Store provisioning profile into unpackage\release\ipa\<app name>.ipa |
| 发行 → 导出 iOS Xcode 工程 (KXBuild) Export iOS Xcode project | Exports to the project's unpackage\kxbuild |
| Right-click → 设置 Bundle ID 与 AppKey Set Bundle ID and AppKey | Changes the bundle ID and the offline packaging AppKey |
| Right-click → 导入 iOS 离线 SDK Import iOS offline SDK | Imports an iOS offline SDK zip you downloaded |
| Right-click → 打开导出的工程目录 Open exported project folder | Opens unpackage\kxbuild in File Explorer |
Which AppKey and SDK do I need for a local uni-app iOS build?
1. Get an AppKey and the offline SDK
The plugin asks for these two things on the first run and remembers them.
- Bundle ID and offline packaging AppKey: in the DCloud developer center, open 应用管理 (app management), select the app, open 各平台信息 (platform info) and add the iOS platform. Enter the bundle ID, then create an offline packaging key. The bundle ID must match the App ID in your Apple Developer account. Both values are saved in the project's nativeResources\ios\Info.plist.
- iOS offline SDK: download the SDK zip that matches your HBuilderX version from the iOS offline SDK download page. Don't unzip it. Select the zip in the dialog. You import it once per HBuilderX version, so import the new SDK after you update HBuilderX.
To change the bundle ID or AppKey or switch SDKs later, right-click the project → KXBuild iOS → 设置 Bundle ID 与 AppKey or 导入 iOS 离线 SDK. For Vue 2 projects, HBuilderX can't be installed in a folder whose path contains parentheses (such as Program Files (x86)), or page compilation fails.
How do I run uni-app on an iPhone and push page changes?
2. Run on the iPhone
Connect the iPhone over USB and choose 运行 → 运行到 iPhone 真机 (KXBuild). The first run takes a minute or two, and progress shows in the HBuilderX console. Set the app name, version, icons and permission descriptions in manifest.json. Put extra Info.plist keys in the project's nativeResources\ios\Info.plist. They're applied on every run.
3. Push changed pages to the phone
Keep writing pages in HBuilderX as usual. When you've only changed pages, styles or JS, use 运行 → 推送页面到 iPhone (KXBuild). The change shows on the phone in a few seconds and the app's local data is kept. When you change native settings in manifest.json, such as modules, permissions or icons, or switch to another phone, use 运行到 iPhone 真机. If the pages changed too, that uninstalls the old version from the phone before installing, so the app's local data is cleared.
4. Debug
Debug page JS with the tools built into HBuilderX. To set breakpoints in native code, open the project's unpackage\kxbuild folder in VS Code (it's created when the plugin runs or exports), select the device in the KXBuild view and press F5. The two work independently, and you still push page changes from HBuilderX.
Before you connect a phone for the first time, install and open Apple Devices from the Microsoft Store to get the USB driver on Windows. On iOS 16 and later, turn on Developer Mode in Settings > Privacy & Security and let the phone restart. See connect an iPhone to Windows for the full steps.
How do I build a uni-app iOS .ipa locally on Windows?
5. Publish
Set up your distribution certificate and provisioning profile as described in sign iOS apps on Windows, then build the .ipa. To upload it to App Store Connect, see publish to the App Store from Windows.
Choose 发行 → Build iOS App Store .ipa (KXBuild). The .ipa, named after the app, is created in the project's unpackage\release\ipa.
After exporting the project, build it for the App Store. The .ipa is created in HBuilder-Hello\build in the export folder.
> kxbuild build .\unpackage\kxbuild\HBuilder-Hello\HBuilder-Hello.xcworkspace -s HBuilder -c Release --export app-storeHow do I build uni-app for iOS offline from the command line?
If you don't use the HBuilderX plugin, or you package from a script, export the Xcode project with uniapp2xcode, then build it like any other iOS project. Run these in the uni-app project folder:
> uniapp2xcode sdk import D:\Downloads\iOS-SDK.zip> uniapp2xcode config --project . --bundle-id com.example.myapp --dcloud-appkey YOUR_APPKEY> uniapp2xcode --project . --sdk auto --output .\unpackage\kxbuild --updateYou only need to run the first two once. While HBuilderX is open, you can also drive the plugin from a terminal with the cli in the HBuilderX installation folder, for example cli kxbuild --action run --project <project folder>. The action can also be push, ipa or export. For all options, see the uniapp2xcode command reference.
How do I fix common uni-app iOS build errors?
| Symptom | Fix |
|---|---|
| The KXBuild commands aren't in the top menu | Select the uni-app project in the Project Manager first. If they're still missing, check that package.json sits directly in plugins\kxbuild-hbuilderx-plugin, then quit HBuilderX completely and open it again |
| You're told you aren't signed in or the AppID doesn't exist, or the app reports an AppKey error as soon as it opens | The AppID, AppKey and bundle ID belong together. Sign in to your DCloud account in HBuilderX and get the AppID under "基础配置" in manifest.json. Then on dev.dcloud.net.cn, apply for an offline packaging AppKey for that bundle ID on the app's iOS platform. The bundle ID you enter in the plugin must match the one you used for the AppKey and the App ID in your Apple Developer account |
| Page compilation fails with a message that the HBuilderX install folder can't contain characters like ( | This is a Vue 2 limit. Move the whole HBuilderX folder to a path like D:\HBuilderX, or switch the project to Vue 3 in manifest.json |
| The app reports a version mismatch or shows a blank white screen after launch | The offline SDK version doesn't match HBuilderX. Download the SDK for your current HBuilderX version, import it with right-click → KXBuild iOS → 导入 iOS 离线 SDK, then run again |
| You changed pages but the phone still shows the old ones | Update with 推送页面到 iPhone or 运行到 iPhone 真机. Reinstalling with F5 in VS Code doesn't update the pages |
| After running, the app's sign-in state and local storage are gone | When pages changed, 运行到 iPhone 真机 uninstalls and reinstalls the app. When you've only changed pages, use 推送页面到 iPhone and the data is kept |
| Export reports that some modules were skipped | The current SDK doesn't have that module, or its library can't be linked, for example real-person verification in the 5.26 SDK. The other modules are packaged as usual. The skipped ones need a fixed SDK from DCloud |
For an error that isn't in the table, first check that the AppID, AppKey and bundle ID belong together and that the offline SDK matches your HBuilderX version, then run kxbuild doctor again. For the command-line options of a uni-app iOS build on Windows, see uni-app offline iOS build on Windows, and for submission see publish to the App Store from Windows.
Next steps
Build and configure
Debug versus Release, choosing a scheme, target and configuration, overriding build settings, where build products go, when you get an .ipa and when Swift package dependencies resolve.
Release and App Store submission
Build Release with a Distribution certificate to get an .ipa, upload it to App Store Connect with kxstore (or Transporter on a Mac), then go through TestFlight and App Review. Ad Hoc and enterprise distribution work the same way.
Don't see your framework?
kxbuild is a general-purpose build toolchain, so if your framework produces an Xcode project, KXBuild can build it. The list above covers common cases only. Tell us about your setup.