Wiki:en.wikipedia.org/wiki/SIMBL
简称:SIMple Bundle Loader
- 原仓库:code.google.com/archive/p/s…
- 现仓库:github.com/msolo/simbl
- Chrome内置SIMBL:github.com/albertz/sim…
- EasySIMBL:github.com/norio-nomur…
- mySIMBL:github.com/w0lfschild/…
原理解析
- SIMBLAgent.app
- 配置SIMBLAgent.app为Launch Agent,登录启动
- 启动监听NSWorkspaceDidLaunchApplicationNotification
- 解析userInfo,获取APP的进程pid
- 通过Scripting Bridge向APP进程,发送SIMeload的AppleEvent
- SIMBL.osax
- 拦截SIMeload的AppleEvent
- 加载Plugin
Launch Agent简介
官方文档:Daemons and Services Programming Guide
其他:
- www.launchd.info/
- [macOS翻译]通过构建基于代理(菜单栏)的应用程序了解 macOS 应用程序的几个概念
- [macOS翻译]使用 Swift 在 macOS 应用程序上使用 XPC 服务
- [macOS翻译]使用 Swift 在 macOS 上创建可提供 XPC 服务的启动代理
AppleScript简介
Scripting Addition工程解析
-
SIMBL的xcodeproj
- productType = "com.apple.product-type.bundle"
- WRAPPER_EXTENSION = osax
- PBXShellScriptBuildPhase:
sdp -fa -o $(PRODUCT_NAME).r $(PRODUCT_NAME).sdef
- PBXRezBuildPhase:
$(PRODUCT_NAME).sdef
-
mySIMBL中包含编译好的SIMBL.osax
$ cd Frameworks/SIMBLManager.framework/Resources/SIMBL.osax
$ tree
.
└── Contents
├── Info.plist
├── MacOS
│ └── SIMBL
├── Resources
│ ├── SIMBL.rsrc
│ └── SIMBL.sdef
└── _CodeSignature
└── CodeResources
4 directories, 5 files
Resource fork简介
Wiki:en.wikipedia.org/wiki/Resour…
In macOS, forks are named file/..namedfork/forkname, e.g., the resource fork of the file IMG_0593.jpg is IMG_0593.jpg/..namedfork/rsrc. The ls command supports a -l@ option which lists a file's forks.
其他:
add_custom_command(TARGET ${myTargetApp} PRE_BUILD
DEPENDS ${MY_SOURCE_DIR}/MyResource.r
COMMAND ${rezCompiler}
# several .r are located across the build
-I ${MY_SOURCE_DIR}/resources/
-arch x86_64
# use the datafork
-useDF
# needs to specify for Carbon.r and CoreServices.r?
#-F Carbon
#-F CoreServices
# where to find framework files
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/
-o "${MY_SOURCE_DIR}/${myTargetApp}.rsrc"
${MY_SOURCE_DIR}/MyResource.r
)
While both versions of Xcode support .r files in the Copy Bundle Resources phase, invoking Rez to compile your inputs, Xcode 14 incorrectly outputs a .rsrc file whose name matches the input .r file (MyResources.r → MyResources.rsrc)
Makefile仿写
参考Xcode工程模板Cocoa Bundle的编译和资源打包
- 新建Cocoa Bundle项目
- 添加无main函数的objective-c源文件
- 用sdp和sdef生成的
.r
资源文件 - 添加该
.r
文件到Copy Bundle Resources
阶段(developer.apple.com/forums/thre… - 编译并查看编译步骤
可以仿写Makefile:github.com/Sunbreak/Qu…
installAddition: buildAddition
mkdir -p ${ADDITION_BUNDLE}/Contents/Resources
cp ${ADDITION_SRC}/addition.plist ${ADDITION_BUNDLE}/Contents/Info.plist
cp ${ADDITION_SRC}/addition.sdef ${ADDITION_BUNDLE}/Contents/Resources/${ADDITION_NAME}.sdef
sdp -fa -o ${BUILD_DIR}/addition.r ${ADDITION_SRC}/addition.sdef
Rez -o ${ADDITION_BUNDLE}/Contents/Resources/${ADDITION_NAME}.rsrc -useDF \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
${BUILD_DIR}/addition.r
Xcode工程模板
TODO