Mac OS 的 open 命令 之 No application knows how to open ...

日常用法

平常使用最多的是

# 打开当前目录
open .

# 打开指定目录(以打开桌面为例)
open ~/Desktop

进阶用法

使用指定 app 打开

# 使用 finder 打开当前目录
open -a finder .

open -a 解决我的一个问题

昨天在打包一个 SDK 时,发现打包脚本报错如下:

重点在第一行里面的 No application knows how to open ... ,打开 SDK 的打包脚本发现打包完最后的工作是自动打开 framework 所在的目录,代码如下:

# Sets the target folders and the final framework product.
FMK_NAME=${PROJECT_NAME}
# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework
# -configuration ${CONFIGURATION}
# Clean and Building both architectures.
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator build
# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
#rm -r "${INSTALL_DIR}/Info.plist"
rm -r "${WRK_DIR}"
open "${INSTALL_DIR}"

因为前面的打包工作全部正常,只是最后一步打开framework的时候出错了,解决方案为,反最后一行改为:

open -a finder "${INSTALL_DIR}"
posted @ 2021-01-14 09:37  1lin24  阅读(1632)  评论(0编辑  收藏  举报