Assistant not opening the correct swift file

I am trying to open the swift file so that I can Ctrl + Drag from the image cell into the swift file that I generated.
The file was generated by New File -> Cocao Touch class, previously.
With the main.storyboard open and then choosing Assistant, I get the ViewController.h for the scene I am in and not the ExploreCell.swift file that I have just generated.
The book I am following as I am a beginner, says that I should set the file as automatic but I can't seem to be able to do that.
What am I doing wrong?

Accepted Reply

For the record I have sorted this out!
All you need to do is goto File menu/New/Editor.
I think everybody above was trying to make the problem too complicated, whereas the solution was so simple if you are an expert you do not think of the simplest solution, but overkill the question when it is staring you in the face.

Replies

If you have file editor on the left and storyboard on the right:
  • select the VC tou want in IB

  • click on the 3rd icon at top (the one with 4 small squares)

  • In the popup menu, on Automatic line, you have your VC

  • in Top level objects, you have the VC and another .h file

If you have only storyboard opened:
  • select the VC in IB

  • Assistant command should open the file.swift

  • if not, click on the link icon (2 small intertwined circles) which should probably say Top level objects

  • Then select Automatic in the popup menu.

I know how to open the file in IB that is not the problem!
By using the method you describe I now open the ExploreViewController.swift, but that is not the file I need to open.
In the book it says I need to open the ExploreCell.swift.
As I mentioned previously the ExploreCell.swift was created by creating a folder called View, as a sub folder of Explore and then creating a new Cocoa Touch file called ExploreCell.swift.
What it is actually doing is opening the top level view controller in the ExploreViewController scene.
I hope this makes sense as it is hard to explain.
With this information can anyone explain how I can open this Assistant view so that I can create the connection with the label button.
In this example, I have:
  • a xib for a cell

  • a Swift file, with the same name as the xib

I display xib in IB
I call Assistant
It opens directly the Swift file associated to the cell.

I change to display another cell xib
The right panel changes for the other file.

How are your xib and class and swift file named ?

In the book it says I need to open the ExploreCell.swift.

Seems you are not using a book fit for the latest Xcode. You should better find another book which matches the Xcode you are using.
Firstly, I have heard about xib files, but have never had to use them.
I have searched in Xcode but can't find how you open the xib files. I have looked through all of the tabs for Xcode.
The swift file name is ExploreCell.
Is the error caused by not doing something previously?

I have now researched Xib files and realise why I can't open one! I am using Storyboard not xib. (Cluade31)
The book I am learning from is: iOS 14 Programming for Beginners by Ahmad Sahar.
Please can someone as I am stuck with the example I am working oil an can't progress any further until I sort this out?

@Rocky48 

You are confusing a lot of things and you should probably start learning the basics of Interface Builder.

You can have storyboard(s) and xib.
For instance the storyboard for all the ViewControllers and additional xib for cells definitions or for other ViewControllers that you want to instantiate by yourself in code.

So, storyboard don't prevent having xib as well, but VC that are in storyboard have not an independent xib (at least not one directly visible in Xcode).

can't progress any further until I sort this out?

You would never be able to progress any more unless you accept that you cannot go exactly as written in the book.
Can you clarify what you have done with your storyboard?
You have added a prototype cell into a tableView and set ExploreCell to the Custom Class of it?
Or something else?

You have no need to use .xib, but one thing sure is that you need to do something else than in the book.

For the record I have sorted this out!
All you need to do is goto File menu/New/Editor.
I think everybody above was trying to make the problem too complicated, whereas the solution was so simple if you are an expert you do not think of the simplest solution, but overkill the question when it is staring you in the face.

I think everybody above was trying to make the problem too complicated, whereas the solution was so simple if you are an expert you do not think of the simplest solution, but overkill the question when it is staring you in the face.

Problem is also that some beginners do not follow the advices that are given:

If you have only storyboard opened:
select the VC in IB
Assistant command should open the file.swift

Assistant command means to everyone with minimal practice "the menu command". That was clearly not enough for you.

Have a good day.


I ran into the same problem, probably also in the same book. This worked for me: in the document outline I selected not the Cell, but some content of the Cell (Label, for example), and then I tried to open the Assistant. ViewController opened, but when you click the Automatic option above, two options are provided - click the Cell.swift and there you go. I hope this helps!