Fixon
Fixon
  • 发布:2024-04-16 16:18
  • 更新:2024-04-17 18:25
  • 阅读:61

【报Bug】cli 云打包后的 IOS APP 某些函数无法运行,捕捉的异常无法定位到是哪里有问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 14.4.1

手机系统: iOS

手机系统版本号: iOS 17

手机厂商: 苹果

手机机型: iphone13pro

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: CLI

CLI版本号: 2.0.2-4000820240401001

示例代码:

部分代码示例

 async createEvent(eventInfo) {  
            try {  
                const { dateInfo, scheduleId, editInfo } = this;  
                const { takeTime, eventName } = eventInfo || {};  
                uni.showLoading({  
                    title: `正在${scheduleId ? "更新" : "创建"}`,  
                    mask: true,  
                });  
                if (scheduleId) {  
                    await apiDeleteTemplateSchedule(scheduleId);  
                    await apiCreateTemplateSchedule({  
                        ...editInfo,  
                        content: eventName || "临时日程",  
                        timeZone: getDefaultTimeZone(),  
                        title: eventName || "临时日程",  
                        takeTime,  
                    });  
                } else {  
                    await apiCreateTemplateSchedule({  
                        content: eventName || "临时日程",  
                        end: dateToDateStr(dateInfo.endTime),  
                        start: dateToDateStr(dateInfo.startTime),  
                        timeZone: getDefaultTimeZone(),  
                        title: eventName || "临时日程",  
                        takeTime,  
                    });  
                }  
                await this.fetchSchedule();  
                uni.hideLoading();  
                this.$refs.ScheduleCalendar.cancelSelected();  
                uni.$emit("calendarSetData", {  
                    show: false,  
                });  
            } catch (e) {  
                const { dateInfo, scheduleId, editInfo } = this;  
                uni.showModal({  
                    title: "Error",  
                    content: JSON.stringify({  
                        e,  
                        dateInfo,  
                        scheduleId,  
                        editInfo,  
                    }),  
                    showCancel: false,  
                });  
            }

错误日志

[WX_KEY_EXCEPTION_WXBRIDGE] exception: TypeError: undefined is not an object (evaluating 'this.$vm.$destroy')  
@  
@  
callbackFromNative@  
@  
global code@  
------------uni-app runtime error------------  
stack:$remove@weex-main-jsfm.js:2:129087  
@weex-main-jsfm.js:2:123459  

[WX_KEY_EXCEPTION_WXBRIDGE] exception: TypeError: null is not an object (evaluating 'i.addEventListener')\n stack:addEventListenerToWebview@app-service.js:1:146692\n@app-service.js:1:146576\n@weex-main-jsfm.js:2:548258\n@weex-main-jsfm.js:2:1418\nmap@[native code]

操作步骤:

云打包后无法正常执行,开发环境自定义基座正常。

预期结果:

打包后能正常运行。

实际结果:

出现无法定位的异常

bug描述:

APP在开发环境自定义基座运行时,能够正常执行函数。打包发行版后会发生报错,但是uni统计收集到的异常日志没办法定位是哪里出了问题。
在生产环境代码里加入try catch抛出异常还是无法定位异常。
所有出问题的地方catch异常报错抛出后都是 “{}”。

2024-04-16 16:18 负责人:无 分享
已邀请:
Fixon

Fixon (作者)

H5、微信小程序、安卓端正常运行。
IOS报错。

  • Fixon (作者)

    IOS只有在生产环境打包的时候会报错,自定义基座运行正常。

    2024-04-17 15:28

Fixon

Fixon (作者)

因为该问题仅在IOS打包后出现,有没有办法提供打包后的IOSAPP调试。不然每次都需要使用云打包加上uni.showModal()去调试,成本有点高。

Fixon

Fixon (作者)

收集的错误日志没办法定位到代码是哪里异常

Fixon

Fixon (作者)

解决了,是条件编译的问题。
这两个条件编译只能在uts里面用
// #ifdef APP-IOS
// #ifdef APP-ANDROID
如果要判断不同端,推荐大家用

// #ifdef APP-PLUS  
const { platform } = uni.getSystemInfoSync();  
const isIOS = platform === "ios";  
const isAndroid = platform === "android";  
// #endif

要回复问题请先登录注册