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

SPM: cannot use resources with .xcodeproj

    XMLWordPrintable

    Details

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

      macOS Catalina 10.15.7

      Xcode 12.1

      Description

      If a Swift package has a .xcodeproj file, it's not possible to use resources since the error Type 'Bundle' has no member “module” always comes up when building. It's possible to just not use a .xcodeproj file, but in some cases it's unavoidable.

      For example, if you create a Swift Package which relies on UIKit, it's not possible to use `swift test` to run CLI tests.

      # build works
      swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios14.0-simulator"
      # but test gives error "module 'XCTest' was created for incompatible target x86_64-apple-macos10.15"
      swift test -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios14.0-simulator"
      

      This can solved by generating a .xcodeproj:

      ```
      swift package generate-xcodeproj
      xcodebuild build -sdk iphoneos -scheme 'MyPackage-Package'
      xcodebuild test -destination 'name=iPhone 11' -scheme 'MyPackage-Package'
      ```
      

      However adding resources to the package then ends up with the error:

      Type 'Bundle' has no member 'module'
      Type of expression is ambiguous without more context

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            edbentley Ed Bentley
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: