Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9188

+[NSBundle bundleForClass:] swizzle crashes on nil argument

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Standard Library
    • Labels:
    • Environment:

      Xcode 10.1 (10B61)
      Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
      Target: x86_64-apple-darwin18.2.0

      Description

      The Swift stdlib is swizzling +[NSBundle bundleForClass:] in order to handle Swift classes properly. Unfortunately it crashes if the passed class is nil. The API itself is documented as taking a nonnull parameter, but the actual observed behavior at runtime of [NSBundle bundleForClass:nil] without Swift is to return the same thing as [NSBundle mainBundle].

      Unfortunately, this crash is a showstopper for us for using Xcode 10.1 because a closed-source dependency of ours is apparently calling [NSBundle bundleForClass:nil].

        Attachments

          Activity

            People

            Assignee:
            mikeash Mike Ash
            Reporter:
            lily Lily Ballard
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: