Search code examples
iosswiftxcodepodfileeureka-forms

Eureka not working with Swift 5 | Swift/Xcode


I've got to gather three different sections of data from users. Instead of building all the forms myself and it taking forever, I decided to use a third party pod. I found that Eureka is largely used. For some reason, it WILL NOT work for me, no matter what tutorial I follow.

Here is my Podfile:

# Uncomment the next line to define a global platform for your project
 platform :ios, '10.0'

target 'Pics2Report' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Pics2Report
pod 'IQKeyboardManagerSwift'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Storage'
  target 'Pics2ReportTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'Pics2ReportUITests' do
    # Pods for testing
  end

pod 'SCLAlertView'
pod 'HGPlaceholders'
pod 'FloatingPanel'
pod 'BEMCheckBox'
pod 'Eureka'

end

It says I installed the pod successfully. Inside my project, I try to run this code:

import Foundation
import Eureka
import UIKit

class FileDetailsViewController: FormViewController {
        
        override func viewDidLoad() {
            super.viewDidLoad()
            
            form +++ Section("About You")
                <<< TextRow() { row in
                    row.title = "Name"
                    row.placeholder = "Your Name"
                }
        }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        //Lock screen into portrait mode
        AppUtility.lockOrientation(.portrait)
        self.hideKeyboardWhenTappedAround()
    }
    
}

but I'm getting the following error:

Missing arguments for parameters 'options', 'isOpened' in call

for this line of code:

form +++ Section("About You")

and this error:

Binary operator '<<<' cannot be applied to operands of type 'Section' and 'TextRow'

for this line of code:

<<< TextRow() { row in

What am I doing wrong here?? Is Eureka outdated? It's like it's not recognizing that it's proper Eureka formatting. Is there a better form builder that will allow me to use expandable/collapsable sections with textfields and a date picker inside?


Solution

  • Eureka Swift 5 fix: Add Eureka. before Section

    form
        +++ Eureka.Section("mysection")
            <<< TextRow("myrow") {
                $0.title = "Title"
                $0.placeholder = "Placeholder"
                $0.value = "myvalue"
                $0.add(rule: RuleRequired())
                $0.validationOptions = .validatesOnChange
            }.cellUpdate { cell, row in
                if !row.isValid {
                    cell.titleLabel?.textColor = .systemRed
                }
            }