- 获取手机剩余可用容量不准
原因:从iOS11.0开始,ytes->KB->MB->G的进制为1000.0,而不是1024.0
代码:
let fileUrl = URL(fileURLWithPath: NSTemporaryDirectory())
let results = try? fileUrl.resourceValues(forKeys: [URLResourceKey.volumeAvailableCapacityForImportantUsageKey])
if let availableSize = results?.volumeAvailableCapacityForImportantUsage {
// ytes->KB->MB->G
let _availableSize = Double(availableSize) / 1000.0 / 1000.0 / 1000.0
self.label.text = "已占用\(byte.fileSizeToString()),剩余\(String(format: "%.1f", _availableSize))G可用"
}
#!/bin/sh
set -e
PLIST_PATH="./项目名/System/BuildInfo.plist"
BUILD_TIME_KEY=":BuildTime"
BUILD_TIME_VALUE="$(date +%Y-%m-%d,%H:%M:%S)"
# 当前是否为Archive操作
if [[ "$TARGET_BUILD_DIR" == *"/Archive"* ]]; then
if [ -r "${PLIST_PATH}" ]; then
echo "修改--->${BUILD_TIME_VALUE}"
/usr/libexec/PlistBuddy -c "Set ${BUILD_TIME_KEY} ${BUILD_TIME_VALUE}" "${PLIST_PATH}"
else
echo "新增--->${BUILD_TIME_VALUE}"
/usr/libexec/PlistBuddy -c "Add ${BUILD_TIME_KEY} string ${BUILD_TIME_VALUE}" "${PLIST_PATH}"
fi
fi