Weex编译后,Xcode工程项目编译报错–[UIView frame] must be used from main thread only

声明:本文转载自狮兄

大致报错有以下两点。

1、Main Thread Checker: UI API called on a background thread: -[UIView frame]

PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit

2、Main Thread Checker: UI API called on a background thread: -[UIView subviews]

其中Weex库文件中,有两行报错。其中一行如下:

if (!(instance.rootView.subviews) || instance.rootView.subviews.count <=0) {

Xcode中,终端打印报错信息如下

Main Thread Checker: UI API called on a background thread: -[UIView frame]

PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21

Backtrace:

4  SinaZC                              0x0000000100717b54 +[WXBridgeContext checkEmptyScreen:] + 200

5  SinaZC                              0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920

6  JavaScriptCore                      0x000000018a96e178 + 28

7  JavaScriptCore                      0x000000018a96d90c + 156

8  SinaZC                              0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316

9  SinaZC                              0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240

10  SinaZC                              0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764

11  SinaZC                              0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144

12  SinaZC                              0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372

13  SinaZC                              0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180

14  Foundation                          0x00000001846fa0ec + 340

15  CoreFoundation                      0x0000000183c57404 + 24

16  CoreFoundation                      0x0000000183c56c2c + 276

17  CoreFoundation                      0x0000000183c5479c + 1204

18  CoreFoundation                      0x0000000183b74da8 CFRunLoopRunSpecific + 552

19  Foundation                          0x00000001845e9674 + 304

20  SinaZC                              0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344

21  Foundation                          0x00000001846f9efc + 1040

22  libsystem_pthread.dylib            0x00000001838d5220 + 272

23  libsystem_pthread.dylib            0x00000001838d5110 + 0

24  libsystem_pthread.dylib            0x00000001838d3b10 thread_start + 4

2018-11-13 10:27:06.709273+0800 SinaZC[998:202842] [reports] Main Thread Checker: UI API called on a background thread: -[UIView frame]

PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21

Backtrace:

4  SinaZC                              0x0000000100717b54 +[WXBridgeContext checkEmptyScreen:] + 200

5  SinaZC                              0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920

6  JavaScriptCore                      0x000000018a96e178 + 28

7  JavaScriptCore                      0x000000018a96d90c + 156

8  SinaZC                              0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316

9  SinaZC                              0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240

10  SinaZC                              0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764

11  SinaZC                              0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144

12  SinaZC                              0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372

13  SinaZC                              0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180

14  Foundation                          0x00000001846fa0ec + 340

15  CoreFoundation                      0x0000000183c57404 + 24

16  CoreFoundation                      0x0000000183c56c2c + 276

17  CoreFoundation                      0x0000000183c5479c + 1204

18  CoreFoundation                      0x0000000183b74da8 CFRunLoopRunSpecific + 552

19  Foundation                          0x00000001845e9674 + 304

20  SinaZC                              0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344

21  Foundation                          0x00000001846f9efc + 1040

22  libsystem_pthread.dylib            0x00000001838d5220 + 272

23  libsystem_pthread.dylib            0x00000001838d5110 + 0

24  libsystem_pthread.dylib            0x00000001838d3b10 thread_start + 4

=================================================================

Main Thread Checker: UI API called on a background thread: -[UIView subviews]

PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21

Backtrace:

4  SinaZC                              0x0000000100717bd8 +[WXBridgeContext checkEmptyScreen:] + 332

5  SinaZC                              0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920

6  JavaScriptCore                      0x000000018a96e178 + 28

7  JavaScriptCore                      0x000000018a96d90c + 156

8  SinaZC                              0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316

9  SinaZC                              0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240

10  SinaZC                              0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764

11  SinaZC                              0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144

12  SinaZC                              0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372

13  SinaZC                              0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180

14  Foundation                          0x00000001846fa0ec + 340

15  CoreFoundation                      0x0000000183c57404 + 24

16  CoreFoundation                      0x0000000183c56c2c + 276

17  CoreFoundation                      0x0000000183c5479c + 1204

18  CoreFoundation                      0x0000000183b74da8 CFRunLoopRunSpecific + 552

19  Foundation                          0x00000001845e9674 + 304

20  SinaZC                              0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344

21  Foundation                          0x00000001846f9efc + 1040

22  libsystem_pthread.dylib            0x00000001838d5220 + 272

23  libsystem_pthread.dylib            0x00000001838d5110 + 0

24  libsystem_pthread.dylib            0x00000001838d3b10 thread_start + 4

2018-11-13 10:27:07.068187+0800 SinaZC[998:202842] [reports] Main Thread Checker: UI API called on a background thread: -[UIView subviews]

PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21

Backtrace:

4  SinaZC                              0x0000000100717bd8 +[WXBridgeContext checkEmptyScreen:] + 332

5  SinaZC                              0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920

6  JavaScriptCore                      0x000000018a96e178 + 28

7  JavaScriptCore                      0x000000018a96d90c + 156

8  SinaZC                              0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316

9  SinaZC                              0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240

10  SinaZC                              0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764

11  SinaZC                              0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144

12  SinaZC                              0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372

13  SinaZC                              0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180

14  Foundation                          0x00000001846fa0ec + 340

15  CoreFoundation                      0x0000000183c57404 + 24

16  CoreFoundation                      0x0000000183c56c2c + 276

17  CoreFoundation                      0x0000000183c5479c + 1204

18  CoreFoundation                      0x0000000183b74da8 CFRunLoopRunSpecific + 552

19  Foundation                          0x00000001845e9674 + 304

20  SinaZC                              0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344

21  Foundation                          0x00000001846f9efc + 1040

22  libsystem_pthread.dylib            0x00000001838d5220 + 272

23  libsystem_pthread.dylib            0x00000001838d5110 + 0

24  libsystem_pthread.dylib            0x00000001838d3b10 thread_start + 4

2018-11-13 10:27:07.178241+0800 SinaZC[998:202842] <Weex>[error]WXMonitor.m:294, [WX_KEY_EXCEPTION_WXBRIDGE] [file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:895:25] ReferenceError: Can't find variable: process

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:895:25

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:12052:31

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:407:36

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9725:33

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9262:38

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9550:32

__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:68:37

global code@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:69:12

file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234

instanceId:0

options:{

    bundleType = Vue;

    bundleUrl = "file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js";

    debug = 1;

    env =    {

        appName = "\U65b0\U6d6a\U4f17\U6d4b";

        appVersion = "1.8.3";

        deviceHeight = 2436;

        deviceModel = "iPhone10,3";

        deviceWidth = 1125;

        logLevel = log;

        osName = iOS;

        osVersion = "11.4.1";

        platform = iOS;

        scale = 3;

        weexVersion = "0.19.0";

    };

}

data:(null)

(

    service,

    clearTimeout,

    setInterval,

    clearInterval,

    services,

    BroadcastChannel,

    weex,

    setTimeout,

    Vue,

    getJSFMVersion,

    "__WEEX_CALL_JAVASCRIPT__"

)

现象:

iOS项目在手机端运行,直接白屏。

问题查找:

步骤一:

在Weex项目中,执行weex run ios指令时候,终端中打印出如下信息:

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.2

Analyzing dependencies

Downloading dependencies

Using AMapFoundation (1.5.5)

Using AMapLocation (2.6.1)

Using SDWebImage (3.7.5)

Using SocketRocket (0.4.2)

Using WeexPluginLoader (0.0.1.9.1)

Installing WeexSDK 0.19.0 (was 0.18.0.3)

Generating Pods project

Integrating client project

Sending stats

Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.

? Choose one of the following devices (Use arrow keys)


步骤二:

检查Xcode中Podfile 文件。如下:

source 'git@github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

#inhibit_all_warnings!

def common

pod 'WeexSDK',

    pod 'WeexPluginLoader'

    pod 'SDWebImage', '3.7.5'

    pod 'SocketRocket', '0.4.2'

    pod 'AMapLocation' #定位SDK

end

target 'WeexDemo' do

    common

end

target 'WeexUITestDemo' do

    common

end

发现,WeexSDK,并没有指定版本,但是在Weex项目编译过程中,出现过Installing WeexSDK 0.19.0 (was 0.18.0.3),说明,这里直接将老的0.18.0.3版本升级到了0.19.0版本。

步骤三:

修改Xcode的Podfile文件,指定WeexSDK版本为0.18.0.3版本

修改后的Podfile文件如下:

source 'git@github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

#inhibit_all_warnings!

def common

pod 'WeexSDK', '0.18.0.3'

    pod 'WeexPluginLoader'

    pod 'SDWebImage', '3.7.5'

    pod 'SocketRocket', '0.4.2'

    pod 'AMapLocation' #定位SDK

end

target 'WeexDemo' do

    common

end

target 'WeexUITestDemo' do

    common

end

步骤四:

进入到Xcode项目根目录:

在终端中,输入指令pod install ,更新cocoapods相关库。

终端信息如下:

ShiXiongweideMacBook-Pro:ios shixiongwei$ pwd

/Users/shixiongwei/Documents/hctl/demo/blt4/blt-app-viewer/platforms/ios

ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:215: warning: Insecure world writable dir /Users/shixiongwei/ConfigDefine/SXWConfig/hadoop-3.1.1/bin in PATH, mode 040777

Analyzing dependencies

Downloading dependencies

Using AMapFoundation (1.5.5)

Using AMapLocation (2.6.1)

Using SDWebImage (3.7.5)

Using SocketRocket (0.4.2)

Using WeexPluginLoader (0.0.1.9.1)

Using WeexSDK (0.19.0)

Generating Pods project

Integrating client project

Sending stats

Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.

ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:215: warning: Insecure world writable dir /Users/shixiongwei/ConfigDefine/SXWConfig/hadoop-3.1.1/bin in PATH, mode 040777

Analyzing dependencies

Downloading dependencies

Using AMapFoundation (1.5.5)

Using AMapLocation (2.6.1)

Using SDWebImage (3.7.5)

Using SocketRocket (0.4.2)

Using WeexPluginLoader (0.0.1.9.1)

Installing WeexSDK 0.18.0.3 (was 0.19.0)

Generating Pods project

Integrating client project

Sending stats

Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.

步骤五:

Xcode项目运行。不报错了。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,014评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,796评论 3 386
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,484评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,830评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,946评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,114评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,182评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,927评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,369评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,678评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,832评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,533评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,166评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,885评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,128评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,659评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,738评论 2 351

推荐阅读更多精彩内容