Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// ComNextchapterOrangeModule.swift
// orange
// Created by Your Name
// Copyright (c) 2019 Your Company. All rights reserved.
import UIKit
import TitaniumKit
import OrangeTrustBadge
Titanium Swift Module Requirements
1. Use the @objc annotation to expose your class to Objective-C (used by the Titanium core)
2. Use the @objc annotation to expose your method to Objective-C as well.
3. Method arguments always have the "[Any]" type, specifying a various number of arguments.
Unwrap them like you would do in Swift, e.g. "guard let arguments = arguments, let message = arguments.first"
4. You can use any public Titanium API like before, e.g. TiUtils. Remember the type safety of Swift, like Int vs Int32
and NSString vs. String.
class ComNextchapterOrangeModule: TiModule {
public let testProperty: String = "Hello World"
func moduleGUID() -> String {
return "34d56fd4-0a90-47ed-8a6b-908b4b07bcb9"
override func moduleId() -> String! {
return ""
override func startup() {
debugPrint("[DEBUG] \(self) loaded")
func example(arguments: Array<Any>?) {
let storyboard = UIStoryboard(name: "OrangeTrustBadge", bundle: Bundle(for: TrustBadge.self))
if let viewController = storyboard.instantiateInitialViewController() {
TiApp.controller()?.topContainerController()?.present(viewController, animated: true)
@objc public var exampleProp: String {
get {
// Example property getter
return "Titanium rocks!"
set {
// Example property setter
// Call with "MyModule.exampleProp = 'newValue'"
self.replaceValue(newValue, forKey: "exampleProp", notification: false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.