Skip to main content

Using Portals in iOS

Creating a Portal

Create a Portal via it's initializer:

let portal = Portal(name: "webapp")

Portal also conforms to ExpressibleByStringLiteral:

let portal: Portal = "webapp"

By default, a Portal will use the name property as the directory to load web content from (relative to the root of Bundle.main). You can specify another location if needed:

let portal = Portal(name: "webapp", startDir: "portals/webapp")

Using PortalView and PortalUIView

After you initialize a Portal, you create a PortalView (for SwiftUI) or PortalUIView (for UIKit) by passing in the Portal.

Portal Initializer
class ViewController: UIViewController {
override func loadView() {
let portal = Portal(name: "webapp")
self.view = PortalUIView(portal: portal)
}
}
class ViewController: UIViewController {
override func loadView() {
self.view = PortalUIView(portal: "webapp")
}
}

Adding Web Code

Now that your Portal is successfully created and added to the view, you need to add the web assets to your application. In iOS, the web folder needs to be copied and added to the XCode project. After the folder is added, you can update its contents with fresh builds of the web application. For more information on how to set up your web bundle, see our how-to guide on how to pull in a web bundle.