编辑快捷键
-
⌘ + L跳转代码具体行数 -
ctrl + shift + 单击多选,选中某一行开始编辑 -
option + 上下拖动多行编辑 -
⌘ + ctrl + e单个代码文件内,修改同一个单词 -
⌘ + shift + o全局快速打开某个代码文件 -
⌘ + option + f替换 -
⌘ + f查找 -
⌘ + shift + L代码区是代码块 IB区是控件
粗略统计代码行数脚本
find . "(" -name "*.h" -or -name "*.mm" -or -name "*.m" -or -name "*.swift" ")" -print | xargs wc -l
主题和样式
主题文件的存放路径 ~/Library/Developer/Xcode/UserData/FontAndColorThemes/
主题集合可参考 https://github.com/hdoria/xcode-themes
代码块: ~/Library/Developer/Xcode/UserData/CodeSnippets
参考 https://github.com/tripleCC/TPCXcodeCodeSnippetsji 脚本同步代码块
经常遇到手机系统版本高于Xcode SDK版本,导致无法调试,需要下载调试包兼容.
Xcode真机调试包的路径:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
可在 github 搜关键词 DeviceSupport
json与plist文件格式互转(自动操作)
fileSubffix=${1##*.} #后缀名if [[ "${fileSubffix}"x == "json"x ]] ;thenplutil -convert xml1 "${1}" -o "${1%.*}".plistfiif [[ "${fileSubffix}"x == "plist"x ]] ;thenplutil -convert json "${1}" -o "${1%.*}".jsonfi
上传IPA到蒲公英(自动操作)
if [[ -n "${1}" ]]; thenipaName=${1##*/}cd $(dirname $1)api_key='replace apikey'result=$(curl -F 'file=@'$ipaName -F '_api_key='$api_key https://www.pgyer.com/apiv2/app/upload)ShortcutUrl_01=${result#*buildShortcutUrl\":\"}ShortcutUrl=${ShortcutUrl_01%%\"*}ipa_url=https://www.pgyer.com/"$ShortcutUrl"echo "$ipa_url" | pbcopyosascript -e "display notification \"测试包ipa上传成功🚀🚀🚀: "${ipa_url}" \" with title \"通知\" subtitle \"链接🔗已拷贝至剪贴板\" sound name \"Funk\""elseecho "调用 sh pgyer_upload_ipa.sh [ipa path] 需要传入ipa完整路径参数"fi
cocoapods 执行pod install(自动操作)
只需找到podfile文件右键菜单执行该workflow即可
PodfilePath="${1%/*}"osascript <<EOFtell application "iTerm"tell current windowcreate tab with default profiletell current sessionwrite text "cd ${PodfilePath}"write text "clear;"write text "pod install"end tellend tellend tellEOF
Xcode打白包即.app => .ipa (自动操作)
AppName_all=${1##*/}AppName=${AppName_all%.*}cd ~/Desktopresult_dir="white_pack_ipa"mkdir $result_dircd $result_dirmkdir -p Payloadcp -Rf $1 ./Payload/zip -qryX ./$AppName.ipa ./Payloadrm -rf Payload
静态库相关(自动操作)
查看静态库信息
.a文件直接读取,framework文件则需要读取编译的mach-O产物
lipo_info=`lipo -info $1`osascript -e "display dialog \"${lipo_info}\" with title \"查看静态库信息\" buttons {\"OK\"} default button 1 with icon file \"Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns\""
合并静态库mach-O产物
lib_path=~/Desktop/libmixif [[ "${1##*.}" == "a" ]]; thenlib_path=~/Desktop/libmix.${1##*.}filipo -create ${*} -output ${lib_path}osascript -e "display dialog \"静态库合并成功!\n路径为:${lib_path}\" with title \"合并静态库\" buttons {\"OK\"} default button 1 with icon file \"Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns\""
移除指定架构
一次只能移除一种架构
select_arch=$(osascript <<EOFchoose from list {"i386", "x86_64", "armv7", "arm64", "arm64e"} with title "移除指定架构的静态库" with prompt "选择一架构" OK button name "提取" cancel button name "取消" default items {"arm64"}EOF)if [[ "${select_arch}" != "false" ]]; thenlib_path=~/Desktop/libno${select_arch}elseexitfiif [[ "${1##*.}" == "a" ]]; thenlib_file_path=$lib_path${1##*.}elselib_file_path=${lib_path}filipo ${1} -remove ${select_arch} -output ${lib_file_path}osascript -e "display dialog \"移除${select_arch}架构成功\" with title \"移除静态库指定架构\" buttons {\"OK\"} default button 1 with icon file \"Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns\""
提取指定的一种架构
select_arch=$(osascript <<EOFchoose from list {"i386", "x86_64", "armv7", "arm64", "arm64e"} with title "提取指定架构的静态库" with prompt "选择一架构" OK button name "提取" cancel button name "取消" default items {"arm64"}EOF)if [[ "${select_arch}" != "false" ]]; thenlib_path=~/Desktop/lib$select_archelseexitfiif [[ "${1##*.}" == "a" ]]; thenlib_file_path=$lib_path${1##*.}elselib_file_path=$lib_pathfilipo ${1} -thin ${select_arch} -output ${lib_file_path}osascript -e "display dialog \"${select_arch}静态库提取成功!\n路径为:${lib_path}\" with title \"提取指定架构的静态库\" buttons {\"OK\"} default button 1 with icon file \"Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns\""
编译SDK的脚本
Xcode需要创建 Aggregate 的Target,并在Build Phases新建一个RunScript里面执行脚本
编译.framework
<<EOF#注释说明: 保存本文件名为xcode_build_framework.sh,放到工程根目录即可# Aggregate里新建RunScript 调用如下:#一键产出通用包 传参指定架构打包sh xcode_build_framework.sh "armv7,armv7s,arm64,arm64e,x86_64,i386"#sh xcode_build_framework.sh # 不传参则弹出GUI选择菜单EOFset -e#SDK的名字SDK_NAME=${PROJECT_NAME}#SDK产出目录INSTALL_DIR=${SRCROOT}/Products/${SDK_NAME}.framework#清空编译缓存rm -rf ${BUILD_DIR}if [ "x$1" = "x" ] ; #无入参则弹窗去选择then#弹出选择架构菜单select_arch=$(osascript <<EOFchoose from list {"i386","x86_64","armv7","armv7s","arm64","arm64e"} with title "指定架构编译SDK" with prompt "选择架构" OK button name "编译" cancel button name "取消" default items {"armv7","arm64"} with multiple selections allowedEOF)else#输入指定架构 "arm64,armv7,..." 用逗号隔开即可select_arch=${1}fi# 默认已选择armv7和arm64 点取消才会走这里if [[ $select_arch = false ]] ;thenecho "未选择架构,已取消本次编译."exit 0;fisimulator_archs=()if [[ $select_arch =~ "i386" ]] ;thensimulator_archs+=("i386")fiif [[ $select_arch =~ "x86_64" ]] ;thensimulator_archs+=("x86_64")fiecho "模拟器架构为: "${simulator_archs[*]}#模拟器架构个数,如果个数为0,则不需要模拟器参与编译了simulator_archs_length=${#simulator_archs[*]}if [[ $simulator_archs_length == 0 ]] ;thenecho "模拟器架构数为0,模拟器无需参与编译"else# 剔除模拟器架构select_arch=${select_arch//i386/ }select_arch=${select_arch//x86_64/ }fi# 获取真机的架构iphoneos_archs=(${select_arch//,/ })echo "真机架构为: "${iphoneos_archs[*]}if [[ $simulator_archs_length > 0 ]] ;then# 执行模拟器编译指令xcodebuild -configuration ${CONFIGURATION} -target "${SDK_NAME}" -sdk iphonesimulator build ARCHS="${simulator_archs[*]}"fi#执行真机编译指令xcodebuild -configuration ${CONFIGURATION} -target "${SDK_NAME}" -sdk iphoneos build ARCHS="${iphoneos_archs[*]}"#真机目录DEVICE_DIR="build"/${CONFIGURATION}-iphoneos/${SDK_NAME}.framework#模拟器目录SIMULATOR_DIR="build"/${CONFIGURATION}-iphonesimulator/${SDK_NAME}.framework#清除旧的输出目录if [ -d "${INSTALL_DIR}" ]thenrm -rf "${INSTALL_DIR}"fi#创建新的输出目录mkdir -p "${INSTALL_DIR}"#拷贝编译产物到输出目录cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"# 有模拟器编译才需要合并if [[ $simulator_archs_length > 0 ]] ;then#合并真机和模拟器的编译产物lipo -create "${DEVICE_DIR}/${SDK_NAME}" "${SIMULATOR_DIR}/${SDK_NAME}" -output "${INSTALL_DIR}/${SDK_NAME}"fi#打开输出目录查看结果open "${SRCROOT}/Products/"rm -rf "${SRCROOT}/build"#查看此次编译的架构支持lipo_info=`lipo -info ${INSTALL_DIR}/${SDK_NAME}`icon_path=`pwd`/Xcode.icnsicon_file=$(osascript -e "set thePath to POSIX file \"${icon_path}\" as string")echo $icon_fileosascript -e "display dialog \"SDK包含架构: ${lipo_info##*are:}\" with title \"当前SDK架构信息\" buttons {\"OK\"} default button 1 with icon file \"${icon_file}\""echo "脚本跑🏃完了"
<<EOF#注释说明: 保存本文件名为xcode_build_lib.sh,放到工程根目录即可# Aggregate里新建RunScript 调用如下:#一键产出通用包 传参指定架构打包sh xcode_build_lib.sh "armv7,armv7s,arm64,arm64e,x86_64,i386"#sh xcode_build_lib.sh # 不传参则弹出GUI选择菜单EOFset -e#SDK的名字SDK_NAME=${PROJECT_NAME}#SDK产出目录INSTALL_DIR=${SRCROOT}/Products/${SDK_NAME}#清空编译缓存rm -rf ${BUILD_DIR}if [ "x$1" = "x" ] ; #无入参则弹窗去选择then#弹出选择架构菜单select_arch=$(osascript <<EOFchoose from list {"i386","x86_64","armv7","armv7s","arm64","arm64e"} with title "指定架构编译SDK" with prompt "选择架构" OK button name "编译" cancel button name "取消" default items {"armv7","arm64"} with multiple selections allowedEOF)else#输入指定架构 "arm64,armv7,..." 用逗号隔开即可select_arch=${1}fi# 默认已选择armv7和arm64 点取消才会走这里if [[ $select_arch = false ]] ;thenecho "未选择架构,已取消本次编译."exit 0;fisimulator_archs=()if [[ $select_arch =~ "i386" ]] ;thensimulator_archs+=("i386")fiif [[ $select_arch =~ "x86_64" ]] ;thensimulator_archs+=("x86_64")fiecho "模拟器架构为: "${simulator_archs[*]}#模拟器架构个数,如果个数为0,则不需要模拟器参与编译了simulator_archs_length=${#simulator_archs[*]}if [[ $simulator_archs_length == 0 ]] ;thenecho "模拟器架构数为0,模拟器无需参与编译"else# 剔除模拟器架构select_arch=${select_arch//i386/ }select_arch=${select_arch//x86_64/ }fi# 获取真机的架构iphoneos_archs=(${select_arch//,/ })echo "真机架构为: "${iphoneos_archs[*]}if [[ $simulator_archs_length > 0 ]] ;then# 执行模拟器编译指令xcodebuild -configuration ${CONFIGURATION} -target "${SDK_NAME}" -sdk iphonesimulator build ARCHS="${simulator_archs[*]}"fi#执行真机编译指令xcodebuild -configuration ${CONFIGURATION} -target "${SDK_NAME}" -sdk iphoneos build ARCHS="${iphoneos_archs[*]}"#真机目录DEVICE_DIR="build"/${CONFIGURATION}-iphoneos#模拟器目录SIMULATOR_DIR="build"/${CONFIGURATION}-iphonesimulator#清除旧的安装目录if [ -d "${INSTALL_DIR}" ]thenrm -rf "${INSTALL_DIR}"fi#创建新的安装目录mkdir -p "${INSTALL_DIR}"#拷贝编译产物到安装目录cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"rm -rf "${INSTALL_DIR}/usr"# 有模拟器编译才需要合并if [[ $simulator_archs_length > 0 ]] ;then#合并真机和模拟器的编译产物lipo -create "${DEVICE_DIR}/lib${SDK_NAME}.a" "${SIMULATOR_DIR}/lib${SDK_NAME}.a" -output "${INSTALL_DIR}/lib${SDK_NAME}.a"fi#打开安装目录查看结果open "${SRCROOT}/Products/"#删除编译冗余数据rm -rf "${SRCROOT}/build"#查看此次编译的架构支持lipo_info=`lipo -info ${INSTALL_DIR}/lib${SDK_NAME}.a`icon_path=`pwd`/Xcode.icnsicon_file=$(osascript -e "set thePath to POSIX file \"${icon_path}\" as string")echo $icon_fileosascript -e "display dialog \"SDK包含架构: ${lipo_info##*are:}\" with title \"当前SDK架构信息\" buttons {\"OK\"} default button 1 with icon file \"${icon_file}\""echo "脚本跑🏃完了"
- 上一篇:Office2022全家桶永久激活 终身授权
- 下一篇: 分享JSX行内样式与CSS互转工具
- 2025所有iPhone17机型都将配备12GB内存
- iPhone17灵动岛变得更小?苹果重新设计了硬件
- 全面解析以太坊 区块链实例以太坊原理探讨
- 开源社区程序discourse安装部署(Debian12 )
- 海棠线上文学城网址 海棠文学登录入口
- Microsoft Office 2024专业版最新版安装包下载+安装教程 永久免费
- Office2021破解版软件安装激活教程+安装包下载8合1
- 蚂蚁庄园今日答案 每日最新题目解析与答案汇总
- 吸管能吸饮料主要依赖于?蚂蚁庄园答案
- 火狐浏览器如何备份旧数据在国际版恢复数据
- 区块链自媒体有哪些?一文了解区块链数据自媒体排行榜
- 京东方生产的BOE屏iPhone17Pro系列机型只供应中国市场

幸存者危城
朕的江山
无尽洪荒
明珠三国
远征手游
蜀山传奇
梦想城镇
逍遥情缘
猎魔勇士
功夫之夜
地心守护
风暴迷城
坍塌世界
萌学园战纪
疯狂动物园
模拟城市:我是市长
军棋
少年名将





