-->

Could not insert new outlet connection [duplicate]

2019-01-07 06:39发布

问题:

This question already has an answer here:

  • Xcode 4: Creating a UIView xib, not properly connecting 32 answers

Could not insert new outlet connection: Could not find any information for the class and not showing any class named "ViewController"

Solutions I have done : - Restarted XCode - Restarted System - Deleted the Deriveddata contents from /Library/developer/xcode

But nothing worked for me

Here is the screenshot for the error

回答1:

I got the same problem as you today... I think this is a bug of Xcode, below is the way to fix the issue:

  1. Close the project you are working on with.
  2. Delete your project's【DerivedData】folder. (This folder may inside your project's folder, or inside ~/Library/Developer/Xcode/DerivedData/(your project)/ ) or somewhere else that was setup by you.
  3. restart your project.

After these steps, the problem should be solved. And from my experience, these steps can solve many Xcode problems, so if you got some problem with Xcode again, try these steps first.



回答2:

Removing(removing reference, not deleting) and then adding the appropriate file(the file of class you want to add the outlet to) is actually enough.

Edit 1 I found that after unchecking (in XCode 6.3.1) I had to wait a few seconds for the Indexing to appear and complete in the project name box. Same for the way backwards. This increased chances to fix the issue in almost all (but not all) cases.

Edit 2 Removing reference means that You do not delete the file completely but just remove it from the project (it still exist in the folder of your project, you add it later).



回答3:

That's most often a problem of file indexing.

To fix it try to clean your target and if this doesn't work, go to your Derived Datafolder and delete your application there. This will force xCode to reindex the files



回答4:

Just got the same issue on Xcode 4.6.2.
Tried solutions presented in different answers/comments, but it still didn't work.

Then all I did was to just:

  1. save all my work;
  2. just quit Xcode & load it again;
  3. then I was able to insert the new outlet connection successfully.

Hope this will save some time/frustration for somebody else.



回答5:

Personally, I had the same problem: "could not insert new outlet connection" AND when I was starting typing something like "UI..." XCode wasn't doing anything. I searched for answers, I tried several things... but it was just an unchecked box. When I was creating a new class, XCode unchecked the box linking the class to the project (I guess).

I can't post a screen shot because I don't have 10 reputations but when you create your class, XCode asks you where you want to save it. Down the finder window, you have 'Targets' and two boxes: 'YouProjectName' and 'YouProjectNameTests'. You should check the first one (at least).

Hope this will help. I saw different discussions about the subject.



回答6:

I recently came across this problem. I soon realized that the cause had been my own doing. I had previously disabled XCode indexing (which used to take forever & eat up my RAM), using the below code in a terminal window:

defaults write com.apple.dt.XCode IDEIndexDisable 1

To revert XCode to its default state, i used the following line in a terminal window:

defaults write com.apple.dt.XCode IDEIndexDisable 0

Voila! All's well again..



回答7:

If you've imported the Class into your Xcode Project you have to manually add the Class (.m file) to your 'Compile Sources'.

Select project icon > TARGETS > Build Phases > Compile Sources Click the + button and add your *.m file.



回答8:

Finally I did it by removing the xcode completely from my mac and reinstall the xocde.dmg file and then install MobileDevice.pkg and MobileDeviceDevelopment.pkg residing on /Applications/Xcode.app/Contents/Resources/Packages



回答9:

make sure that your source have had been included in the "Build Phases" place.

This do fix my problem. But I think Xcode is still really buggy and annoying.