libgnss-codes

Installation and Usage Guide

This project is a Swift 6.0 port of the libgnss-codes C library. It provides high-performance GNSS ranging code generation for GPS, Galileo, GLONASS, and BeiDou.

Prerequisites

Installation

As a Dependency in a Swift Package

Add libgnss-codes-swift to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/shuwang1/libgnss-codes-swift.git", from: "1.0.0")
]

Then, add it to your target’s dependencies:

targets: [
    .target(
        name: "MyTarget",
        dependencies: [
            .product(name: "GNSSCodes", package: "libgnss-codes-swift")
        ]
    )
]

Testing

To verify the installation and ensure all GNSS codes are generated correctly:

swift test

This will run the comprehensive test suite covering GPS, Galileo, GLONASS, and BeiDou signals.

Usage

Import the module in your Swift code and use the unified generate API:

import GNSSCodes

// Generate GPS L1 C/A code for PRN 1
if let code = GNSSCodes.generate(prn: 1, type: .L1CA) {
    print("Generated \(code.length) chips at \(code.chipRate) Hz")
    print("First 10 chips: \(code.chips.prefix(10))")
}

// Generate Galileo E1B code for PRN 10
if let e1bCode = GNSSCodes.generate(prn: 10, type: .E1B) {
    // Process Galileo chips...
}

Supported Signal Types

The library supports a wide range of signals via the CodeType enum:

Documentation

The project includes the swift-docc-plugin. You can generate rich API documentation using Swift DocC:

swift package generate-documentation

To preview the documentation in your browser (starts a local web server):

swift package --disable-sandbox preview-documentation --target GNSSCodes

Build Options

Build for release (optimized):

swift build -c release