{"id":21969410,"url":"https://github.com/rhx/swifthellogtkbuilder","last_synced_at":"2025-10-27T13:37:19.578Z","repository":{"id":54934069,"uuid":"65108862","full_name":"rhx/SwiftHelloGtkBuilder","owner":"rhx","description":"A simple 'hello-world' GtkBuilder app using SwiftGtk","archived":false,"fork":false,"pushed_at":"2023-07-29T06:35:45.000Z","size":77,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-27T07:18:18.669Z","etag":null,"topics":["gtk","gtk3","gtk4","gtkbuilder","linux","macos","swift","ubuntu","xcode"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-07T00:56:43.000Z","updated_at":"2024-12-29T08:58:16.000Z","dependencies_parsed_at":"2022-08-14T07:00:31.834Z","dependency_job_id":null,"html_url":"https://github.com/rhx/SwiftHelloGtkBuilder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhx%2FSwiftHelloGtkBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhx%2FSwiftHelloGtkBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhx%2FSwiftHelloGtkBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhx%2FSwiftHelloGtkBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhx","download_url":"https://codeload.github.com/rhx/SwiftHelloGtkBuilder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251099787,"owners_count":21536163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gtk","gtk3","gtk4","gtkbuilder","linux","macos","swift","ubuntu","xcode"],"created_at":"2024-11-29T14:19:47.745Z","updated_at":"2025-10-20T02:39:28.468Z","avatar_url":"https://github.com/rhx.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftHelloGtkBuilder\n\nA simple 'hello-world' GtkBuilder app using SwiftGtk\n\n![macOS 11 build](https://github.com/rhx/SwiftHelloGtkBuilder/workflows/macOS%2011/badge.svg)\n![macOS 10.15 build](https://github.com/rhx/SwiftHelloGtkBuilder/workflows/macOS%2010.15/badge.svg)\n![macOS gtk4 build](https://github.com/rhx/SwiftHelloGtkBuilder/workflows/macOS%20gtk4/badge.svg)\n![Ubuntu 20.04 build](https://github.com/rhx/SwiftHelloGtkBuilder/workflows/Ubuntu%2020.04/badge.svg)\n![Ubuntu 18.04 build](https://github.com/rhx/SwiftHelloGtkBuilder/workflows/Ubuntu%2018.04/badge.svg)\n\n## Building\n\nMake sure you have all the prerequisites installed (see below).  After that, you can simply clone this repository and build the command line executable (be patient, this will download all the required dependencies and take a while to compile) using\n\n\tgit clone https://github.com/rhx/SwiftHelloGtkBuilder.git\n\tcd SwiftHelloGtkBuilder\n    ./run-gir2swift.sh\n\tswift build\n\nYou can run the program using\n\n\tswift run\n\nA simple, empty 'Hello World' window should appear.  To exit the program, click the close button or press Control-C in the Terminal window.\n\n### macOS\n\nPlease note that on macOS, due to a bug currently in the Swift Package Manager,\nyou need to pass in the build flags manually, i.e. instead of `swift build` and `swift run` you can run\n\n    swift build `./run-gir2swift.sh flags -noUpdate`\n    swift run   `./run-gir2swift.sh flags -noUpdate`\n\n#### Application Bundler\n\nUnder macOS, you can also create an Application bundle that you can create and open directly:\n\n    ./app-bundle.sh\n\topen .build/app/HelloGtkBuilder.app\n\nThis bundle is self-contained and you can move it to your `Applications` folder (or wherever it suits you), e.g.:\n\n\tmv .build/app/HelloGtkBuilder.app /Applications\n\n#### Xcode\n\nOn macOS you can also build the project using Xcode instead (but there is no full macOS app target yet, only a command-line executable).  To do this, you need to create an Xcode project first, then open the project in the Xcode IDE:\n\n\n\t./xcodegen.sh\n\topen HelloGtkBuilder.xcodeproj\n\nAfter that, select the executable target (not the Bundle/Framework target with the same name as the executable) and use the (usual) Build and Run buttons to build/run your project.\n\n## What is new?\n\nThis now uses SPM and Foundation to package and resolve resources (`.ui` files).\n\nExperimental support for gtk 4 was added via the `gtk4` branch.\n\nVersion 12 of gir2swift pulls in [PR#10](https://github.com/rhx/gir2swift/pull/10), addressing several issues:\n\n- Improvements to the Build experience and LSP [rhx/SwiftGtk#34](https://github.com/rhx/SwiftGtk/issues/34)\n- Fix issues with LLDB [rhx/SwiftGtk#39](https://github.com/rhx/SwiftGtk/issues/39)\n- **Controversial:** Implicitly marks all declarations named \"priv\" as if they had attribute `private=1`\n- Prevents all \"Private\" records from generating unless generated in their instance record\n  - `-a` option generates all records\n- Introduces CI\n- For Class metadata types no longer generates class wrappers. Ref structs now contain static method which returnes the GType of the class and instance of the Class metatype wrapped in the Ref struct.\n- Adds final class GWeak\u003cT\u003e where T could be any Ref struct of a type which supports ARC. This class is a property wrapper which contains weak reference to any instance of T. This is especially beneficial for capture lists.\n- Adds support for weak observation.\n- Constructors and factories of GObjectInitiallyUnowned classes now consume floating reference upon initialisation as advised by [the GObject documentation](https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html)\n\nPartially implemented:\n- Typed signal generation. Issues shown in [rhx/SwiftGtk#35](https://github.com/rhx/SwiftGtk/issues/35) hat remain to be addressed are listed here: [mikolasstuchlik/gir2swift#2](https://github.com/mikolasstuchlik/gir2swift/pull/2).\n\n### Other Notable changes\n\nVersion 11 introduces a new type system into `gir2swift`,\nto ensure it has a representation of the underlying types.\nThis is necessary for Swift 5.3 onwards, which requires more stringent casts.\nAs a consequence, accessors can accept and return idiomatic Swift rather than\nunderlying types or pointers.\nThis means that a lot of the changes will be source-breaking for code that\nwas compiled against libraries built with earlier versions of `gir2swift`.\n\n * Requires Swift 5.2 or later (Swift 5.3 is required for gtk4)\n * Wrapper code is now `@inlinable` to enable the compiler to optimise away most of the wrappers\n * Parameters and return types use more idiomatic Swift (e.g. `Ref` wrappers instead of pointers, `Int` instead of `gint`, etc.)\n * Functions that take or return records now are templated instead of using the type-erased Protocol\n * `ErrorType` has been renamed `GLibError` to ensure it neither clashes with `Swift.Error` nor the `GLib.ErrorType`  scanner enum\n * Parameters or return types for records/classes now use the corresponding, lightweight Swift `Ref` wrapper instead of the underlying pointer\n\n\n## Prerequisites\n\n### Swift\n\nTo build, you need at least Swift 5.3 (which has support for bundled resources).\nDownload from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well).\nTest that your compiler works using `swift --version`, which should give you something like\n\n\t$ swift --version\n\tApple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)\n    Target: x86_64-apple-darwin20.3.0\n\non macOS, or on Linux you should get something like:\n\n\t$ swift --version\n\tSwift version 5.3.2 (swift-5.3.2-RELEASE)\n\tTarget: x86_64-unknown-linux-gnu\n\n### Gtk 3.22 or higher\n\nThe Swift wrappers have been tested with glib-2.46, 2.48, 2.52, 2.56, 2.58, 2.60, 2.62, 2.64 and 2.66, and gdk/gtk 3.18, 3.20, 3.22, 3.24, and 4.0 on the `gtk4` branch.  They should work with higher versions, but YMMV.  Also make sure you have `gobject-introspection` and its `.gir` files installed.\n\n#### Linux\n\n##### Ubuntu\n\nOn Ubuntu 20.04 and 18.04 you can use the gtk that comes with the distribution.  Just install with the `apt` package manager:\n\n\tsudo apt update\n\tsudo apt install libgtk-3-dev gir1.2-gtksource-3.0 gobject-introspection libgirepository1.0-dev libxml2-dev\n\n##### Fedora\n\nOn Fedora 29, you can use the gtk that comes with the distribution.  Just install with the `dnf` package manager:\n\n\tsudo dnf install gtk3-devel pango-devel cairo-devel cairo-gobject-devel glib2-devel gobject-introspection-devel libxml2-devel\n\n#### macOS\n\nOn macOS, you can install gtk using HomeBrew (for setup instructions, see http://brew.sh).  Once you have a running HomeBrew installation, you can use it to install a native version of gtk:\n\n\tbrew update\n\tbrew install gtk+3 glib glib-networking gobject-introspection pkg-config\n\n## Troubleshooting\n\nHere are some common errors you might encounter and how to fix them.\n\n### Old Swift toolchain or Xcode\n\nIf you get an error such as\n\n\t$ ./build.sh \n\terror: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-package (No such file or directory)\n\t\nthis probably means that your Swift toolchain is too old.  Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).\n\n  If you get an older version, make sure that the right version of the swift compiler is found first in your `PATH`.  On macOS, use xcode-select to select and install the latest version, e.g.:\n\n\tsudo xcode-select -s /Applications/Xcode.app\n\txcode-select --install\n\n### Known Issues\n\n * When building, a lot of warnings appear.  This is largely an issue with automatic `RawRepresentable` conformance in the Swift Standard library.  As a workaround, you can turn this off by passing the `-Xswiftc -suppress-warnings` parameter when building.\n \n * The current build system does not support directory paths with spaces (e.g. the `My Drive` directory used by Google Drive File Stream).\n * BUILD_DIR is not supported in the current build system.\n \nAs a workaround, you can use the old build scripts, e.g. `./build.sh` (instead of `run-gir2swift.sh` and `swift build`) to build a package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhx%2Fswifthellogtkbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhx%2Fswifthellogtkbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhx%2Fswifthellogtkbuilder/lists"}