stackotter/swift-cross-ui

Basic Counter App project not working on linux

ajstrand opened this issue · 7 comments

Hi,
This is a really neat project and one that I'm definitely interested in contributing to.

I tried creating a basic Counter App with the example Package.swift in the Readme.

I got this error in my terminal when I ran swift build

error: product 'SwiftGtk' required by 
package 'swift-cross-ui' target 'SwiftCrossUI' not found.

This is what my package.swift looks like

// 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: "Example",
    dependencies: [
            .package(url: "https://github.com/stackotter/swift-cross-ui", .branch("main"))

    ],
    targets: [
             .executableTarget(
            name: "Example",
             dependencies: [
        .product(name: "SwiftCrossUI", package: "swift-cross-ui")
      ]),
        .testTarget(
            name: "ExampleTests",
            dependencies: ["Example"]),
    ]
)

I'm running Pop OS which is a Ubuntu fork/derivative.

This should be fixed now if you run swift package clean and try again. This issue was my fault, I renamed my fork of SwiftGtk and broke some things. Can you please confirm that it's fixed?

I look forward to your contributions if you decide to contribute :)

Hey dont worry about it.

I ran swift package clean and then swift build

and got a new error:

https://github.com/stackotter/SwiftGtk 
@ 71e570e1a87e4185119247e97fb155fbe69d6265: 
error: could not find the commit 71e570e1a87e4185119247e97fb155fbe69d6265 in https://github.com/stackotter/SwiftGtk

I dont see that commit hash in your Swift Gtk fork, so I'm not sure where it's coming from.

Maybe try deleting Package.resolved and trying again? Maybe it's slightly corrupted

So deleting Package.resolved fixed the build issue.

However the Swift compiler doesnt seem to like the @main attribute in your Counter example.

/home/alex/Documents/Example/Sources/Example/main.swift:9:1: 
error: 'main' attribute cannot be used in a module that contains top-level code
@main

I'm not what cause behind this could be if the project works on macOS.

You need to rename your main.swift file to something else such as Example.swift. Otherwise Swift assumes you have top-level code.

That worked! Thanks for your help.

You're welcome :) Thanks for checking out the project