serve-sim 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,22 @@ static BOOL SwizzleInstanceMethod(Class cls, SEL orig, SEL swiz) {
49
49
  NSStringFromSelector(swiz));
50
50
  return NO;
51
51
  }
52
- method_exchangeImplementations(o, s);
52
+ // `orig` may be inherited rather than implemented directly on `cls` (e.g.
53
+ // on iOS 26 UIImagePickerController no longer overrides viewDidAppear:).
54
+ // A plain method_exchangeImplementations would then mutate the *superclass*
55
+ // Method, clobbering that selector for every subclass — and our `swiz`
56
+ // selector only exists on `cls`, so unrelated controllers crash with
57
+ // "unrecognized selector simcam_…". Install the override directly on `cls`
58
+ // instead: add `orig` pointing at the swizzled IMP, and if that succeeds
59
+ // (no direct impl existed) repoint `swiz` at the inherited original so the
60
+ // [self simcam_…] call still reaches it.
61
+ IMP origIMP = method_getImplementation(o);
62
+ IMP swizIMP = method_getImplementation(s);
63
+ if (class_addMethod(cls, orig, swizIMP, method_getTypeEncoding(s))) {
64
+ class_replaceMethod(cls, swiz, origIMP, method_getTypeEncoding(o));
65
+ } else {
66
+ method_exchangeImplementations(o, s);
67
+ }
53
68
  return YES;
54
69
  }
55
70
 
package/bin/serve-sim-bin CHANGED
Binary file