Is usage of “lipo” command recommended by Apple?

When we develop a dynamic framework and distribute it to reuse. We combine simulator (i386 and x86_64) and device(arm7, arm7s and arm64) architectures into one. So that developer can easily run an app on simulator and device without any error.


If we try to submit the universal framework, AppStore rejects it. In order to fix this error, we use lipo command to remove simulator architectures.


My question is Is usage of "lipo" command recommended by Apple?

Accepted Reply

The correct way to distribute your framework is to build a version for the device, and a separate version for simulators, and have the clients of your framework conditionally link to the correct framework depending if the app's build is for simulator or for device. Using lipo to combine the device architectures with the simulator architectures is not supported.

Replies

You are allowed to use lipo to combine different architectures into a single framework, but Apple forbids the combining of different platforms (macOS and iOS). It seems to work OK, and it's often done for frameworks distributed outside the app store, but Apple says it may stop working at any time in the future.


You'll have to find a workflow that builds and archives the iOS-only platform when you prepare the app for submission to the app store.

I am not thinking of combining different macOS and iOS platform.


I am only thinking of combining iOS simulator (i386 and x86_64) and device (armv7, armv7s and arm64) architectures, so that developer can integrate the precompiled dynamic framework and run an app on simulator and device. Before submitting an app to AppStore, remove the iOS simulator architectures because it is not needed.


Is there any indication by Apple that "lipo" will remove or will not work in future.

Yes, sorry, I wasn't clear. The iOS simulator *is* macOS platform. That's because it's running macOS underneath (obviously), and the simulator is a bridging layer that translates iOS APIs to (near enough) macOS equivalents. Whether that makes sense or not, the simulator uses a macOS-platform executable when you build your iOS app for debugging.


(Apple says it like this: It's a simulator, not an emulator.)


Anyway, the point is that your app will be rejected if it includes the simulator version of the framework, and there's not much you can do, except remove it (or archive without building it).

Thanks for clarifying it.


Whats your opinion rgarding removal of "lipo" command.


The following are the link which provides precompiled binaries

  1. Google: https://www.gstatic.com/cpdc/8f4d85570fdd4ab9-Google-3.0.3.tar.gz
  2. Realm Database: https://realm.io/docs/objc/latest/#prerequisites


Framework developers often use the lipo command to merge architectures.


When we integrate thrid party binaries using cocoapods, it has script which removes the unnecessary architectures when we build an app for AppStore release.


I would like to know what Apple says about this whole process. This process can fail if Apple removes lipo command or change the way completely.

I don't think Apple is going to remove lipo. It's necessary (AFAICT) for combining architectures

I also think Apple will not remove lipo because it is used by xcode itself during the build phase.

The correct way to distribute your framework is to build a version for the device, and a separate version for simulators, and have the clients of your framework conditionally link to the correct framework depending if the app's build is for simulator or for device. Using lipo to combine the device architectures with the simulator architectures is not supported.

If this is the way it must be done, then could we please see some sample code?


  1. A project that shows how to correctly configure it to build and distribute a device framework and a simulator framework
  2. Another project that shows how to correctly build an app for device and simulator that conditionally uses the correct framework.


Otherwise, everyone is going to keep doing this the way they see it done by either major SDKs, Cocoapods, Carthage, StackOverflow, or random blogs, and thus every new framework requires a different hack to strip it correctly.


Please show us how to do this correctly once and for all.

No sample code demonstrating this is available at this time. Please file an enhancement request through the Bug Reporter system.

  • So to recap...

    "Is using lipo to strip architectures from frameworks supported?" "No, you must produce device and sim frameworks during your build and have your consumers put conditional logic in their projects to use the right one during their builds" "Can we please see some sample code on how to do this right? Every major framework doesn't do it this way." "No, go kick rocks."

    Is there any sample code showing how to do this correctly, four years later?

  • So to recap...

    "Is using lipo to strip architectures from frameworks supported?" "No, you must produce separate device and simulator frameworks during your build and have your consumers put conditional logic in their projects to use the right one during their builds." "Can we please see some sample code on how to do this right? Every major framework doesn't do it this way." "No, go kick rocks."

    It's four years later - is there yet any sample code showing how to do this correctly?

Add a Comment