msg2swift

2.0.0

Generate Swift model for ROS message, service or action file.
DimaRU/Msg2swift

What's New

v2.0.0

2024-04-06T17:32:23Z

Swift Platforms CI/CD

Msg2swift - Generate Swift models for ROS message, service and action files.

Description

Msg2swift help you generate swift models from ROS .msg/.srv/.action files. Intended for use with CDRCodable.
In particular Msg2swift generates proper CodableKeys for encoding and decoding fixed-size arrays.

Installation for use with command line

Homebrew

Run the following command to install using Homebrew:

brew install DimaRU/formulae/msg2swift

Swift package manager command plugin

When you add CDRCodable dependency to your project:

.package(url: "https://github.com/DimaRU/CDRCodable", from: "1.0.0")

you may use msg2swift SPM command line plugin:

swift package plugin --allow-writing-to-package-directory msg2swift ../../msg/BatteryState.msg -o model

Command line USAGE

USAGE: msg2swift [<options>] <file> ...

ARGUMENTS:
  <file>                  .msg or .srv or .action file(s) to convert.

OPTIONS:
  --let/--var             Use var or let for model properties. (default: --let)
  --struct/--class        Struct or class declaration. (default: --struct)
  --codable/--encodable/--decodable
                          Model declaration protocol. (default: --codable)
  --snake-case/--no-snake-case
                          Convert property names from "snake_case" to
                          "camelCase" (default: --snake-case)
  -c, --compact           Compact generated code.
        Strip all comments and remove empty lines.
  --detect-enum/--no-detect-enum
                          Detect enums. (default: --detect-enum)
        Detect and group constants into Swift enum.
  -n, --name <name>       Object name.
        By default file name used.
  -o, --output-directory <path>
                          The output path for generated files.
        By default generated files written to the current directory.
  -s, --silent            Don't print processed file names.
  --version               Show the version.
  -h, --help              Show help information.

Build

Use swift package manager for build.

https://github.com/DimaRU/Msg2swift.git
cd Msg2swift
swift build

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Tue Apr 30 2024 00:12:07 GMT-0900 (Hawaii-Aleutian Daylight Time)