English
Due to the large differences in mobile phones, HBuilder does not provide an App simulator. Regardless of uni-app or 5+App/wap2app projects, you need to connect a real mobile phone or mobile phone emulator to run the test, which is called "real machine running".
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.
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模拟器
注意事项
上面的界面会额外显示搜索框,因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代码会打印到控制台上,点击打印日志可以跳转到相关代码。
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:
The standard operating base is provided by DCloud to facilitate the low-threshold debugging of developers. This base App uses DCloud's package name, certificate and third-party SDK configuration.
Under the condition that the native layer remains unchanged, dynamic codes such as js can be dynamically loaded on the running base to realize hot reload operation.
HBuilderX3.7.1版本调整标准基座支持的系统版本
If you want to customize the native layer, you need to go through the packaging process of iOS or Android, and compile and package by XCode or Android studio to generate an ipa or apk installation package.
However, after packaging, it cannot be easily debugged, and cannot be hot reloaded and console logs displayed. So HBuilder provides a special option when packaging, packaging a "custom run base".
The entry of the packaged App is in the release menu at the top of HBuilder, or the shortcut key [Ctrl+u]
自定义运行基座可以所有配置生效(主要是manifest.json的配置),包括:
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模拟器。参考文档
You can use the offline SDK package to generate a custom running base (the cli method is not supported, drag and drop the src into the editor, and re-identify the project type), and store the apk and ipa packages in the project directory/unpackage/debug directory after generation , and the file names are android_debug.apk and iOS_debug.ipa respectively.
默认标准基座闪退 可以查看手机存储根目录 /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/
注意不是所有崩溃都能捕获到并保存文件