Skip to content

Collaborative IoT framework in Swift targeted at iOS, iPadOS, and MacOS applications.

License

Notifications You must be signed in to change notification settings

coatyio/coaty-swift

Repository files navigation

Coaty Swift

Powered by Coaty 2 Swift version Pod version Pod platform License: MIT

Ready to upgrade to CoatySwift 2?

CoatySwift is a Coaty implementation written in Swift 5. The CoatySwift package provides the cross-platform implementation targeted at iOS, iPadOS,and macOS native applications.

CoatySwift comes with complete API documentation, a developer guide, a tutorial, and best-practice examples.

What is Coaty

Using the Coaty [koʊti] framework as a middleware, you can build distributed applications out of decentrally organized application components, so called Coaty agents, which are loosely coupled and communicate with each other in (soft) real-time. The main focus is on IoT prosumer scenarios where smart agents act in an autonomous, collaborative, and ad-hoc fashion. Coaty agents can run on IoT devices, mobile devices, in microservices, cloud or backend services.

Coaty provides a production-ready application and communication layer foundation for building collaborative IoT applications in an easy-to-use yet powerful and efficient way. The key properties of the CoatySwift framework include:

  • a lightweight and modular object-oriented software architecture favoring a resource-oriented and declarative programming style,
  • standardized event based communication patterns on top of an open publish-subscribe messaging protocol (currently MQTT),
  • and a platform-agnostic, extensible object model to discover, distribute, share, query, and persist hierarchically typed data.

Learn how to use

If you are new to CoatySwift and would like to learn more, we recommend checking out the following resources:

  • Tutorial - shows how to set up a minimal CoatySwift app.
  • Developer Guide - explains how to develop a CoatySwift app.
  • API Documentation - the source code documentation of public types and members of the CoatySwift framework.
  • Design Rationale - in case you want to know why certain things have been implemented in a particular way in the CoatySwift implementation.

Getting started

Coaty Swift now supports both Swift Package Manager and CocoaPods!

It is compatible with the the following deployment targets:

Deployment Target Compatibility
iOS 9.0+
macOS 10.14+

CocoaPods

To use Coaty Swift with Cocoapods you need XCode 10.2 or higher. CoatySwift is available through CocoaPods. Ensure you have installed at least version 1.8.4 of CocoaPods, i.e. running pod --version should yield 1.8.4 or higher.

You can add the CoatySwift pod to the Podfile of your app as follows:

target 'MyApp' do
  pod 'CoatySwift', '~> 2.4.0'
end

Then, run a pod install.

Swift Package Manager

To use CoatySwift with Swift Package Manager you need XCode 11.0 or higher. The Swift Package Manager is a package manager integrated into the swift compiler.

Once you have your Swift package set up, add CoatySwift by modifying the dependencies attribute in your Package.swift file.

dependencies: [
    .package(url: "https://github.com/coatyio/coaty-swift", from: "2.4.0"),
]

Examples

If you want a short, concise look into CoatySwift, feel free to check out the CoatySwift Tutorial with a step-by-step guide on how to set up a basic CoatySwift application.

The source code of this tutorial can be found in the CoatySwiftExample Xcode project inside of the CoatySwift repo. Just clone the repo, open the Example.xcodeproj file and run the project on a device / simulator.

You can find additional examples in the swift sections of the coaty-examples repo on GitHub. You will find the following Xcode projects there: Hello World and Remote Operations. They are interoperable with the corresponding Coaty JS examples and intended to be used along with them. These projects can serve as blueprints for how to design CoatySwift applications.

Testing

If you want to run unit tests on CoatySwift, look at (https://github.com/coatyio/coaty-swift/tree/master/Tests) Xcode target of the CoatySwift repo. Just clone the repo and wait for XCode to fetch all of the required dependencies. Then select the Test Navigator in Navigator View, enable chosen tests and run them. Plese note that an MQTT Broker must be present to test some of the functionality (running on localhost:1883) - you may use the Coaty Development Broker, as described in e.g. coaty-examples/hello-world/js.

Contributing

If you like CoatySwift, please consider ★ starring the project on github. Contributions to the CoatySwift framework are welcome and appreciated.

Please follow the recommended practice described in CONTRIBUTING.md. This document also contains detailed information on how to build, test, and release the framework.

License

Code and documentation copyright 2019 Siemens AG.

Code is licensed under the MIT License.

Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

The following list displays all the relevant licenses for third-party software CoatySwift depends on:

Credits

Last but certainly not least, a big Thank You! to the folks who designed, implemented and contributed to CoatySwift: