Hot questions for Using Eureka in xcode

Question:

I implemented a new library into my project (named Eureka), and now I get errors when trying to upload to the App Store / TestFlight.

These include "Unsupported architectures", "Invalid segment alignment", and "The Binary is invalid.. This binary does not seem to have been built with Apple's linker".

I did not have any of these errors before implemented Eureka. I am running Xcode 7.3

I should note I installed the framework via Carthage.


Answer:

The problem was that Xcode precompiles the dynamic library for both the simulator (i386) and devices (x86_64). You can implement this run script to remove the unused architecture.

Question:

Specifically, from Eureka. I am trying to use this branch: https://github.com/xmartlabs/Eureka/tree/feature/Xcode9-Swift3_2 as the master branch is failing to build.

This was my Cartfile for the master: github "xmartlabs/Eureka" ~> 3.0.0

I have tried to specify the XCode9 (as that is what I am using) branch with: github "xmartlabs/Eureka" "/tree/feature/Xcode9-Swift3_2" , github "xmartlabs/Eureka" "/feature/Xcode9-Swift3_2", and github "xmartlabs/Eureka" "/Xcode9-Swift3_2".

At this point am just guessing.

Any help?


Answer:

You are almost there. No need for slash (/). Following should work:

github "xmartlabs/Eureka" "feature/Xcode9-Swift3_2"

Question:

I am using the swift form class Eureka to to build my form. On button submit I get my fields using form.values(). This gives me the following

let formvalues = form.values()

print(formvalues)

["field1":Optional(20), "field2": Optional("")]

I am trying to post the field names/values


Answer:

There is no guaranteed way to serialize a dictionary containing Any type values in it. Any can be any swift construct, including objects, structs, tuples, etc. There is no one-size-fits-all serialization that supports serializing any data type like that.

Now if you have a dictionary of type <String: String>, <String: Int>, or other fixed types, then you could use NSJSONSerialization to export it as JSON. You just need to stick to the types defined by JSON. You could also export it as XML or a plist file.

Question:

I have a Swift 3.2 application that I am preparing to upgrade to Swift 4 with. Over the last week Xcode got automatically upgrade and the Swift version has been changed to 3.3 with no option to move back to 3.2

This would be OK, however the Eureka pod fails with the following error

 type 'Section' does not conform to protocol 'RangeReplaceableCollection'

This is a error that occurred with previous versions of Eureka and specific 3.2 build was created to fix. The trunk build works on Swift 4. However both the trunk and 3.2 branches fail on 3.3

I can't upgrade to 4 until this error has been resolved. Is there a way to install a previous version of Swift, ie 3.2, on Xcode so that I can move beyond this.

all thoughts welcome


Answer:

Simply download the last version from Xcode that supports Swift 3.2 from your Apple Developer account at https://developer.apple.com/download/more/

Question:

I am trying to hide a row based on the value chosen in the ActionSheetRow before it .If the user picks they live in a cold climate I would like to hide or keep hidden the ActionSheetRow of where they would prefer to swim.

 func testForm(){
        form +++ Section("Test")
            <<< TextRow("Your Name"){
                $0.placeholder = "Enter Your Name"
        }
            <<< ActionSheetRow<String>("placeOfLiving") {
                $0.title = "Continent"
                $0.selectorTitle = "Where do you live?"
                $0.options = ["Antartica","Australia","Africa", "Asia", "Europe", "North America", "South America"]

        }
            <<< ActionSheetRow<String>("swimming") {
                $0.hidden = Condition.function([])
                { form in
                    if let section = form.rowBy(tag: "placeOfLiving") as? ActionSheetRow<String> {
                        if section.value == "Antartica" {
                            return true
                        }
                    }
                    return false
                }
                $0.title = "Swimming"
                $0.selectorTitle = "Where do you like to swim?"
                $0.options = ["Pool","Beach","Lake", "River"]

        }

    }

How would I go about checking the value of the ActionSheetRow and then hiding the following row? I have attempted different ways on how to do this check but cannot find a similar scenario. Any feedback welcomed


Answer:

You need to pass the tag of the rows that you want to check for values inside hidden function array as below.

$0.hidden = Condition.function(["rowTag"])

So, your code will become,

$0.hidden = Condition.function(["placeOfLiving"])
   { form in
      if let row = form.rowBy(tag: "placeOfLiving") as? ActionSheetRow<String> {
          return section.value == "Antartica"
       }
       return false
   }

Question:

Is there anyone else who is getting error during build process after Xcode upgraded to 10.1? I am trying whole night and day what's wrong and it seems like ImageRow is not compatible with newest Xcode?

Swift 4.2 Xcode 10.1 Eureka 4.3.0 ImageRow 3.1.0

Pod file:

platform :ios, '9.0'

target 'My cashflow' do
  use_frameworks!

  pod 'ImageRow', '~> 3.0'
end

And errors I get after compiling:

Errors:

Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey'

'UIImagePickerControllerSourceType' has been renamed to 'UIImagePickerController.SourceType'

Missing argument label 'rawValue:' in call

All pods installed and updated (Podfile.lock):

PODS:
  - Eureka (4.3.0)
  - ImageRow (3.1.0):
    - Eureka (~> 4.0)

DEPENDENCIES:
  - ImageRow (~> 3.0)

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - Eureka
    - ImageRow

SPEC CHECKSUMS:
  Eureka: 6d711cb30ca333b4bc893110285a722ae3840114
  ImageRow: 1ea483078bfa3d880a7fc76fdfcddfd5f29a9e6b

PODFILE CHECKSUM: 0bae1aabb456725a8d30797929aa85ea96da832c

COCOAPODS: 1.5.3

Answer:

Searching in the ImageRow known issues and you easily find the answer: https://github.com/EurekaCommunity/ImageRow/issues/51

For Swift 4.2 use the master branch. There is no release for that yet

So, in your Podfile, use:

pod 'ImageRow', :git => 'https://github.com/EurekaCommunity/ImageRow', :branch => 'master'

After pod update, your Podfile.lock will show the updated dependency as:

PODS:
  - Eureka (4.3.0)
  - ImageRow (3.1.0):
    - Eureka (~> 4.0)

DEPENDENCIES:
  - ImageRow (from `https://github.com/EurekaCommunity/ImageRow`, branch `master`)

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - Eureka

EXTERNAL SOURCES:
  ImageRow:
    :branch: master
    :git: https://github.com/EurekaCommunity/ImageRow

CHECKOUT OPTIONS:
  ImageRow:
    :commit: 6e75b9408bd3393daea467afa73c07cc021a87ae
    :git: https://github.com/EurekaCommunity/ImageRow

SPEC CHECKSUMS:
  Eureka: 6d711cb30ca333b4bc893110285a722ae3840114
  ImageRow: 1ea483078bfa3d880a7fc76fdfcddfd5f29a9e6b

PODFILE CHECKSUM: 0e94ba74cfd5e7ee8120ee7410f3045c8e2cbcfc

COCOAPODS: 1.5.3

And it will build fine in Xcode 10+.

Question:

I am attempting to have an ActionSheetRow, but I would like the options of this row to be based on the value selected on a different ActionSheetRow. I attempted on placing and if statement before the dependent ActionSheetRow but this did not work. I also attempted to add an if statement before setting the options and this also did not work. Is this something that is possible and if so how would I go about doing this?

Thank you all feed back welcome


Answer:

In your setup closure of the ActionSheetRow you get the row you want to switch on, see:

let row: RowOf<String>! = form.rowBy(tag: "Request")
let value = row.value ?? ""

if value == "1" {
  $0.options = ["A", "B"]
} else {
  $0.options = ["C", "D"]
}

That should work.

Question:

I am using the Eureka plugin for xcode swift and having an issue with the app crashing when selecting option "OTHER". It's supposed to have a TextRow below the date if "OTHER" is selected.

Error: Thread 1: Assertion failed: Duplicate tag segments

I'm pretty sure the issue is with <<< SegmentedRow<String>("segments"){ not being incremented "segments1", "segments2", etc... with each looped row. Also I do not know how I could make the $0.hidden line work if segments had to be incremented: $0.hidden = "$segments != 'OTHER'"

form
            +++ Section()

            for (index, date) in fdates.enumerated() {
                form.last!
                <<< SegmentedRow<String>("segments"){
                    $0.title = date
                    $0.options = ["FULL", "AM", "PM", "OTHER"]
                    $0.value = "FULL"
                    }.cellUpdate { cell, row in

                        cell.segmentedControl.setContentHuggingPriority(.defaultHigh, for: .horizontal)

                        if (self.type == "Lieu") {
                            cell.segmentedControl.setWidth(CGFloat(47), forSegmentAt: 0)
                            cell.segmentedControl.setWidth(CGFloat(40), forSegmentAt: 1)
                            cell.segmentedControl.setWidth(CGFloat(40), forSegmentAt: 2)
                            cell.segmentedControl.setWidth(CGFloat(57), forSegmentAt: 3)
                        }

                        //print(index)
                    }

                +++ Section(){
                    $0.tag = "other_\(index)"
                    $0.hidden = "$segments != 'OTHER'" 
                }
                <<< TextRow(){
                    $0.title = "This will be changed to a time picker after..."
                }
            }

** EDIT ** I managed to stop the crashing by using the index row with "segments" but the TextRow still doesn't show up when clicking "OTHER":

let tag = "segments\(index)"
<<< SegmentedRow<String>(tag){

+++ Section(){
    $0.tag = "other\(index)"
    $0.hidden = Condition(stringLiteral: "$segments\(index) != 'OTHER'")
}


Answer:

The author told me to move the form +++ Section() into the loop just before <<< SegmentedRow<String>(tag){ and this works.

for (index, date) in fdates.enumerated() {
    form +++ Section()
    let tag = "segments\(index)"
     <<< SegmentedRow<String>(tag){
         $0.title = date

Question:

When I use Eureka forms, Xcode seems to like to format it in a way that could cause confusion.

I'll use the one of the code blocks in the README as an example:

let row  = SwitchRow("SwitchRow") { row in      // initializer
    row.title = "The title"
    }.onChange { row in
        row.title = (row.value ?? false) ? "The title expands when on" : "The title"
        row.updateCell()
    }.cellSetup { cell, row in
        cell.backgroundColor = .lightGray
    }.cellUpdate { cell, row in
        cell.textLabel?.font = .italicSystemFont(ofSize: 18.0)
}

This really makes my OCD go off. The last } isn't inline with all the other ones feels so annoying.

I would like to format it like so:

let row  = SwitchRow("SwitchRow") { row in      // initializer
    row.title = "The title"
    }.onChange { row in
        row.title = (row.value ?? false) ? "The title expands when on" : "The title"
        row.updateCell()
    }.cellSetup { cell, row in
        cell.backgroundColor = .lightGray
    }.cellUpdate { cell, row in
        cell.textLabel?.font = .italicSystemFont(ofSize: 18.0)
    }

Or this:

let row  = SwitchRow("SwitchRow") { row in      // initializer
    row.title = "The title"
}.onChange { row in
    row.title = (row.value ?? false) ? "The title expands when on" : "The title"
    row.updateCell()
}.cellSetup { cell, row in
    cell.backgroundColor = .lightGray
}.cellUpdate { cell, row in
    cell.textLabel?.font = .italicSystemFont(ofSize: 18.0)
}

So I went to the preference pane of Xcode and looked for things like custom indentation. I thought there would be something similar to the formatting settings in IntelliJ, but I found nothing.

Then I found the closest thing to what I'm looking for - Automatic Indent. So I unchecked the checkbox for }, like the:

But as I type .onChange { then press enter, this happens:

    let row = SwitchRow("") {
        row in
        }.onChange {

    }

How can make it not automatically indent to that? I want one of the styles mentioned above.


Answer:

If you are willing to use the non-trailing syntax, i.e. with extra parentheses (which admittedly bloat the code a bit) the auto-indentation should work fine.

Your example code gets formatted to:

let row  = SwitchRow("SwitchRow", { row in      // initializer
    row.title = "The title"
}).onChange({ row in
    row.title = (row.value ?? false) ? "The title expands when on" : "The title"
    row.updateCell()
}).cellSetup({ cell, row in
    cell.backgroundColor = .lightGray
}).cellUpdate({ cell, row in
    cell.textLabel?.font = .italicSystemFont(ofSize: 18.0)
})