Could not insert new outlet connection: Could not find any information for the class named
Here are some things that can fix this (in increasing order of difficulty):
- Clean the project (Product > Clean)
Manually paste in
@IBOutlet weak var viewName: UIView!
// or
@IBAction func viewTapped(_ sender: Any) { }and control drag to it. (Change type as needed.) Also see this.
Completely close Xcode and restart your project.
- Delete the Derived Data folder (Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.)
- Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)
Cannot add Outlet connection from Button to ViewController
I see the you have multiple ViewControllers in storyboard. Ideally, each View controller in the storyboard is supposed to be of only one type of UIViewController implementation and it's also true the other way around. so, If you have say 3 UIViewControllers in Your storyBoard, then you will need to create 3 .swift
files which implement UIViewController like so:
abcVC:UIViewController { .....
efgVC:UIViewController { .....
ViewController:UIViewController { ..... //this is the default one you get.
and then set the class of each ViewController in your storyboard to one of each of the above.
if your ViewController which has the button you want to outlet has a class type abcVC, then you can outlet your button only in abcVc
's implementation in abcVC.swift
.
Hope it makes sense. to see how to set class, refer @Vadim F. 's answer.
and if you happen to upvote this answer, please also consider upvoting @Vadim F. 's answer.
This is how you can crate a new .swift
file while subclassing a UIViewController: File -> new -> File -> Cocoa touch class -> #make it subclass of UIViewController and give it a unique name eg: abcVC
Why doesn't xcode let me create an IBOutlet
It is probably because you need to connect the storyboard vc to the file.
Click on the storyboard vc -> Click tab on right -> Enter name of view controller file into Class (Where it is highlighted in the image)
Related Topics
How to Push Two View Controllers But Animate Transition Only for the Second One
Firebase Dynamic Link Not Opening the App iOS
Change Font of Back Navigation Bar Button
Pod Error in Xcode "Id: Framework Not Found Pods"
Access the Instance of a Viewcontroller from Another in Swift
Spacing Between Uitableviewcells
Swift - Instantiating a Navigation Controller Without Storyboards in App Delegate
How to Zoom a Uiscrollview Inside of a Uicollectionviewcell
Cross Directional Uiscrollviews - How to Modify the Scrolling Behaviour
iOS Steps to Create Custom Uitableviewcell with Xib File
How to Get Uiviewcontroller of a Uiview's Superview in iOS
iOS 11 Uisearchbar in Uinavigationbar
Set Background Color of Active Tab Bar Item in Swift
Upload Multiple Images in Swift Using Alamofire
Repeating Local Notifications for Specific Days of Week (Swift 3 iOS 10)
Calculating Tiles to Display in a Maprect When "Over-Zoomed" Beyond the Overlay Tile Set