jpsim / Yams

A Sweet and Swifty YAML parser.
https://jpsim.com/Yams
MIT License
1.12k stars 144 forks source link

Can't seem to build or import Yams (Xcode 13.2.1) #341

Closed stevelandeyasana closed 2 years ago

stevelandeyasana commented 2 years ago

I'm using SwiftPM to install 4.0.6. Here's my Package.swift file:

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "modelgen",
  platforms: [
    .macOS("11.6.0"),
  ],
  products: [
    .executable(name: "modelgen", targets: ["main"]),
  ],
  dependencies: [
    .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.0.0")),
    .package(url: "https://github.com/jpsim/Yams.git", .upToNextMajor(from: "4.0.6")),
  ],
  targets: [
    .executableTarget(
      name: "main",
      dependencies: [
        .product(name: "ArgumentParser", package: "swift-argument-parser"),
        .product(name: "Yams", package: "Yams"),
        .target(name: "ModelgenLib"),
        .target(name: "CoreDataModelDescription"),
      ]),
    .target(name: "ModelgenLib", dependencies: [
      .target(name: "CoreDataModelDescription"),
    ]),
    .target(name: "CoreDataModelDescription", exclude: ["LICENSE", "README.md"]),
    .testTarget(
      name: "ModelgenTests",
      dependencies: ["ModelgenLib"]),
  ])

If I do a clean build, I get an Xcode error about the Swift compiler failing.

Screen Shot 2022-01-20 at 1 30 14 PM

If I try swift run <myprogram> on the command line (after first removing the .build/ directory), I get errors:

Fetching https://github.com/jpsim/Yams.git from cache
Fetching https://github.com/apple/swift-argument-parser.git from cache
Fetched https://github.com/jpsim/Yams.git (0.63s)
Fetched https://github.com/apple/swift-argument-parser.git (0.74s)
Computing version for https://github.com/jpsim/Yams.git
Computed https://github.com/jpsim/Yams.git at 4.0.6 (0.04s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.0.2 (0.04s)
Computing version for https://github.com/jpsim/Yams.git
Computed https://github.com/jpsim/Yams.git at 4.0.6 (0.00s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.0.2 (0.00s)
Creating working copy for https://github.com/jpsim/Yams.git
Working copy of https://github.com/jpsim/Yams.git resolved at 4.0.6
Creating working copy for https://github.com/apple/swift-argument-parser.git
Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.0.2
/Users/stevelandey/dev/ios/scripts/modelgen/.build/x86_64-apple-macosx/debug/Yams.build/module.modulemap:2:12: error: header '/Users/stevelandey/dev/ios/scripts/modelgen/.build/x86_64-apple-macosx/debug/Yams.build/Yams-Swift.h' not found
    header "/Users/stevelandey/dev/ios/scripts/modelgen/.build/x86_64-apple-macosx/debug/Yams.build/Yams-Swift.h"
           ^
/Users/stevelandey/dev/ios/scripts/modelgen/Sources/ModelgenLib/generate.swift:9:8: error: could not build Objective-C module 'Yams'
import Yams
       ^

The last two errors are repeated about 20 times but I omitted the repetitions to keep this issue short.

stevelandeyasana commented 2 years ago

PEBKAC - I added the dependency to the wrong target.

jpsim commented 2 years ago

I started debugging your issue and came back to see you had closed it. Thanks for sharing!