Skip to main content

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

Run a uni-app project on a real iPhone from HBuilderX with the KXBuild plugin, push page changes to the phone in seconds, and build a release .ipa, with no cloud build queue.
Show steps for

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?

  1. Install KXBuild, then run kxbuild doctor once. If HBuilderX is already on your computer, the plugin is installed along with it; running kxbuild doctor again later updates the plugin to the latest version.
  2. Quit HBuilderX completely and open it again.
  3. 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.

Download the HBuilderX plugin

MenuWhat 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-store

How 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 --update

You 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?

SymptomFix
The KXBuild commands aren't in the top menuSelect 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 opensThe 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 launchThe 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 onesUpdate 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 goneWhen 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 skippedThe 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

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.