I am getting two builds of the same codebase delivered as two separate frameworks: one for iOS device and one for simulator
Is there a way to conditionally include one or the other depending on the target of my app?
您可以编写脚本阶段以某些条件替换框架文件(可能是目标架构)。
这是解决方案。假设 iOS 设备和模拟器的框架分别位于文件夹中$device
。$simulator
. 合并后的框架将进入$merged
:
$simulator
到$merged
$device
到$merged
(确保这将覆盖我们在上一步中复制的同名二进制文件,但我们只想确保我们拥有其他所有内容(模块映射等);同名二进制文件的实际合并发生在下一步)$name
同时存在于$simulator
和中的每个二进制文件(main 和 *.dylib) $device
,请执行以下操作:
lipo -create $device/name $simulator/$name -output $merged/$name
以上可以很容易地用脚本自动化。
我使用我们与 Flutter 一起使用的一组框架验证了该方法,并且它有效。最简单的方法是将$merged
文件夹作为供应商框架添加到 podspec 文件中