Mac App Store: Giving up 32 bit support in favor f

2019-03-30 08:03发布

问题:

I'm considering dropping 32-bit support for in favor for Automatic Reference Counting (which is only supported for 64 bit binaries).

I'd like to avoid these two scenarios with the Mac App Store:

For a user of an old 32-bit Mac:

  1. who did purchase the previous version with 32-bit support: Will they see an update message for the app in the Mac App Store? If so, the (now 64 bit only) update would not work for him/her.

  2. who has not purchased the app before: will they be able to purchase the app although it will not run on their system?

ARC 64 bit only: http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html#//apple_ref/doc/uid/TP40011226

EDIT: I found one occasion of somebody being able to download a 64 bit only app to a 32 bit MacBook and being presented with an error message "Your purchase could not be completed". In this case it was a free app. I wonder when this message would pop up for a paid app (before or after the payment).

http://www.linethirteen.com/blog/2011/01/mac-app-store-32-bit-vs-64-bit/

回答1:

I've also found out that ARC requires 64bit processors. However, I managed to build a fat binary where the 64bit version uses ARC and the 32bit version uses the garbage collector. To do this I had to do the following:

  • set up a 32bit only target that uses GC
  • set up a 64bit only target that uses ARC
  • add the 32bit target as a dependency to the 64bit target
  • add a custom build phase with a shell script that uses lipo to assemble a fat binary from the binaries in the two targets

Both targets use the same source, but a few #ifdef __OBJC_GC__ statements were necessary. I did have to give up synthesized ivars for backward compatibility :(



回答2:

I don't know what App Store will do (and it's probably subject to change, anyway), but if the app does get delivered to 32-bit customers, you can work around the problem in this way:

  1. Make your app 64-bit only.
  2. Make a second app that is 32-bit only and does nothing but show an alert message.
  3. Build all of the resources from the second app into the first (i.e., add them to both targets).
  4. Make the second target a dependency of the first, and use lipo in a shell script phase in the first target to assimilate the 32-bit binary into the 64-bit binary.

You'll then have a Universal Binary (or “fat binary”) that is your real application on 64-bit machines, and the “please upgrade your Mac” application on 32-bit machines.