一.查看本地安装的版本,在终端执行下面的命令
xcodebuild -showsdks
![](https://img.haomeiwen.com/i3450630/dd4f9070e2caa637.png)
二.开始转换
1.先切换路径到需要转换的OC文件
![](https://img.haomeiwen.com/i3450630/321cbf553f4e12ed.png)
2.执行需要的命令
(1).使用指定版本的sdk(如果安装的版本多)
xcrun -sdk iphonesimulator10.3 clang -rewrite-objc filename.m
(2).使用模拟器
xcrun -sdk iphonesimulator clang -rewrite-objc filename.m
(3).使用真机的sdk命令为
xcrun -sdk iphoneos clang -rewrite-objc filename.m
(4).如果代码包含weak,应该会报错添加版本号即可 '-fobjc-arc -fobjc-runtime=ios-13.2 '
xcrun -sdk iphonesimulator clang -rewrite-objc -fobjc-arc -fobjc-runtime=ios-13.2
TestCode.m
网友评论