DeepShell is a lightweight Swift framework for URL-based command routing and command execution
It allows you to define commands via a property list (plist) and execute them dynamically, supporting parameterized routes and wildcards
- Define commands in a plist (
Commands.plistin your app bundle):
<plist version="1.0">
<dict>
<key>CommandList</key>
<array>
<dict>
<key>Alias</key>
<array><string>myapp://search</string></array>
<key>Class</key>
<string>SearchCommand</string>
<key>NeedLogin</key>
<false/>
</dict>
<dict>
<key>Alias</key>
<array><string>myapp://user/$(userId)/profile</string></array>
<key>Class</key>
<string>UserProfileCommand</string>
<key>NeedLogin</key>
<true/>
</dict>
</array>
</dict>
</plist>- Create commands conforming to
DSCommand(UIViewController or service):
class SearchCommand: NSObject, DSCommand {
var resultBlock: ((Error?, Any?) -> Void)?
required override init() {}
func run(params: [String: String]) {
// perform search
resultBlock?(nil, "results")
}
}- Initialize and setup DeepShell (e.g. in AppDelegate):
let shell = DeepShell()
shell.setupDeepShell(plistNames: ["Commands"])- Execute a command:
shell.execute(urlString: "myapp://search?q=swift") { error, result in
// handle result
}