Skip to content

the-swift-collective/imgui

Repository files navigation

ImGui

Cross platform swift package for the imgui library.

Demo

To run an imgui example, first install SwiftBundler, and run the following (currently only the glfw+metal backend on macOS, more coming soon...)
git clone https://github.com/the-swift-collective/imgui.git
cd imgui

swift bundler run

should launch 'GLFWMetalApp.app'.


Usage

To use imgui in swift, add imgui as a package dependency in your project's Package.swift file.
dependencies: [
  .package(url: "https://github.com/the-swift-collective/imgui.git", branch: "main"),
]
Then, for any target you'd like, add the imgui product as a target dependency, a complete example.
// swift-tools-version: 5.10
import PackageDescription

let package = Package(
  name: "MyPackage",
  products: [
    .library(
      name: "MyLibrary",
      targets: ["MyLibrary"]
    ),
  ],
  dependencies: [
    .package(url: "https://github.com/the-swift-collective/imgui.git", branch: "main")
  ],
  targets: [
    .target(
      name: "MyLibrary",
      dependencies: [
        /* add the imgui product as a library dependency. */
        .product(name: "ImGui", package: "imgui"),
      ],
      cxxSettings: [
        /* for windows, add the following until swift updates its embedded clang. */
        .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])),
        .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])),
        .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])),
      ],
      swiftSettings: [
        /* enable swift/c++ interop. */
        .interoperabilityMode(.Cxx),
      ]
    ),
  ],
  /* use cxx17 language standard. */
  cxxLanguageStandard: .cxx17
)


the swift collective - cross platform swift packages.
imgui is licensed under the terms of the MIT License.

About

create bloat free gui in swift with imgui.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages