如何将资源文件编译成自定义框架或静态库或Mach-O文件?

How to compile resource files into a custom framework or static library or Mach-O file?

如何将资源文件编译成自定义框架或静态库(意思是编译成Mach-O文件)?感谢您的任何提示。

假设“资源文件”是指任意二进制文件,您可以通过创建汇编文件(例如 resources.S)将它们包含到任何二进制文件中,如下所示:

.section __RESOURCE,__file1
_symbol_file1:
.incbin "file1.zip"
.no_dead_strip _symbol_file1

.section __WHATEVER,__file2
_symbol_file2:
.incbin "file2.bin"
.no_dead_strip _symbol_file2

// etc, you get the pattern

如果您还没有可以在其中包含此文件的项目,那么您可以将其本身变成 iOS arm64 框架,如下所示:

mkdir MyResources.framework
xcrun -sdk iphoneos clang -arch arm64 -shared -o MyResources.framework/MyResources resources.S