uniapp2xcode command reference
Export an HBuilderX uni-app project and the DCloud iOS offline SDK as an Xcode project, then build, debug and package it locally with kxbuild.
Usage: uniapp2xcode --project <uni-app project> --sdk <iOS offline SDK> --output <output dir> [options]. uniapp2xcode is a standalone program installed with kxbuild. It has no subcommands. For the full workflow from development to the App Store, see the uni-app stack page.
Options
| Option | Description |
|---|---|
| -p, --project DIR | HBuilderX uni-app project directory, containing manifest.json. Required. |
| --sdk DIR | Root of the DCloud iOS offline SDK, containing HBuilder-Hello/, SDK/ and uniapp.podspec (SDKs for HBuilderX 5.13 and later). Required. Download it from the iOS offline SDK download page. |
| -o, --output DIR | Output directory for the generated Xcode project. Required. |
| --clean | Empties the output directory before exporting. |
| --dcloud-appkey KEY | DCloud app key. Required, or the app reports an AppKey error at launch. Apply for one at dev.dcloud.net.cn for your bundle ID. You can also set it as dcloud_appkey in nativeResources/ios/Info.plist. |
| --bundle-id ID | Bundle ID. Required if nativeResources/ios/Info.plist doesn't set one. |
| --display-name NAME | App name shown on the Home Screen. |
| --version-name / --version-code | Overrides the version and build number from manifest.json. |
| --team-id ID | Development team ID written to the project. |
| --hbx DIR | HBuilderX install directory. Detected automatically if omitted. |
| --skip-build | Skips compiling the pages and uses the existing build output. |
| --force-build | Compiles the pages even if build output already exists. |
| --version | Prints the version. |
Export
The export calls HBuilderX to compile the pages, then generates an Xcode project from them and the SDK, and installs the modules checked in manifest.json with CocoaPods. The app name, version, icons and permission descriptions come from manifest.json. Put any extra Info.plist keys in nativeResources/ios/Info.plist in the uni-app project. Both are applied on every export. The generated project is HBuilder-Hello\HBuilder-Hello.xcworkspace in the output folder.
Modules the current SDK doesn't have or can't link are skipped and listed at the end of the export, for example face verification in the 5.26 SDK. You can also add or remove modules after the export in the uniapp_subspecs list of HBuilder-Hello\Podfile, then run pod install in that folder.
> uniapp2xcode --project D:\work\myuniapp --sdk D:\sdk\HBuilder-iOS-SDK --output D:\work\myuniapp-ios --bundle-id com.example.myapp --dcloud-appkey YOUR_APPKEY --cleanAfter you change page code in HBuilderX, run the same command again to bring the changes into the iOS project.
After the export
The .xcworkspace in the output directory is an ordinary iOS project. Run doctor on it first, then build it or debug it in VS Code.
> kxbuild doctor D:\work\myuniapp-ios\HBuilder-Hello\HBuilder-Hello.xcworkspace> kxbuild build D:\work\myuniapp-ios\HBuilder-Hello\HBuilder-Hello.xcworkspace -s HBuilder -c Release