Skip to content

Instantly share code, notes, and snippets.

@666tos
Created October 4, 2018 14:12
Show Gist options
  • Save 666tos/5d9e3b6c7ac98d8615abca8d8c815413 to your computer and use it in GitHub Desktop.
Save 666tos/5d9e3b6c7ac98d8615abca8d8c815413 to your computer and use it in GitHub Desktop.
Enable 3D maps on AppleTV 4K
//
// MapHacks.m
// Tacx-iOS
//
// Created by M Ivaniushchenko on 6/7/18.
// Copyright © 2018 Splendo. All rights reserved.
//
#import "MapHacks.h"
#import <objc/message.h>
#import <CoreLocation/CoreLocation.h>
bool (*gOriginalMKSystemControllerSupports3DImagery)(id, SEL);
bool (*gOriginalMKSystemControllerSupports3DMaps)(id, SEL);
bool _replace_MKSystemController_supports3DImagery(id self, SEL _cmd) {
return true;
}
bool _replace_MKSystemController_supports3DMaps(id self, SEL _cmd) {
return true;
}
@implementation MapHacks
+ (void)load {
[self replaceMKSystemController1];
[self replaceMKSystemController2];
}
+ (void)replaceMKSystemController1 {
SEL originalSelector = @selector(supports3DImagery);
SEL replacementSelector = @selector(_replace_supports3DImagery);
Class class = NSClassFromString(@"MKSystemController");
Method originalMethod = class_getInstanceMethod(class, originalSelector);
IMP originalMethodImpl = method_getImplementation(originalMethod);
gOriginalMKSystemControllerSupports3DImagery = (void *)originalMethodImpl;
const char *typeEncoding = method_getTypeEncoding(originalMethod);
if (!class_addMethod(class, originalSelector, (IMP)_replace_MKSystemController_supports3DImagery, typeEncoding)) {
method_setImplementation(originalMethod, (IMP)_replace_MKSystemController_supports3DImagery);
}
}
+ (void)replaceMKSystemController2 {
SEL originalSelector = @selector(supports3DMaps);
SEL replacementSelector = @selector(_replace_supports3DMaps);
Class class = NSClassFromString(@"MKSystemController");
Method originalMethod = class_getInstanceMethod(class, originalSelector);
IMP originalMethodImpl = method_getImplementation(originalMethod);
gOriginalMKSystemControllerSupports3DMaps = (void *)originalMethodImpl;
const char *typeEncoding = method_getTypeEncoding(originalMethod);
if (!class_addMethod(class, originalSelector, (IMP)_replace_MKSystemController_supports3DMaps, typeEncoding)) {
method_setImplementation(originalMethod, (IMP)_replace_MKSystemController_supports3DMaps);
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment