XCode 7.2: Undefined Symbols for UIKit

I upgraded to XCode 7.2 and I can no longer compile my project. I'm getting a bunch of "Undefined Symbols", but these are all UIKit items (UIFont... seriously?).


The errors are being thrown during the Linking Phase. Specifically, the errors show up under `Merge <projectName>.swiftmodule` task.


I've tried cleaning the project, cleaning the build folder, deleting derived data, deleting and reinstalling Xcode, deleting everything under `~/Libarary/Developer/Xcode`. Nothing works.


The errors only occur under certain files. Not all files where I use these symbols are showing the error.


All of this compiled correctly under XCode 7.1.


Anyone have any ideas what's going on?



undef: _OBJC_CLASS_$_NSTextContainer
undef: _OBJC_CLASS_$_NSLayoutManager
undef: _NSLinkAttributeName
undef: _NSParagraphStyleAttributeName
undef: _NSForegroundColorAttributeName
undef: _NSHTMLTextDocumentType
undef: _OBJC_CLASS_$_NSTextStorage
undef: _OBJC_CLASS_$_NSTextAttachment
undef: _NSBackgroundColorAttributeName
undef: _NSDocumentTypeDocumentAttribute
undef: _NSBaselineOffsetAttributeName
undef: _OBJC_CLASS_$_NSMutableParagraphStyle
undef: _OBJC_CLASS_$_UIFont
undef: _NSFontAttributeName

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSTextContainer", referenced from:
      objc-class-ref in libTTTAttributedLabel.a(TTTAttributedLabel.o)
  "_OBJC_CLASS_$_NSLayoutManager", referenced from:
      objc-class-ref in libTTTAttributedLabel.a(TTTAttributedLabel.o)
  "_NSLinkAttributeName", referenced from:
      oDeskMessenger.attributedTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
      oDeskMessenger.attributedAltTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
      -[TTTAttributedLabel drawFramesetter:attributedString:textRange:inRect:context:] in libTTTAttributedLabel.a(TTTAttributedLabel.o)
      -[TTTAttributedLabel setText:] in libTTTAttributedLabel.a(TTTAttributedLabel.o)
  "_NSParagraphStyleAttributeName", referenced from:
      +[ODMEmptySceneView emptySceneWithTitle:description:icon:] in ODMEmptySceneView.o
      oDeskMessenger.attributedTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
      oDeskMessenger.attributedAltTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
      _FBSDKTextSize in libFacebook-iOS-SDK.a(FBSDKButton.o)
      -[SLKTypingIndicatorView attributedString] in libSlackTextViewController.a(SLKTypingIndicatorView.o)
  "_NSForegroundColorAttributeName", referenced from:
      -[ODMApplicantInfoCollectionViewCell locationAttributedTextWithCity:country:timezone:] in ODMApplicantInfoCollectionViewCell.o
      -[ODMApplicantsCardView carousel:viewForItemAtIndex:reusingView:] in ODMApplicantsCardView.o
      -[ODMApplicantsViewController optionAtIndex:] in ODMApplicantsViewController.o
      -[ODMAvatarView textAttributes] in ODMAvatarView.o
      -[ODMAvatarView setTextAttributes:] in ODMAvatarView.o
      -[ODMInvitation htmlLetter] in ODMInvitation.o
      -[ODMApplicationReceiptViewController viewDidLoad] in ODMApplicationReceiptViewController.o
      ...
  "_NSHTMLTextDocumentType", referenced from:
      -[ODMInvitation htmlLetter] in ODMInvitation.o
      -[ODMPost htmlBody] in ODMPost.o
  "_OBJC_CLASS_$_NSTextStorage", referenced from:
      objc-class-ref in libTTTAttributedLabel.a(TTTAttributedLabel.o)
  "_OBJC_CLASS_$_NSTextAttachment", referenced from:
      objc-class-ref in ODMApplicantInfoCollectionViewCell.o
  "_NSBackgroundColorAttributeName", referenced from:
      -[ODMConversationViewController tableView:didSelectRowAtIndexPath:] in ODMConversationViewController.o
      -[ODMConversationViewController textView:shouldChangeTextInRange:replacementText:] in ODMConversationViewController.o
      oDeskMessenger.attributedTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
      oDeskMessenger.attributedAltTextForDashMessage (Swift.String, attributes : [DashTransportLayer.MessageAttribute]) -> __ObjC.NSAttributedString in DashMessageAdapter.o
  "_NSDocumentTypeDocumentAttribute", referenced from:
      -[ODMInvitation htmlLetter] in ODMInvitation.o
      -[ODMPost htmlBody] in ODMPost.o
  "_NSBaselineOffsetAttributeName", referenced from:
      -[ODMApplicantInfoCollectionViewCell locationAttributedTextWithCity:country:timezone:] in ODMApplicantInfoCollectionViewCell.o
  "_OBJC_CLASS_$_NSMutableParagraphStyle", referenced from:
      objc-class-ref in ODMEmptySceneView.o
      type metadata accessor for __ObjC.NSMutableParagraphStyle in DashMessageAdapter.o
  "_OBJC_CLASS_$_UIFont", referenced from:
      objc-class-ref in ODMButton.o
      type metadata accessor for __ObjC.UIFont in MilestoneTableViewCell.o
  "_NSFontAttributeName", referenced from:
      -[ODMApplicantInfoCollectionViewCell locationAttributedTextWithCity:country:timezone:] in ODMApplicantInfoCollectionViewCell.o
      -[ODMInvitationHeaderClientPurchasesView setInvitation:] in ODMInvitationHeaderClientPurchasesView.o
      -[ODMApplicantsCardView carousel:viewForItemAtIndex:reusingView:] in ODMApplicantsCardView.o
      -[SVProgressHUD updatePosition] in SVProgressHUD.o
      -[ODMApplicantsViewController updateTitleWithUpArrow:] in ODMApplicantsViewController.o
      -[ODMApplicantsViewController optionAtIndex:] in ODMApplicantsViewController.o
      -[ODMAvatarView textAttributes] in ODMAvatarView.o
Answered by ahayman in 98095022

I figured out the core problem. I believe that reinstalling Xcode and certain components would fix the problem. But eventually, I'd switch to a branch that would cause the problem again, and I'd have to reinstall Xcode or Command Line tools in order to fix (even deleting derived data didn't seem to work). In the branch that was causing the problem, I had created a new module I called `UIFoundation`. I was pushing common components into that module (shared across multiple projects). Since we have `Foundation` and `UIKit`, I figured `UIFoundation` would be safe. I was wrong. Apple must use this name internally because simply adding a module with that name to the project caused it to fail when linking. Renaming the module to something else fixed the problem completely.

Using Unity?

Accepted Answer

I figured out the core problem. I believe that reinstalling Xcode and certain components would fix the problem. But eventually, I'd switch to a branch that would cause the problem again, and I'd have to reinstall Xcode or Command Line tools in order to fix (even deleting derived data didn't seem to work). In the branch that was causing the problem, I had created a new module I called `UIFoundation`. I was pushing common components into that module (shared across multiple projects). Since we have `Foundation` and `UIKit`, I figured `UIFoundation` would be safe. I was wrong. Apple must use this name internally because simply adding a module with that name to the project caused it to fail when linking. Renaming the module to something else fixed the problem completely.

Good info, thanks for the followup.

XCode 7.2: Undefined Symbols for UIKit
 
 
Q