Skip to content

Commit

Permalink
Fix Issue with Bundle path checking (closes snowplow#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
mylifeasdog committed Jan 18, 2024
1 parent cc13625 commit 8aa3f5b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Sources/Core/ScreenViewTracking/UIKitScreenViewTracking.swift
Expand Up @@ -69,9 +69,15 @@ extension UIViewController {
@objc func sp_viewDidAppear(_ animated: Bool) {
sp_viewDidAppear(animated)

let bundle = Bundle(for: self.classForCoder)
if !bundle.bundlePath.hasPrefix(Bundle.main.bundlePath) {
// Ignore view controllers that don't start with the main bundle path
let bundlePath = Bundle(for: self.classForCoder).bundlePath
let mainBundlePath = Bundle.main.bundlePath

// Resolve any symbolic links and standardize the file paths
let resolvedBundlePath = URL(fileURLWithPath: bundlePath).resolvingSymlinksInPath().path
let resolvedMainBundlePath = URL(fileURLWithPath: mainBundlePath).resolvingSymlinksInPath().path

// Ignore view controllers that don't start with the main bundle path
guard resolvedBundlePath.hasPrefix(resolvedMainBundlePath) else {
return
}

Expand Down

0 comments on commit 8aa3f5b

Please sign in to comment.