Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

˜this class is not key value coding-compliant for the key˜ when creating a new Target

I have a big base project for iOS done in Swift. Now I was trying to create different client version by creating a new Targets:

  • BaseProject (Works just fine, unless I change it's name)
  • Client1 (NSUnknownKeyException after launch screen).

The base project runs just fine. But I get the following NSUnknownKeyException when I switch for the new target:

Terminating app due to uncaught exception 'NSUnknownKeyException', 
reason: '[<UIViewController 0x135e57c40> setValue:forUndefinedKey:]: 
this class is not key value coding-compliant for the key textConfirmPassword.'

"textConfirmPassword" is a reference of a Text Field from my main.storyboard.

  • I checked Referencing outlets and that doesn't seem to be the problem.
  • I checked Target Membership of the Text Field.
  • I Recreated the outlet reference.
  • I deleted the reference, created a hard coded text field that doesn't appear on the storyboard just so the code would compile. The exception went to a different Text Field (textEmail).

Before doing all this, I created a sample project using an image and a referenced label. The versioning worked just fine.

like image 606
CFlux Avatar asked May 25 '16 15:05

CFlux


2 Answers

I found what was wrong. Something really simple that I can't believe it took me so long to figure out. The first view controller had a module selected (when it was not supposed to have any). For that reason, whenever I ran a different target it would not find the view's elements.

like image 146
CFlux Avatar answered Nov 16 '22 14:11

CFlux


I finally found the issue, for few view controllers in my storyboard->Identity Inspector->Inherit Module From Target wasn't selected that is why an error came in the newly created target.

enter image description here

Check "Inherit Module From Target" for view controllers

like image 4
Mohit Kumar Avatar answered Nov 16 '22 14:11

Mohit Kumar