<commit_before>import Foundation

private class CurrentBundleFinder {}

// The custom bundle locator code is needed to work around a bug in Xcode
// where SwiftUI previews in an SPM module will crash if they try to use
// resources in another SPM module that are loaded using the synthesized
// Bundle.module accessor.
//
extension Bundle {
    static var phoneNumberKit: Bundle = {
        #if DEBUG && SWIFT_PACKAGE
        let bundleName = "PhoneNumberKit_PhoneNumberKit"
        let candidates = [
            /* Bundle should be present here when the package is linked into an App. */
            Bundle.main.resourceURL,
            /* Bundle should be present here when the package is linked into a framework. */
            Bundle(for: CurrentBundleFinder.self).resourceURL,
            /* For command-line tools. */
            Bundle.main.bundleURL,
            /* Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). */
            Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent()
        ]
        for candidate in candidates {
            let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
            if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
                return bundle
            }
        }
        #endif
        
        #if SWIFT_PACKAGE
        return Bundle.module
        #else
        return Bundle(for: CurrentBundleFinder.self)
        #endif
    }()
}
<commit_msg>Fix bundle search path (#531)<commit_after>import Foundation

private class CurrentBundleFinder {}

// The custom bundle locator code is needed to work around a bug in Xcode
// where SwiftUI previews in an SPM module will crash if they try to use
// resources in another SPM module that are loaded using the synthesized
// Bundle.module accessor.
//
extension Bundle {
    static var phoneNumberKit: Bundle = {
        #if DEBUG && SWIFT_PACKAGE
        let bundleName = "PhoneNumberKit_PhoneNumberKit"
        let candidates = [
            /* Bundle should be present here when the package is linked into an App. */
            Bundle.main.resourceURL,
            /* Bundle should be present here when the package is linked into a framework. */
            Bundle(for: CurrentBundleFinder.self).resourceURL,
            /* For command-line tools. */
            Bundle.main.bundleURL,
            /* Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). */
            Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(),
            /* Bundle should be present here when running previews from a framework which imports framework whick imports PhoneNumberKit package (this is the path to "…/Debug-iphonesimulator/"). */
            Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent()
        ]
        for candidate in candidates {
            let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
            if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
                return bundle
            }
        }
        #endif
        
        #if SWIFT_PACKAGE
        return Bundle.module
        #else
        return Bundle(for: CurrentBundleFinder.self)
        #endif
    }()
}

{'fraction_non_alphanumeric': 0.075713453698311, 'fraction_numerical': 0.0008736167734420501, 'mean_word_length': 2.3809055118110236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6596685', 'n_tokens_mistral': 863, 'n_tokens_neox': 834, 'n_words': 304}