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}"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM