macos: 14 items found.

macOS Xcode清理空间

用过Xcode的同学可能遇到过这种情况, 有个CoreSimulator目录 /Users/<name>/Library/Developer/CoreSimulator/Devices非常大, 像我的就已经达到二三十G,对于256G的小硬盘来说太占空间了。

这个原因可能是因为不断升级Xcode版本,有些老的Device已经不用了,但是仍占据空间。

可以使用如下命令快速清理已经不能用的Device:

xcrun simctl delete unavailable
More ~

macos 上查看端口占用

使用命令lsof即可。
lsof -i :3306

lsof -i :3306
COMMAND PID   USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
mysqld  773 hijack   32u  IPv4 0x5273dd7b96798a1      0t0  TCP localhost:mysql (LISTEN)

也可以指定tcp 如lsof -i tcp:3306

More ~

MacOS app renders blank screen with WKWebView

I'm not sure there are differences of WKWebView usage between iOS app and MacOS app. There I have an issue that a web view on the storyboard can not load a request. Typically there is always the white screen, implies nothing loads.

Finally, I found the solution here. In the Capabilities tab of the project target, it's App Sandbox, check the Network: Outgoing Connections (Client).

Screen Shot 2019-07-25 at 22.28.10.png

More ~

在mac命令行执行显示通知

需要用的工具:
osascript在macos上可以执行AppleScript, JavaScript等.
这里介绍AppleScript两个常用命令: display, say.

display

这个命令可以在mac上发送系统通知,macos 会在侧边栏显示这个通知消息。
AppleStript这样写 display notification "hello world!"

为了执行这条命令需要用到osascript, 并且需要-e参数,后面跟的单引号字符引用的命令
执行发送这条通知:
osascript -e 'display notification "hello world!"'

Screen Shot 2019-07-17 at 12.31.58.png

这条通知显示在屏幕右上角,3秒后消失。

More ~

shell tree in macos

Use find to list the current folder:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Add to ~/.bash_profile or ~/.zshrc
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
  

Or install the tree with brew
brew install tree

More ~