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

Swift Package Resources Not Found Under Test

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Package Manager
    • Labels:
      None

      Description

      I'm encountering a fatal error when running tests on a framework which depends on a Swift Package that is trying to load its resource bundle using `Bundle.module`. Attached is a sample project that can reproduce the error by running the tests on the PhoneEntryKit target.

      Setup:

      • PhoneEntryKit framework depends on PhoneNumberKit Swift Package
      • PhoneEntryKitTest target uses PhoneNumberEntry app as its test host
      • PhoneEntryKit uses a type from PhoneNumberKit which attempts to load a resource from the resource bundle generated by Swift Package Manager.

       

      What happens:

      The built products when running the tests in Xcode yields the xctest bundle inside of the test host's Plugins directory, but the generated accessor for `Bundle.module` doesn't account for that situation, which leads to the fatal error (https://github.com/apple/swift-package-manager/blob/1f2eda34deec3c92b97d116f192fd734657c4613/Sources/Build/BuildPlan.swift#L639).

       

      I've tried this both in Xcode 12.4 as well as 12.5 beta 3.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jsorge Jared Sorge
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: