0%

(前面省略 OCLint 编译以及其他问题,有需要可以看 https://oclint.org)

参考 https://docs.oclint.org/en/stable/guide/xcodebuild.html

前期材料

  1. 写好的 OCLint 规则

  1. Demo Project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
➜  TestStrCopy  xcodebuild -list
Command line invocation:
/Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -list

User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES

Information about project "TestStrCopy":
Targets:
TestStrCopy

Build Configurations:
Debug
Release

If no build configuration is specified and -scheme is not passed then "Release" is used.

Schemes:
TestStrCopy

用 Clang 写一个小 demo 编出抽象语法树,然后开始苟且。

1
clang -fmodules -fsyntax-only -Xclang -ast-dump ./OCLintTest.m

XCode 调试自定义规则时提示

1
2
oclint: error: cannot find dynamic library for report type: text
Program ended with exit code: 2

添加符号断点后打印 reporterPath。对于目录下确实没有文件

1
2
(lldb) po oclint::option::reporterPath()
"/Users/yulintao/Code/oclint/oclint-xcodederiver/bin/Debug/../lib/oclint/reporters"

解决方式:手动拷贝 build 目录下的 oclint-release/lib 目录到上述目录中

文长不看

  1. 分析内存虚拟内存和堆内存(All Heap Allocagtions)都需要关注, VM 也是有区别的,有些会导致 OOM
  2. VM: CG raster data 会导致崩溃
  3. 创建22小位图,Instruments 标记的是堆内存,100100 的位图,Instruments 标记的是 VM: CG raster data
  4. AutoLayout 用多了也要占用内存,CollectionCell 上最好都使用手动布局(不光内存更优,性能也更好)
  5. 屏幕中 Cell 数量越多,占用内存越多。
  6. Cell 越复杂,占用的内存越多
阅读全文 »

今天 Xcode 抽风(12.2 不会有问题,12.3,12.4 会有问题),一直卡死,排查思路如下,打开活动监视器对 Xcode 进行取样,发现DTDKMobileDeviceToken 字样。猜测是因为手机连接的问题,于是把手机拔了,发现 Xcode 不卡死了。

最终解决方案:重启手机