CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
793 stars 104 forks source link

Need Assistance Using XMLCoder! #274

Closed Treata11 closed 10 months ago

Treata11 commented 10 months ago

A package based on XMLCoder

MusicXML written by Jame Bean, Ben Wetherfield & Sihao Lu is heavily base on XMLCoder & has been dormant for a couple of years now! None of the maintainers respond unfortunately ...

What is the problem?

The package does not function & fails Tests & probably was left incomplete. It is based on MusicXML 3.0 release & it misses some elements & data types (4.0 version was added after the project went dormant) which I'm currently adding them in a fork that I've created & renamed the package to SwiftMXL.

Though things are missing & some must be reimplemented, I believe that's not the only reason that the package is failing. I think that XMLCoder is not properly used as its dependency & that might be contributing to the thrown errors.

Assistance required

Since the maintainers of MusicXML have also contributed to XMLCoder & both packages share similarities, I'd appreciate if anyone could take a look at the crash logs & trace the errs back to its origin. Possibly some of you might even be able to find the problem in a glance.

fjagerman commented 10 months ago

Hi Treata,

As a happy XMLCoder user I took some time to reproduce your issue. I could build the package in Xcode 15 and produce 17 errors. Most of them have to do with missing resources. Nowadays a testtarget is supposed to copy it's resources like this:

    .testTarget(
        name: "SwiftMXLTests",
        dependencies: ["SwiftMXL", "Yams"],
        resources: [
            .copy("Complex Types"),
            .copy("LilyPondTests"),
            .copy("ScoreTests"),
        ]),

This requires version 5.3 (or higher) specified on top:

// swift-tools-version:5.3

After this some issues with "font family" remained

I hope this is any help to you. :-)

Treata11 commented 10 months ago

@fjagerman I appreciate that you took time & investigated the package. Lemme be frank here :) I don't even know how you faced 17 issues (in XCode 15). You should've faced 6 errors all of which are originated from the implementation of XMLChoiceDecodingContainer in XMLCoder.

Treata11 commented 10 months ago

I've understood what is causing the original package to fail as I've mentioned in the previous comment & I reckon I can handle it myself. I'll open another issue with a PR when job's done.

Treata11 commented 10 months ago

Nowadays a testtarget is supposed to copy it's resources like this:

Could you be a little bit more descriptive on this issue? This is the Package.swift file of the project:


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

import PackageDescription

#if swift(>=5.7)
let platforms: [PackageDescription.SupportedPlatform] = [.macOS(.v10_14), .iOS(.v11), .watchOS(.v4), .tvOS(.v11)]
#elseif swift(>=5.0)
let platforms: [PackageDescription.SupportedPlatform]? = nil
#endif

let package = Package(
    name: "SwiftMXL",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SwiftMXL",
            targets: ["SwiftMXL"]
        ),
    ],
    dependencies: [
        .package(url: "https://github.com/MaxDesiatov/XMLCoder", from: "0.17.1"),
        .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "SwiftMXL",
            dependencies: ["XMLCoder"]
        ),
        .testTarget(
            name: "SwiftMXLTests",
            dependencies: ["SwiftMXL", "Yams"]
        ),
    ]
)

what has to be edited here?

fjagerman commented 10 months ago

Hi Treata

Sorry for bothering you with a fix for a problem you don’t have yourself. I changed package.swift (as shown below) because the tests could not access those resources (using Xcode 15.0 and MacOS Sonoma 14.0) The resources were introduced with SE-0271. https://github.com/apple/swift-evolution/blob/main/proposals/0271-package-manager-resources.md p.s. My own project seems to be working fine with XMLCoder 17.1 Good luck with your project!

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

import PackageDescription

let package = Package( name: "SwiftMXL", products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( name: "SwiftMXL", targets: ["SwiftMXL"] ), ], dependencies: [ .package(url: "https://github.com/MaxDesiatov/XMLCoder", from: "0.17.1"), .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"), ], targets: [ .target( name: "SwiftMXL", dependencies: ["XMLCoder"] ), .testTarget( name: "SwiftMXLTests", dependencies: ["SwiftMXL", "Yams"], resources: [ .copy("Complex Types"), .copy("LilyPondTests"), .copy("ScoreTests"), ]), ] )