Skip to content

Tests fail in Xcode due to ResourceHelper using wrong path #130

Closed
@Diggory

Description

@Diggory

Hello,

I find that when running the tests in Xcode they crash (they don't crash when running the tests from the shell using swift test):

SwiftCSVTests/PerformanceTest.swift:16: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2023-08-24 07:52:43.102488+0100 xctest[3765:8434382] SwiftCSVTests/PerformanceTest.swift:16: Fatal error: Unexpectedly found nil while unwrapping an Optional value

This appears to be due to ResourceHelper.url() which tries to get test CSV files from the test bundle via a hard-coded path } else if let realBundle = Bundle(path: "\(bundle.bundlePath)/../../../../SwiftCSVTests") { . This fails because Xcode stores derived data in the user's library folder, not the project folder these days.

I have a branch which gets rid of ResourceHelper entirely and instead uses Bundle.module.url(forResource:, withExtension: ) however that requires bumping the swift-tools version in the package manifest to 5.5 (from 5.0 in main).

Would that be acceptable? I assume that this would restrict building the package to using swift version 5.5 or later. (5.5 was released in Sept 2021 and requires Xcode 13 on macOS which requires Big Sur.)

(At the time of writing, the latest version of Swift is 5.8.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions