RoundCode for iOS

RoundCode is a Facebook messenger like custom QR code with lots of customization.

In addition to encoder the RoundCode also includes convenient camera scanner and decoder.



pod 'RoundCode'

Swift Package Manager:

File > Swift Packages > Add Package Dependency

Usage example

import framework

import RoundCode


create coder and encode

let image = RCImage(message: "Hello World")
let coder = RCCoder()
do {
  imageView.image = try coder.encode(image)
} catch {
  //handle errors

You can also validate the messsage before encoding

let coder = RCCoder()
let isValidText = coder.validate("Hello world")


Create instane of RCCameraViewController and handle the delegate

class ViewController: UIViewController, RCCameraViewControllerDelegate {
  func scan() {
    let cameraController = RCCameraViewController()
    cameraController.delegate = self
    present(cameraController, animated: true)
  func cameraViewController(didFinishScanning message: String) {
    messageLabel.text = message

You can also decode a UIImage like this

let coder = RCCoder()
  do {
    messageLabel.text = try coder.decode(UIImage(named: code)!)
  } catch {
    //handle errors


You can change the appearance like this

var image = RCImage(message: "Hello world")
image.contentInsets = UIEdgeInsets(top: 8, left: 10, bottom: 4, right: 10)
image.attachmentImage = UIImage(named: "Profile")
image.size = 300
image.gradientType = .linear(angle: CGFloat.pi)
image.tintColors = [.red, .black]

⚠️ When choosing colors or transparent background you should keep in mind that decoder will detect the code on light background with dark colors ⚠️


You can provide custom coding configuration in order to encode long text by reducing number of characters

let configuration = RCCoderConfiguration.shortConfiguration
let coder = RCCoder(configuration: configuration)
let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789")
let coder = RCCoder(configuration: configuration)

⚠️ If you are encoding with custom configuration, then you should change the RCCameraViewController configuration ⚠️

let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789")
let coder = RCCoder(configuration: configuration)
let camera = RCCameraViewController()
camera.coder = coder


Written in Swift 5 and requires Xcode 11.0

RoundCode is compatible with iOS 13.0+.