I am recently working on a uni project to build an IOS app and during building the onboarding screens, the project builds fine but right after that it throws the error.
Would really appreciate if anyone can tell me what is actually going wrong.
This is the app delegate and view controller code :
App delegate :
import UIKit import Firebase import FirebaseDatabase import MSAL
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
Database.database().isPersistenceEnabled = true
//Sadi added some code snippets here for the App Tutorial
window = UIWindow(frame: UIScreen.main.bounds)
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
var initialViewController = storyBoard.instantiateViewController(withIdentifier: "Onboarding")
let userDefaults = UserDefaults.standard
if userDefaults.bool(forKey: "onboardingComplete") {
initialViewController = storyBoard.instantiateViewController(withIdentifier: "Mainapp")
}
window?.rootViewController = initialViewController
window?.makeKeyAndVisible()
return true
}
View Controller :
import UIKit import PaperOnboarding
class ApptutorialViewController: UIViewController, PaperOnboardingDataSource, PaperOnboardingDelegate {
@IBOutlet weak var onboardingView: OnboardingView!
@IBOutlet weak var getStartedButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
onboardingView.dataSource = self
onboardingView.delegate = self
// Do any additional setup after loading the view.
}
func onboardingItemsCount() -> Int {
return 6
}
func onboardingItem(at index: Int) -> OnboardingItemInfo {
return [
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "logo"),
title: "Welcome to SpiderByte!",
description: "Please take a few minutes to learn about the features of the app",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.red,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 10)!),
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "slide"),
title: "Navigate around the application",
description: "Swipe to switch between Announcements, Events and Personal Information",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.blue,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 18)!),
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "lock"),
title: "Login with your K-number",
description: "You can log in with your existing email, using k-number@kcl.ac.uk",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.cyan,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 18)!),
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "bullhorn"),
title: "Announcements",
description: "You can click on each announcement to see more detail",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.blue,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 18)!),
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "calendar"),
title: "Calendar",
description: "You can click on dates to see more details about events on that day",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.blue,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 18)!),
OnboardingItemInfo(informationImage: #imageLiteral(resourceName: "settings"),
title: "Settings",
description: "You can click on settings tab to see personal information and application details",
pageIcon: #imageLiteral(resourceName: "active"),
color: UIColor.blue,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont.init(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont.init(name: "AvenirNext-Regular", size: 18)!)
][index]
}
// func onboardingConfigurationItem(_: OnboardingContentViewItem, index _: Int) {
// <#code#>
// }
func onboardingWillTransitonToIndex(_ index: Int) {
if index == 1 {
if self.getStartedButton.alpha == 1 {
UIView.animate(withDuration: 0.2, animations: {
self.getStartedButton.alpha = 0
})
}
}
}
func onboardingDidTransitonToIndex(_ index: Int) {
if index == 5 {
UIView.animate(withDuration: 0.4, animations: {
self.getStartedButton.alpha = 1
})
}
}
@IBAction func gotStarted(_ sender: Any) {
let userDefaults = UserDefaults.standard
userDefaults.set(true, forKey: "onboardingComplete")
userDefaults.synchronize()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}