ortuman / SwiftForms

A small and lightweight library written in Swift that allows you to easily create forms.
MIT License
1.33k stars 209 forks source link

Swift4 version crash #160

Closed appsird closed 7 years ago

appsird commented 7 years ago

I compiled and ran your example, and all appeared to work.

Though, I continued to crash when running my loadform(), receiving exceptions. On closer inspection, I click on your project file in Xcode 9 beta3, and notice the Swift Language version was set to "unspecified". Though, I click each SwiftFormsApplication and SwiftForms targets and note these were set to use Swift4.

With the above setting, I then compile and see compile warnings and runtime errors. See images below. Note the error on line 136 of FormViewController.swift.

THis is the exact same place where I experience a crash when running in my application. Specifically if I set a cell.appearance, like:

    let row2 = FormRowDescriptor(tag: Static.subtitleTag, type: .text, title: "Subtitle")
    row2.configuration.cell.appearance = ["textField.placeholder" : "Classification" as AnyObject,
                                         "textField.textAlignment" : NSTextAlignment.right.rawValue as AnyObject]

Then, I will receive a crash on the line 136.

Appears there is something new in Swift4 regarding key/value changes which was not present in Swift 3.

Would appreciate any assistance. I can send you my modified project if you would like to take a look.

pic1 pic2

appsird commented 7 years ago

Here is a pic of the setting changed from unspecified to swift4

pic3

morgan-legal commented 7 years ago

Hello, I'm still having the issue after changing the swift language version to swift 4.0. Any ideas ?

appsird commented 7 years ago

The current Swift4 branch here has runtime problems as described above.

pod 'SwiftForms', :git => 'https://github.com/ortuman/SwiftForms.git', :branch => 'Swift4'

I'm currently running the standard Swift3 branch:

pod 'SwiftForms'

make certain to specify swift language version appropriately like described above.

I would still appreciate a fully functioning Swift4 version which does not experience runtime errors, which appear are related to new Key/Value handling in Swift4/Xcode9.

alexbartisro commented 7 years ago

Can confirm. Broken on swift 4.

ortuman commented 7 years ago

Current master version has been adapted to Swift4. Sorry for the issues.

appsird commented 7 years ago

Thanks Miguel.

On Oct 13, 2017, at 6:58 AM, Miguel Ángel Ortuño notifications@github.com wrote:

Current master version has been adapted to Swift4. Sorry for the issues.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

alexbartisro commented 7 years ago

Nope. Just updated in my project and the issue still reproduces.

appsird commented 7 years ago

I only now updated to the latest Swift4 release using the following in my Podfile:

I'm running Xcode Version 9.0 (9A235)

pod 'SwiftForms', :git => 'https://github.com/ortuman/SwiftForms.git', :branch => 'Swift4'

Upon running 'pod install' I received the status:

Using SwiftForms (1.7)

Running my application with this version yields an error on the same line. Prior the error was in purple, i.e. runtime error. Now the errors green.

untitled

alexbartisro commented 7 years ago

I'm using 1.7 from master not a specific branch and it's still fine. 1.8, the latest from master still crashes for me.

appsird commented 7 years ago

Miguel,

Appears your Swift4 branch is deprecated and changes are folded into the master branch. To avoid confusion, can the Swift4 branch be removed.

trusk89, I installed master branch 1.8.1 and ran without seeing any errors. Here's my setup;

iPhone5, iPhone7 Xcode 9.0.1 SwiftForms Pod Build Settings 'Swift Language Version' set to Swift 4 Podfile line: pod 'SwiftForms'

I'm not seeing any issues currently. Please match the above and see if you continue to have errors. I typically delete the Pods project and ancillary Pod folder in the project, quit out of Xcode, then 'pod update', then 'pod install. Then relaunch Xcode.

alexbartisro commented 7 years ago

@appsird nope, still crashes for me Installing SwiftForms 1.8.1 (was 1.7)

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SwiftForms.FormPickerCell 0x150063200> valueForUndefinedKey:]: this class is not key value coding-compliant for the key valueLabel.'
*** First throw call stack:
(0x186473d38 0x185988528 0x186473a00 0x186e1b864 0x186d61f70 0x186d92814  0x101721188 0x101721398 0x18fbb8474 0x18fbb89d8 0x18fb98670 0x18f953f10 0x18f880000 0x18a4510b4 0x18a455194 0x18a3c3f24 0x18a3ea340 0x18a3eb180 0x18641b8b8 0x186419270     0x18641982c 0x18633a2d8 0x1881cbf84 0x18f8e6880 0x1004130d8 0x185e5e56c)
libc++abi.dylib: terminating with uncaught exception of type NSException
appsird commented 7 years ago

seems you must be using a SwiftForm class that I may not use - and thus slipped through the cracks on Miguel's latest update.

I'm a little in the dark, and hopeful Miguel will chime in... Though, here's an approach:

A cursory glance shows I'm directly referencing the following SwiftForm classes:

FormViewController FormDescriptor FormRowDescriptor FormSectionDescriptor FormTextViewCell FormSliderCell

If you use one or more classes outside the above group group, you may want to try to comment out somehow and isolate the faulty class. Report back your results.

Painful I know, but that's all I have.

Brian

On Thu, Oct 19, 2017 at 11:51 AM, Alex Bartiș notifications@github.com wrote:

@appsird https://github.com/appsird nope, still crashes for me Installing SwiftForms 1.8.1 (was 1.7)

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SwiftForms.FormPickerCell 0x150063200> valueForUndefinedKey:]: this class is not key value coding-compliant for the key valueLabel.' *** First throw call stack: (0x186473d38 0x185988528 0x186473a00 0x186e1b864 0x186d61f70 0x186d92814 0x101721188 0x101721398 0x18fbb8474 0x18fbb89d8 0x18fb98670 0x18f953f10 0x18f880000 0x18a4510b4 0x18a455194 0x18a3c3f24 0x18a3ea340 0x18a3eb180 0x18641b8b8 0x186419270 0x18641982c 0x18633a2d8 0x1881cbf84 0x18f8e6880 0x1004130d8 0x185e5e56c) libc++abi.dylib: terminating with uncaught exception of type NSException

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ortuman/SwiftForms/issues/160#issuecomment-338002607, or mute the thread https://github.com/notifications/unsubscribe-auth/AIFFGUv7vmtylewkDROgS9L9I6Y2kKajks5st5oxgaJpZM4OTojY .

alexbartisro commented 7 years ago

Thanks for the feedback @appsird! I'll spend some time debugging this weekend.

ghost commented 6 years ago

@trusk89 Have you found the reason? I did have the same problem BUT not with the SwiftForm example.

alexbartisro commented 6 years ago

@appsird @gisngocthach I have time today. I've forked it and will look into fixing it and open a PR.

Fixed it in PR https://github.com/ortuman/SwiftForms/pull/169

Please review

abanet commented 5 years ago

I just get same error (FormViewController - line 136) after update SwiftForms to 1.8.2 version. I'm working with Xcode 10 and swift 4.2. The only way for me to keep working with SwiftForm: remove the 'titleLabel.font' key from
row.configuration.cell.appearance = ["textField.placeholder" : "Mandatory" as AnyObject, "textField.textAlignment" : NSTextAlignment.right.rawValue as AnyObject, "titleLabel.font": UIFont.boldSystemFont(ofSize: 15.0)] I don't have the font I'd like but it works!