Error Importing SPM Module in Xcode While swift build and xcodebuild Works

Originator:liamrosenfeld
Number:rdar://49890606 Date Originated:April 14 2019
Status:Open Resolved:
Product:Xcode Product Version:10.2
Classification:Developer Tools Reproducible:Always
 
Summary:
When using Xcode, an error is given when importing a second target in the project even though swift build and xcodebuild still work.

Steps to Reproduce:
1) Create an SPM Project with this Manifest (or open attached project):
```
// swift-tools-version:5.0
import PackageDescription
let package = Package(
    name: "AnimalFarm",
    dependencies: [
        .package(url: "https://github.com/Azoy/Sword", .branch("master")),
        .package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
    ],
    targets: [
        .target(
            name: "AnimalFarm"
        ),
        .target(
            name: "AnimalFarmDiscord",
            dependencies: [
                .target(name: "AnimalFarm"),
                "Sword",
                "Logging"
            ]
        )
    ]
)
```
2) swift package update
3) swift package generate-xcodeproj
4) Try importing AnimalFarm in AnimalFarmDiscord
5) Xcode fails to find module
6) build in the command line and it works

Expected Results:
Xcode to import the module as it does in the command line.

Actual Results:
`Error: No such module 'AnimalFarm'` at every import statement

Version/Build:
10.2 (10E125)

Configuration:
Project autogenerated, so none.

Workaround:
Avoid Xcode and build only in the command line

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!