Xcode Error: CFBundleSupportedPlatforms or Mach-O LC_VERSION_MIN

本身 macOS/iOS App 可以携带编译的 executable 文件,比如带个静态编译的 ffmpeg 之类的。

但今天提交的时候突然提示我

Couldn't find platform family in Info.plist CFBundleSupportedPlatforms or Mach-O LC_VERSION_MIN for xxxx

找来找去,看到一个线索

好吧,用 otool -l xxxxxx

查看了编译出来的二进制文件,还真没有 LC_VERSION_MIN_MACOSX 这个值。

解决方案

man clang 后可以看到这样一段说明

MACOSX_DEPLOYMENT_TARGET
If  -mmacosx-version-min  is unspecified, the default deployment 
target is read from this environment variable. 
This option  only affects Darwin targets.

找到原因后,解决的方法很直接……在 bash 里加入这个环境变量就好了。

export MACOSX_DEPLOYMENT_TARGET=10.11

重新编译后使用 otool -l 查看

cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.9
  sdk 10.13

嗯,赞,just works