25

Is there any current information on wether or not method swizzling is legal/illegal on the App Store?

The only data point I can find is the Three20 framework shakeup a while back, which started with this notice:

Your application, xxx, currently posted to the App Store is using method_exchangeImplementations to exchange the implementation of Apple provided APIs with your own implementations. Because of upcoming changes, this behavior in your application may cause a crash or cause user data loss on iPhone OS 4.0.

xxx uses method_exchangeImplementations to exchange the implementation of dealloc with your method ttdealloc. It also exchanges the implementation of the method popViewControllerAnimated: with your method popViewControllerAnimated2:.

Please resolve this issue immediately and upload your new binary to iTunes Connect. We may remove your application if we believe that doing so is prudent or necessary.


When I'm searching around, every recent conversation I can find about swizzling and the app store seems to reference the same Three20 incident. The notice seems to be pretty specific, and I'm wondering if the issue was specific changes issues with the changes Three20 had made or if method_exchangeImplementations is universally banned.

Are there any other data points about whether or not the practice is allowed? Are there any devs with Apps in the store that are using swizzling?

Thanks!

ultramiraculous
  • 1,062
  • 14
  • 21
  • 1
    What exactly is it you really want to do? In most cases method swizzling is a hack that could be avoided with a better design. – JeremyP Jan 12 '12 at 12:13
  • 4
    I'm voting to close this question as off-topic because it's about Apple's rejection policies. See also: [Why we're not customer support for your favorite company](https://meta.stackoverflow.com/questions/255745/why-were-not-customer-support-for-your-favorite-company). – FelixSFD Apr 21 '17 at 07:24

2 Answers2

8

AFNetworking, a lib widely (IMO) used for network-requests, used swizzling up to at least version 1.3.4 to support additional acceptable status-codes and content-types in class-methods.

So it seems legit to do it.

Note: They used class_replaceMethod and not method_exchangeImplementations.

patric.schenke
  • 942
  • 11
  • 19
  • I did a workspace search for 'method_exchangeImplementations' in AFNetworking couldn't find any references of it. AFNetworking uses runtime library only for some view's categories and it uses objc_setAssociatedObject method for key value binding. I don't that is method swizzling. – Kunal Balani Jun 18 '14 at 14:04
  • AFNetworking underwent a major rehaul, maybe version 2.0 works without swizzling. However, until and including version 1.3.4 it used class_replaceMethod before in AFHTTPRequestOperation. – patric.schenke Jun 23 '14 at 08:32
  • please update your answer then. – Kunal Balani Jun 23 '14 at 14:26
1

Normally swizzling would be for debugging to see when a specific method is called, or in situation you can't subclass something or use a category for it. If you don't have a tight schedule on putting your Application on the app store, I guess you could try to send your application using method swizzling and see if it's accepted. No all application are reviewed the same way, sometimes it's just really up to the reviewer.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137