https://github.com/sourcemeta-research/native
The Native Framework. Build a desktop applications with C++
https://github.com/sourcemeta-research/native
Last synced: about 1 year ago
JSON representation
The Native Framework. Build a desktop applications with C++
- Host: GitHub
- URL: https://github.com/sourcemeta-research/native
- Owner: sourcemeta-research
- License: other
- Created: 2024-04-24T21:33:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-21T16:11:30.000Z (over 1 year ago)
- Last Synced: 2025-01-25T07:07:24.194Z (over 1 year ago)
- Language: CMake
- Homepage:
- Size: 139 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

native
Build your Desktop application with C++
Native is a C++ framework designed to streamline the development of native applications for C++ developers.
> ✋ Native is currently available in alpha for macOS and Windows, but *it is not production ready*!
## ✨ Features
- 🚀 **Modern C++ API**: Streamlined API for modern C++.
- 🛠 **CMake Integration**: Seamless integration with CMake projects.
- 📦 **Packaging Ready**: Includes code signing for macOS (notarization is comming)
- 🧩 **Modular Architecture**: Opt-in modules for tailored functionality.
### Roadmap
#### `ui`
| Module | macOS Support | Win32 Support | Notes |
|--------------|---------------------|---------------------|-----------------------------------------------------------------|
| **Window** | ✅ Supported | ✅ Supported | Basic window creation and management |
| **WebView** | ✅ Supported | ✅ Supported | Embeds web content in a native app |
| **Menu** | 🚧 Planned | 🚧 Planned | Application menus |
| **IPC** | 🚧 Planned | 🚧 Planned | Communication channel between the main process and the Webview. |
| **Tray** | 🚧 Planned | 🚧 Planned | System tray icons and context menus |
#### `sysmod`
| Module | macOS Support | Win32 Support | Notes |
|------------------|---------------------|---------------------|-----------------------------------------------|
| **Open** | 🚧 Planned | 🚧 Planned | Open URLs, URIs, and files |
| **Storage** | 🚧 Planned | 🚧 Planned | Key-value storage for app data |
| **HTTP Client** | 🚧 Planned | 🚧 Planned | Send HTTP requests, handle responses |
## Getting Started with Native using CMake
1. Code!
Create these three files at the root of your project.
```cc
// main.cc
#include
#include
#include
#include
#include
class App : public sourcemeta::native::Application {
public:
auto on_start() -> void override { std::cout << "Starting!" << std::endl; }
auto on_ready() -> void override {
std::cout << "Ready!" << std::endl;
window.size(1200, 900);
window.show();
webview.load_html("index.html");
window.add(webview);
this->exit();
}
auto on_error(std::exception_ptr) noexcept -> void override {}
private:
sourcemeta::native::Window window;
sourcemeta::native::WebView webview;
};
NATIVE_RUN(App)
```
```html
Native Framework
Welcome to Native
This is a simple example to demonstrate loading HTML with CSS styling.
```
```css
/* style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f0f0f0;
}
h1 {
color: #333;
}
p {
color: #666;
}
```
2. Configure!
```cmake
cmake_minimum_required(VERSION 3.14)
project(my_hello_world)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Native REQUIRED)
native_add_app(
TARGET hello_world_app
PLATFORM desktop
SOURCES hello_world.cc)
native_add_assets(
TARGET hello_world_app
ASSETS index.html style.css)
native_set_profile(
TARGET hello_world_app
NAME "example_hello_world"
IDENTIFIER "com.native.example_hello_world"
VERSION "1.0.0"
DESCRIPTION "My app ..."
CODESIGN_IDENTITY "W4MF6H9XZ6"
MODULES "ui/window" "ui/webview")
```
3. Build!
```shell
cmake -S . -B ./build
cmake --build ./build
```
4. Enjoy!
The application is available in the `/dist` folder of your current directory.
https://github.com/user-attachments/assets/fba80492-d42d-4f9c-be3b-34ce6c1eabbf
## Contributing
We welcome contributions to this project! To get started, please follow these steps.
### Prerequisites
Make sure you have the following tools installed:
- [CMake](https://cmake.org/)
### Building the Project
1. **Clone the repository**:
```sh
git clone https://github.com/sourcemeta-research/native.git
cd native
```
2. **Install dependencies**:
```sh
git clone https://github.com/sourcemeta-research/native.git
cd native
```
3. **Configure and build the project**:
We use a Makefile to handle the build process, which in turn uses CMake. Simply run:
```sh
make
```
This will configure the project, build the necessary files, and run the executable.
4. **Running the Executable**:
After building the project, you can run the executable to ensure everything is working as expected:
```sh
make test
```
The `make` command will handle this for you and check the exit status of the executable.
We highly advise you to explore and play with the project inside the `/example` folder.
### Cleaning Up
To clean the build directory, run:
```sh
make clean
```