flutter NoMethodError - undefined method `size' for nil:NilClass错误排查

错误描述: pod install时发生错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
### Error

​```
NoMethodError - undefined method `size' for nil:NilClass
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:455:in `populate_mach_header'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:233:in `populate_fields'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:55:in `initialize_from_bin'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:33:in `new_from_bin'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:365:in `block in populate_machos'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `each'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `populate_machos'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:156:in `populate_fields'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:95:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `new'
/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/xcode/linkage_analyzer.rb:16:in `dynamic_binary?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sandbox/file_accessor.rb:171:in `block in vendored_dynamic_frameworks'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sandbox/file_accessor.rb:170:in `select'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sandbox/file_accessor.rb:170:in `vendored_dynamic_frameworks'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sandbox/file_accessor.rb:179:in `vendored_static_frameworks'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sandbox/file_accessor.rb:292:in `vendored_static_artifacts'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:82:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:82:in `flat_map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:82:in `block (2 levels) in verify_no_static_framework_transitive_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:74:in `each_key'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:74:in `block in verify_no_static_framework_transitive_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:73:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:73:in `verify_no_static_framework_transitive_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/xcode/target_validator.rb:38:in `validate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:595:in `validate_targets'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:162:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
​```

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=undefined+method+%60size%27+for+nil%3ANilClass&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
- NoMethodError - undefined method `size' for nil:NilClass
https://github.com/CocoaPods/CocoaPods/issues/10426 [closed] [3 comments]
a week ago

- NoMethodError - undefined method `size' for nil:NilClass
https://github.com/CocoaPods/CocoaPods/issues/10273 [closed] [3 comments]
7 weeks ago

- NoMethodError - undefined method `size' for nil:NilClass
https://github.com/CocoaPods/CocoaPods/issues/8377 [closed] [24 comments]
a week ago

and 8 more at:
https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60size%27%20for%20nil&type=Issues&utf8=✓

解决办法:在flutter目录运行以下命令

1
2
3
4
5
flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec

参考:https://github.com/CocoaPods/CocoaPods/issues/8377

framework not found

问题:在build的时候framework not found

解决:

  • 添加需要的framework
  • 确定framework齐全的情况下,就是系统添加了冗余的framework编译需求,找到require列表删除即可
1
project.xcodeproj文件--->显示包内容--->project.pbxproj文件 全局查找删除

ps:版本对不上处理方法同理,修改版本号和实际pods下载过来一致

hexo部署文章到github 443问题

问题:

1
2
3
4
5
6
7
8
9
fatal: unable to access 'https://github.com/xxx/xxx.github.io.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/Users/kevin/Desktop/xxx.github.io/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

解决:在_config.yml文件里把deploy的地址从http换成git

1
2
3
4
5
6
deploy:
type: git
#repo: https://github.com/xxx/xxx.github.io.git
repo: git@github.com:xxx/xxx.github.io.git
branch: master

h5优化策略总结

  • 原生webview加载耗时

    • 预热webview,并且缓存多个对象进行复用
  • webview网络请求页面内容,下载html

    • 在未点开网页时,用网络请求框架异步请求html内容,保存到本地缓存框架中
    • 在移动端启动local web server,同步服务器资源到本地,h5链接替换成localhost+port链接,例如swift版本的Telegraph
    • 本地网络框架请求zip资源并解压,供WKWebview的WKURLSchemeHandler拦截网络请求并调用(例如把http替换为自动以scheme)
  • 解析html

    • webview请求网络前先本地缓存查找已经下载好的html内容,直接进行加载渲染
  • 请求js、css资源

    • 本地网络框架选择性下载较大图片文件
  • 正常页面加载顺序为拿到html,计算布局,识别外链资源,绘制渲染

    • 后端直接加载好页面依赖的css,js和接口数据,拼接好一个最终版html返回给前端
  • 接口耗时长

    • 更新接口的处理方式
    • 增加占位图,优化体验
  • 内存泄露

    • 及时释放图片和数组等资源

参考链接:

融云iOS无法接受语音视频消息

安卓(李某测试)拨打 苹果(李朴2),进入对话界面,

弹出键盘,弹出报错,在chat_room.dart文件中

1
2
3
4
5
6
7
8
9
10
11
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 112 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112:12)
#3 _ChatRoomState.didChangeMetrics (package:polars_app/pages/chat/chat_room.dart:708:27)
#4 WidgetsBinding.handleMetricsChanged (package:flutter/src/widgets/binding.dart:571:16)
#5 _rootRun (dart:async/zone.dart:1190:13)
#6 _CustomZone.run (dart:async/zone.dart:1093:19)
#7 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#8 _invoke (dart:ui/hooks.dart:251:10)
#9 _updateWindowMetrics (dart:ui/hooks.dart:53:3)

解决:在访问maxScrollExtent属性前一定要判断_scrollController.hasClients

1
2
3
if (_scrollController.hasClients) {
_scrollController.position.maxScrollExtent;
}

问题描述:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//33003	调用接口时传入的参数不正确
[RC-Flutter-IM] iOS error sendMessage 33003

[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method '+' was called on null.
Receiver: null
Tried calling: +(":该消息内容为空,可能该消息没有在原生 SDK 中注册")
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 MessageFactory.map2Message (package:rongcloud_im_plugin/src/util/message_factory.dart:120:40)
#2 MessageFactory.string2Message (package:rongcloud_im_plugin/src/util/message_factory.dart:27:12)
#3 RongIMClient.sendMessageWithCallBack (package:rongcloud_im_plugin/src/rong_im_client.dart:187:43)
<asynchronous suspension>
#4 RongIMClient.sendMessageCarriesPush (package:rongcloud_im_plugin/src/rong_im_client.dart:116:12)
#5 RongIMClient.sendMessage (package:rongcloud_im_plugin/src/rong_im_client.dart:92:12)
#6 _ChatRoomState._sendMessage (package:polars_app/pages/chat/chat_room.dart:2765:32)
#7 _ChatRoomState._sendMessageClick (package:polars_app/pages/chat/chat_room.dart:2144:9)
#8 _ChatRoomState._buildTextComposer.<anonymous closure>.<anonymous closure> (package:polars_app/pages/chat/chat_room.dart:2097:29)
#9 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
#10 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
#11 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
#12 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
#13 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
#14 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
#15 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
#16 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:362:20)
#17 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
#18 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
#19 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
#20 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
#21 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
#22 _rootRunUnary (dart:async/zone.dart:1206:13)
#23 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#25 _invoke1 (dart:ui/hooks.dart:265:10)
#26 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)

分析:

1
2
3
4
5
6
//走到这串代码
msg = await RongIMClient.send
//launch和login调用登录代码
RyManager.instance.connect();
//方法内部调用 获取到的token为空
RongIMClient.connect(token)

无法连接融云,暂停;

继续调试

李朴2 userID:1174605640773193730

李某测试 userID:1107918162780569602

李某测试 (userID:1107918162780569602) android

打给

李朴2 (userID:1174605640773193730) iOS,锁屏超过一分钟

at 11:56

14:00 等待融云官方回复

app_helper——–>go web page ——->web view

jenkins安装

  • 安装

    1
    brew install jenkins-lts
  • 启动

    1
    brew services start jenkins-lts
  • 停止

    1
    brew services stop jenkins-lts
  • 重启

    1
    brew services restart jenkins-lts
  • 更新

    1
    brew upgrade jenkins-lts

局域网访问配置

homebrew.mxcl.jenkins.plist里面httpListenAddress127.0.0.1更改为0.0.0.0

两个地方

  • ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
  • /usr/local/Cellar/jenkins/版本号/homebrew.mxcl.jenkins.plist

参考:https://www.jianshu.com/p/10041e79ac6f