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

Binary targets non-deterministically fail to import in Xcode

    XMLWordPrintable

    Details

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

      macOS 11.2.3 (20D91), Xcode 12.5 (12E262), Swift 5.4, iOS SDK

      Description

      The following dependency graph causes non-deterministic build failures:

      Xcode app -> MyProduct (dynamic library in MyPackage) -> MyTarget (Swift target in MyPackage) -> CMyTarget (C target in MyPackage) -> Binary target

      In particular, CMyTarget occasionally fails to import the headers from the binary target. From my testing, this appears to be a race condition where the binary target's framework is not always extracted into the products directory before the C files using it are compiled.

      I've attached a sample project demonstrating the bug (simply an iOS app with the aforementioned dependency graph). The issue only occurs on clean builds, and that too not always; quitting and re-opening Xcode also helps reproduce the bug. Re-building seems to fix the problem (because the framework is already in the products dir?), but that's unfortunately impractical for CI/CD setups.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            kabiroberai Kabir Oberai
            Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: