简体   繁体   中英

Use different framework for device and simulator

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?

您可以编写脚本阶段,以使用某些条件(可能是目标体系结构)替换框架文件。

Here is the solution. Assume the frameworks for iOS device and simulator are at folders $device resp. $simulator . The merged framework will go into $merged :

  • Copy everything from $simulator into $merged
  • Copy everything from $device into $merged (for sure this will overwrite same-named binaries we copied in the step before, but we just want to make sure we have everything else (module mappings etc.); the actual merging of same-named binaries happens in the next step)
  • For each binary (main and *.dylib) with name $name that exists both in $simulator and $device , do: lipo -create $device/name $simulator/$name -output $merged/$name

The above can easily be automated with a script.

I verified the approach with a set of frameworks we use with Flutter and it works. The easiest way is to add the $merged folder as a vendored framework into the podspec file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM