You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our team is looking into PostHog, my biggest issue is the swizzling of system functions in a third party SDK.
I understand PostHog wants to be the only analytics tool you need, but in reality you're not working in a vacuum. And the current SDK swizzles a lot; layoutSubviews, viewDidAppear, Application sendAction & sendEvent, scrollViews, urlSession, ...
I didn't find any settings to avoid swizzling, are there any plans to provide a 'light version'? Does anyone know how badly functionality would be impacted by disabling swizzling?
You’re right that our iOS SDK uses method swizzling in several places to enable some of the advanced features we provide like session replay, autocapture, surveys and screen view capture.
At the moment, we don't provide any global "disable swizzling" flag - but could be something worth considering. Having said that, swizzling is only executed when the relevant features mentioned above are enabled in the SDK config. If you want to avoid or reduce swizzling you can just disable those features
The above will remove almost all swizzling the SDK does with the exception of Session Manager which uses swizzling to detect idle time - could easily be refactored when the global flag is introduced, however.
+1 to being allowed to disable Swizzling completely. Even with all above options disabled, it does appear to introduce a non-negligible performance hit, particularly with SwiftUI. This shows it taking up roughly ~4% of CPU cycles on a simple navigation tap (on an iPhone 17 Pro, I imagine it's worse on older devices).
Hey guys @andrewtheis@cbg-dev-k. Just wanted to let you know that I'm actively working on adding a flag for disabling swizzling all together. As well as looking into the high cpu impact mentioned here
Reacted by cbgdev, Andrew Theis and Alexander Bearinger
Activity
ioannisj commentedon Jun 23, 2025
Hi there 👋 Thanks for raising this!
You’re right that our iOS SDK uses method swizzling in several places to enable some of the advanced features we provide like session replay, autocapture, surveys and screen view capture.
At the moment, we don't provide any global "disable swizzling" flag - but could be something worth considering. Having said that, swizzling is only executed when the relevant features mentioned above are enabled in the SDK config. If you want to avoid or reduce swizzling you can just disable those features
The above will remove almost all swizzling the SDK does with the exception of Session Manager which uses swizzling to detect idle time - could easily be refactored when the global flag is introduced, however.
andrewtheis commentedon Sep 24, 2025
@ioannisj
+1 to being allowed to disable Swizzling completely. Even with all above options disabled, it does appear to introduce a non-negligible performance hit, particularly with SwiftUI. This shows it taking up roughly ~4% of CPU cycles on a simple navigation tap (on an iPhone 17 Pro, I imagine it's worse on older devices).
With PostHog Enabled:

With PostHog Disabled:

ioannisj commentedon Sep 24, 2025
Hey @andrewtheis, this is with the latest SDK version correct?
andrewtheis commentedon Sep 24, 2025
@ioannisj yes, 3.31.0
ioannisj commentedon Oct 3, 2025
Hey guys @andrewtheis @cbg-dev-k. Just wanted to let you know that I'm actively working on adding a flag for disabling swizzling all together. As well as looking into the high cpu impact mentioned here