

English
因手机差异较大,HBuilder并没有提供App的模拟器。不管uni-app (x)或5+App/wap2app项目,都需要连接真实的手机或手机模拟器来运行测试,称之为“真机运行”。
The purpose of running the real machine is to realize the hot refresh of code modification and avoid packaging to see the effect. Edit the code in HBuilder, see the modification effect in real time on the mobile phone, and you can see the log in the HBuilder console.
The run entry can be activated through the run menu at the top of HBuilder, the run button on the toolbar, or a shortcut key.
Menu items can be quickly selected by number. For example, press "4" to select "Run to Android App Dock". You can also press the up and down keys and then enter to select.
Compared with the run menu at the top of HBuilder, the run menu under the run button on the toolbar has less content, and only the most common runs are reserved.
Actually activates the toolbar run button. You can continue to match the number keys to achieve quick operation without a mouse.
点击运行到iOS或Android设备时,会弹出选择界面,需选择要连接的手机设备或模拟器。
可以多设备运行,每个运行设备会在HBuilder底部控制台新开一个独立窗口,互不干扰。 But a device can only run one project at the same time, and when different projects run to the same mobile phone, only the last project takes effect.
HBuilderX 4.71+版本,Android设备支持无线连接设备。
If you can't find your phone during the process of connecting the device, you can try to click the "Refresh" button. If you still can't find your phone, please refer to Real Phone Running FAQs
注意事项
USB debugging
mode is turned on in the Android phone settings. Usually in the [Settings] [Developer Options] of the mobile phone, some mobile phones can also be set in the system notification bar after plugging in the data cable. Note that it cannot be set to U disk mode. If it is charging mode, you must set the charging time at the same time. Allow usb debugging
.HBuilderX中自带的标准真机运行基座使用DCloud向苹果申请的企业开发者证书签名,根据苹果开发者企业计划许可协议要求,使用企业开发者证书签名的App只允许企业员工内部使用,不允许企业外部人员安装使用。 因收到苹果公司警告,自2022年9月14日起iOS真机设备不再支持使用标准真机运行基座,详情见论坛公告:https://ask.dcloud.net.cn/article/40041 在iOS真机设备上运行请向苹果申请证书制作自定义基座或者在Mac电脑使用iOS模拟器
注意事项
如果是Mac电脑安装XCode后,“标准运行基座”支持使用iOS模拟器
点击后进入iOS模拟器选择界面
上面的界面会额外显示搜索框,因XCode的iOS模拟器非常多,可通过搜索框过滤快速选择需要使用的模拟器。
When you run it for the first time, you will be prompted to install the "real machine running plug-in".
The plugin has a built-in "Standard Run Dock", which uses DCloud's package name, certificate and third-party SDK configuration. If you want to customize, you need to use custom playground
在运行菜单中选择要运行的手机设备或模拟器,点击运行按钮,会执行如下流程:
运行成功后,HBuilder底部的控制台显示成功日志。此后修改代码会差量同步到手机上,手机程序会动态热刷。同时console.log代码会打印到控制台上,点击打印日志可以跳转到相关代码。
注意:uni-app x 的 web-view 组件网页日志和错误从 HBuilderX 4.51+ 开始支持同步显示到控制台。
Currently only supports MacOSX, not Windows
HBuilderX 3.7.0+ version, newly added to run the App project to the real iOS device, after running successfully, the App on the phone will be opened automatically.
As shown below:
Note: MacOSX needs to install the Xcode version that matches the iOS phone system. For example, if the iPhone system is iOS 16.2, you also need to install an Xcode version that supports iOS 16.2. If there is no iOS Platforms
that matches the mobile phone system in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
directory, then the App cannot be launched automatically. Please click the running dock icon on the mobile phone to start it manually.
Use the following command to view Xcode iOS Platforms data.
ls -lh /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
On MacOSX, if the App cannot be started automatically, please check the following reasons:
标准运行基座,是DCloud为方便开发者低门槛调试而提供的,此基座App使用的是DCloud的包名、证书和三方SDK配置。
在原生层不变的情况下,js等动态代码可以在运行基座上动态加载,实现热重载运行。(uni-app x的Android端,uts代码编译为kt后通过dex动态加载来实现热刷新)
HBuilderX3.7.1版本调整标准基座支持的系统版本
标准基座仅能更新热刷代码和资源文件,其他诸如修改包名、应用名称、证书、权限、原生模块变更、xml等资源变更、引入三方sdk等,需要完整的执行Android/iOS的打包流程,由Android studio或XCode编译打包生成apk或ipa安装包,才能生效。
但真的打包为正式包,又无法调试,不能热重载和显示控制台日志。所以HBuilder在运行打包时提供了一个特殊选项,“自定义运行基座”。
自定义运行基座可以所有配置生效(主要是manifest.json的配置),包括:
可以云打包自定义基座,也可以本地打包自定义基座。
使用云打包,开发者不必配置原生打包环境。
打包App的入口在HBuilder顶部发行菜单,或快捷键【Ctrl+u】
After packaging the custom runtime base, HBuilder will automatically store the generated apk and ipa packages in the project directory/unpackage/debug directory, and the file names are android_debug.apk
and iOS_debug.ipa
respectively.
Only one custom pedestal can be generated for a project, and multiple generation only keeps the last result.
生成自定义基座后,在设备选择窗口,选择自定义基座-本地基座,如下图所示:
注意:自定义运行基座必须在HBuilderX中真机运行使用,不可直接安装使用,启动时会弹出toast提示信息。正式发版时需要按正常打包方式重新打包。
HBuilderX 3.7.13起,MacOSX系统,App项目,支持运行自定义基座到iOS模拟器。参考文档
HBuilderX 4.71之前
使用离线SDK打包生成自定义运行基座(不支持cli方式,将src拖拽到编辑器中,并重新识别项目类型),生成后将apk和ipa包存放在项目目录/unpackage/debug目录下,文件名分别为android_debug.apk和iOS_debug.ipa。
可以在设备选择窗口,选择自定义基座-本地基座,如下图所示:
HBuilderX 4.71+(仅Android)
Android通过离线SDK打包生成的自定义基座后,如果基座已通过Android Studio的运行安装到手机中。 可以在设备选择窗口,选择自定义基座-已安装基座,并选择对应调试的包名。如下图所示:
如果配置关联项目后,还可以在HBuilderX中原生联调(仅uni-app x)
默认标准基座闪退 可以查看手机存储根目录 /Android/data/io.dcloud.HBuilder/logs/io.dcloud.HBuilder/crash/
崩溃日志文件
自定义基座闪退 可以查看手机存储根目录 /Android/data/packageName/logs/packageName/crash/
崩溃日志文件
packageName: apk包名
apk包名是“uni.UNIB89CXX”,目录则为:/Android/data/uni.UNIB89CXX/logs/uni.UNIB89CXX/crash/
注意不是所有崩溃都能捕获到并保存文件
uni-app x的闪退日志有多种查看方式。
不管是uni-app还是uni-app x,线上应用还可以通过uni统计查看崩溃日志。