Skip to content

Commit

Permalink
fix: typo Swizziling -> Swizzling (#2831)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Mar 24, 2023
1 parent 725565a commit 1bbcb9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* An empty ViewController to ensure the swizzling of the SentrySDK doesn't call the initialize
* method from a background thread. The initializer method is called before the runtime sends its
* first message to the class, which is also the case when swizzling a class. For more information
* checkout SentryUIViewControllerSwizziling.
* checkout SentryUIViewControllerSwizzling.
*/
@interface InitializerViewController : UIViewController

Expand Down
34 changes: 17 additions & 17 deletions Sources/Sentry/SentryUIViewControllerSwizzling.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)start
// twice. We could also use objc_getClassList to lookup sub classes of UIViewController, but
// the lookup can take around 60ms, which is not acceptable.
if (![self swizzleRootViewControllerFromUIApplication:app]) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root UIViewController "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Failed to find root UIViewController "
@"from UIApplicationDelegate. Trying to use "
@"UISceneWillConnectNotification notification.");

Expand All @@ -87,7 +87,7 @@ - (void)start
name:UISceneWillConnectNotification
object:nil];
} else {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: iOS version older then 13. There is "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: iOS version older then 13. There is "
@"no UISceneWillConnectNotification notification. Could not find "
@"a rootViewController");
}
Expand All @@ -102,7 +102,7 @@ - (void)start
[self swizzleUIViewControllersOfImage:processImage];
} else {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: Did not found image name from current process. "
@"UIViewControllerSwizzling: Did not found image name from current process. "
@"Skipping Swizzling of view controllers");
}
}
Expand All @@ -114,14 +114,14 @@ - (void)start
{
if (![UIApplication respondsToSelector:@selector(sharedApplication)]) {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: UIApplication doesn't respond to sharedApplication.");
@"UIViewControllerSwizzling: UIApplication doesn't respond to sharedApplication.");
return nil;
}

UIApplication *app = [UIApplication performSelector:@selector(sharedApplication)];

if (app == nil) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplication.sharedApplication is nil.");
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: UIApplication.sharedApplication is nil.");
return nil;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ - (void)swizzleUIViewControllersOfClassesInImageOf:(Class)class
const char *imageNameAsCharArray = [self.objcRuntimeWrapper class_getImageName:class];

if (imageNameAsCharArray == NULL) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Wasn't able to get image name of the class: "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Wasn't able to get image name of the class: "
@"%@. Skipping swizzling of classes in same image.",
class);
return;
Expand All @@ -163,7 +163,7 @@ - (void)swizzleUIViewControllersOfClassesInImageOf:(Class)class

if (imageName == nil || imageName.length == 0) {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: Wasn't able to get the app image name of the app "
@"UIViewControllerSwizzling: Wasn't able to get the app image name of the app "
@"delegate class: %@. Skipping swizzling of classes in same image.",
class);
return;
Expand All @@ -175,13 +175,13 @@ - (void)swizzleUIViewControllersOfClassesInImageOf:(Class)class
- (void)swizzleUIViewControllersOfImage:(NSString *)imageName
{
if ([imageName containsString:@"UIKitCore"]) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Skipping UIKitCore.");
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Skipping UIKitCore.");
return;
}

if ([self.imagesActedOnSubclassesOfUIViewControllers containsObject:imageName]) {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: Already swizzled UIViewControllers in image: %@.",
@"UIViewControllerSwizzling: Already swizzled UIViewControllers in image: %@.",
imageName);
return;
}
Expand Down Expand Up @@ -225,14 +225,14 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification *
// The object of a UISceneWillConnectNotification should be a NSWindowScene
if (![notification.object respondsToSelector:@selector(windows)]) {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: Failed to find root UIViewController from "
@"UIViewControllerSwizzling: Failed to find root UIViewController from "
@"UISceneWillConnectNotification. Notification object has no windows property");
return;
}

id windows = [notification.object performSelector:@selector(windows)];
if (![windows isKindOfClass:[NSArray class]]) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root UIViewController "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Failed to find root UIViewController "
@"from UISceneWillConnectNotification. Windows is not an array");
return;
}
Expand All @@ -244,7 +244,7 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification *
[self
swizzleRootViewControllerAndDescendant:((UIWindow *)window).rootViewController];
} else {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Failed to find root "
@"UIViewController from UISceneWillConnectNotification. Window is "
@"not a UIWindow class or the rootViewController is nil");
}
Expand All @@ -255,28 +255,28 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification *
- (BOOL)swizzleRootViewControllerFromUIApplication:(id<SentryUIApplication>)app
{
if (app.delegate == nil) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: App delegate is nil. Skipping "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: App delegate is nil. Skipping "
@"swizzleRootViewControllerFromAppDelegate.");
return NO;
}

// Check if delegate responds to window, which it doesn't have to.
if (![app.delegate respondsToSelector:@selector(window)]) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: UIApplicationDelegate.window is nil. "
@"Skipping swizzleRootViewControllerFromAppDelegate.");
return NO;
}

if (app.delegate.window == nil) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. "
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: UIApplicationDelegate.window is nil. "
@"Skipping swizzleRootViewControllerFromAppDelegate.");
return NO;
}

UIViewController *rootViewController = app.delegate.window.rootViewController;
if (rootViewController == nil) {
SENTRY_LOG_DEBUG(
@"UIViewControllerSwizziling: UIApplicationDelegate.window.rootViewController is nil. "
@"UIViewControllerSwizzling: UIApplicationDelegate.window.rootViewController is nil. "
@"Skipping swizzleRootViewControllerFromAppDelegate.");
return NO;
}
Expand All @@ -294,7 +294,7 @@ - (void)swizzleRootViewControllerAndDescendant:(UIViewController *)rootViewContr
for (UIViewController *viewController in allViewControllers) {
Class viewControllerClass = [viewController class];
if (viewControllerClass != nil) {
SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling Calling swizzleRootViewController.");
SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling Calling swizzleRootViewController.");
[self swizzleViewControllerSubClass:viewControllerClass];

// We can't get the image name with the app delegate class for some apps. Therefore, we
Expand Down

0 comments on commit 1bbcb9c

Please sign in to comment.