Category: iOS Swift

  • Font Awesome, Swift 5 Support With Swift Package Manager (SPM)

    Font Awesome, Swift 5 Support With Swift Package Manager (SPM)

    I wanted to give a try to Swift Package Manager which is build in functionality in Xcode 11. I have to say fantastic! I think in very short future all Git repository will be updated with this package independence manager. Finally we will be able tosay “good bye” to CocoaPod, Cartilage and some many other.…

  • Render and Test UIKit UIView Realtime On Xcode 11 With SwiftUI Integration

    Render and Test UIKit UIView Realtime On Xcode 11 With SwiftUI Integration

    How to integrate UIKit UIView in few line of code.   // // SampleV.swift // UIExp // // Created by dejaWorks on 14/01/2020. // Copyright © 2020 dejaWorks. All rights reserved. // #if canImport(SwiftUI) && DEBUG import SwiftUI #endif import UIKit // MARK: – An ordinary UIView class SampleV: UIView{ override init(frame: CGRect) { super.init(frame:…

  • Render and Test UIKit UIViewController Realtime On Xcode 11 With SwiftUI Integration

    Render and Test UIKit UIViewController Realtime On Xcode 11 With SwiftUI Integration

    How to integrate UIKit UIViewController  in few line of code.   // // RedVC.swift // SwiftUIOne // // Created by dejaWorks on 14/01/2020. // Copyright © 2020 dejaWorks. All rights reserved. // #if canImport(SwiftUI) && DEBUG import SwiftUI #endif import UIKit // MARK: – An ordinary VC /// VC (UIKit UIViewController) class RedVC: UIViewController {…

  • Xcode11 iOS13 Simulators Couldn’t find MIDI Network Driver Problem – Solved

    Xcode11 iOS13 Simulators Couldn’t find MIDI Network Driver Problem – Solved

    Recently I installed Xcode11 and tried my working music application on iOS13 simulator. But unfortunately I faced an unexpected runtime error message “Couldn’t find MIDI network driver” and crash! I was using last update of  AudioKit 4.9 (as I updated it at the same time with Xcode 11) I thought that could be the problem. But not!…

  • iOS Swift Accessing Bundle Folder And File Write

    iOS Swift Accessing Bundle Folder And File Write

    To access a file in Bundle folder: Bundle.main.url(forResource:”YourFile”, withExtension: “FileExtension”)   Also to write a file with error checking: var myData: Data! func checkFile() { if let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last { let fileURL = documentsDirectory.appendingPathComponent(“TheFile.extension”) do { let fileExists = try fileURL.checkResourceIsReachable() if fileExists == true { print(“File exists”) } else {…

  • iOS Swift Save|Load Custom Class Variables As Encoded Object

    iOS Swift Save|Load Custom Class Variables As Encoded Object

    By using NSKeyedArchiver.archivedData, NSKeyedUnarchiver.unarchiveObject you can actually store the data as compressed zip in the device and recall/unzip them to your class structure Model Class class User: NSObject, NSCoding { // Common var userId: Int = 0 var userFullName: String = “” var userUsername: String = “” var userBiography: String = “” var userRegisterDate: String =…

  • iOS Swift Navigation With Manuel Segue

    iOS Swift Navigation With Manuel Segue

    Unwind Structure Example @IBAction func unwindToTheVC(segue: UIStoryboardSegue) { if let source = segue.source as? OtherVC { print(“From OtherVC”) } }     Manuel Segue Example func gotoSegue(_ sender:Any){ guard let destination = UIStoryboard(name:”Main”, bundle:nil).instantiateViewController(withIdentifier: “TheTableViewController”) as? TheTableViewController else { print(“Could not instantiate view controller with identifier of type SecondViewController”) return } destination.variablesToSet = vars destination.unwindTo…

  • iOS Swift Find Exist Fond Families In The Project

    iOS Swift Find Exist Fond Families In The Project

    This code showing the font families and real name of the fonts.   for family: String in UIFont.familyNames { print(“\(family)”) for names: String in UIFont.fontNames(forFamilyName: family) { print(“== \(names)”) } }  

  • Resolving CocoaPods Install Problem

    CococaPods is not stable installer sometimes it install but not link to the project properly. This creates a runtime error. Reference is here. Deintegrate the cocoapods (means uninstall the pods) can help to refresh the install. You can install the tool with sudo gem install cocoapods-deintegrate Will uninstall the existing Pod files but keep the…

  • Xcode Export Entire Build Log

    In order to determine  a build problem, export the log into text file. Navigate into project, in terminal type line below xcodebuild -project yourproject.xcodeproj -scheme YourBuildScheme -arch arm64 -sdk iphoneos > build-log.txt 2>&1  

  • Making iOS Swift App Without Storyboard, Just Programmatically!

    Making iOS Swift App Without Storyboard, Just Programmatically!

    Storyboard is a good thing but has some side unwanted effect. You can find many discussion about it. Personally I don’t like it so much especially when I make an application without default navigation system it is useless, slow and makes me tired. I prefer creating my UIViews separately and link them to their UIViewController’s…

  • iOS Swift Initialising XIB And Bind To The Controller Without Storyboard

    iOS Swift Initialising XIB And Bind To The Controller Without Storyboard

    It is very useful to able to initialise  xib files independently from storyboard. Here is what to do with a line of code: //Calling the initializer in the ViewController convenience override init() { // ViewName is by convenience same name. // I use like: BlahV.xib BlahVC.swift self.init(nibName: “BlahV.xib”, bundle: nil) //initializing the view Controller form specified…