Mac tips

2.1

Check Binary is universal

universal means to support both x86_64 (Intel) and arm64 (Apple silicon)

lipo -archs /System/Applications/Mail.app/Contents/MacOS/Mail

x86_64 arm64

Open Finder from Terminal

open .
open /path/to/folder

"lib..." Cannot be verified

Allow application to run anyway:

System Preferences -> Security & Privacy -> Allow Anyway

Svg to png

qlmanage -t -s 26 . linux.svg

# output: linux.svg.png, 
# width: 26

Find IP address

# Wi-Fi
ipconfig getifaddr en0

# Wired
ipconfig getifaddr en1

设置开机启动项

Preference / Users & Groups / Login Items

unzip: illegal byte sequences

压缩包内有中文字符时,使用unzip会报错

unzip archive.zip

可以用ditto

ditto -xk archive.zip archive

Xcode: provisioning profile doesn't include signing certificate

  • Build Settings > Signing

    • Provisioning Profile > Debug/Release > Select profiles

    • Code Signing Identity > Debug/Release > Select Identities

  • General > Signing(Debug/Release) > Select Provisioning Profile

ios - Xcode 8 shows error that provisioning profile doesn't include signing certificate - Stack Overflow

临时避免休眠

caffeinate

Sketch print plugin

BohemianCoding/print-export-sketchplugin: Exports a PDF for printing

Screencast to animated GIF

Requires

  • QuickTime > File > New Screen Recording

  • QuickTime > Edit > Trim

    Record sceen and generate .mov file

  • FFmpeg: Convert .mov to .gif

  • gifsicle: Optimize .gif

    ffmpeg -i out.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - > out.gif
    
    ffmpeg -i out.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif
    

安装自动构建工具

brew install autoconf automake libtool

卸载 xcode 后 git 报错

xcode-select --install

或者手动下载安装包 https://developer.apple.com/download/more/

快速切换窗口大小(半屏)

spectacle

Mac 和 Windows 相互连接、共享文件

参考

Mac 共享文件到 Windows

  • Mac > System Preferences > Sharing

    • 勾选 File Sharing
    • 点击 Option,勾选 SMB,并激活相关账号,点击完成
    • 记下 Mac 局域网地址,如192.168.200.1
  • Windows

    • 按下Ctrl + R,输入地址 \\192.168.200.1\
    • 输入 Mac 用户名和密码(安全考虑,可以单独建立共享账号)
    • 网络即中可找到 Mac 共享的文件夹

Windows 共享文件到 Mac

  • Windows

    • 网络共享中心 > 高级共享设置 > 启用网络发现
    • 特定文件、文件夹,右键 > 共享 > 进行设置
  • Mac

    • Finder > Command+K,打开 Connect to Server
    • 点击 Browse,找到可用的共享网络
    • 或者,Server Address,直接输入共享网络地址,例如:smb://192.168.1.10

终端

iTerm2

📖