Two view controllers have the same storyboard identifier - ios

As the title suggests I am getting the error that two view controllers have the same identifier but the problem is, they don't! I have checked through all my storyboards multiple times and never saw any with the identifier! The full error is
Two view controllers have the same storyboard identifier "IAC".
Not only that, but there are no storyboards with the identifier "IAC". Its possible I may have named one that a long time ago but their certainly aren't any now. I also just updated Xcode to the ios 7.1 SDK and it's possible that's part of the error. Does anyone know why?

In that case, press Command + Shift + F and then type the identifier that is being mentioned in the Warning / Error area.
Here after you search there will be list of matches, in that select Storyboard icons, and your answer lies there.

remove derive data from Xcode -> Prefrences -> Locations -> DerivedData and rerun the project

Have you already tried cleaning your project temp and caches files and restarting Xcode? Sometimes this simple step can solve problems like this.

I got same error in my application. I could not find any information regarding this in web.
I have cleaned and deleted derived data nothing could not help me.
After some time I found solution for this.
I have assigned one story board identifier to two view controllers in scene(where we can see entire views at one place) in my application. After some time I realised this error and solved it.
goto->storyboard scene->click on view controllers and observe the identity inspector in the control panel.
if you assigned the same story board identifier to 2 or more view controllers then remove it.
Delete viewController name which is assigned for 2 or more view controllers in the Identity inspector. I hope I am able to make everyone understand.

In that case, press Command + Shift + F and then search by type the identifier that (exam problem search by name "IAC")
you will see duplicate data after you see that you choose delete and build again.

Related

Why is my storyboard not working properly?

I am building an app right now and using storyboards for the user interface. Storyboards were working great until about a week ago. Suddenly, they began to give me trouble. I posted a couple of Stack Overflow question regarding issues about storyboards. I have been experiencing all of the following issues:
Actions connect as AnyObject instead of Any when connecting them from storyboard.
I receive an error unrecognized selector sent to instance 0x7fb80e92bc00 due to objects not connecting from storyboard to source code.
Unwind Segues do not work. When I try to connect one, it doesn't even show any available.
I cannot select any of my UIViewControllers from the dropdown menu under the Identity inspector which I discussed more about in this question.
Inherit module from target does not get automatically selected in Interface Builder.
Here are the following things I have tried:
Clean the build folder.
Restart Xcode.
Restart my MacBook.
Delete derived data.
Tried a different storyboard.
Deleted some of the files that were giving me trouble (which is no longer an option as all files are giving me trouble).
New issues pop up everyday and it is getting more difficult to build my app when these issues occur. Why is this happening and is there any solution available?
I am facing the same issue in Xcode beta version. It generally facing when create new file. I resolved by following steps
Remove File reference
Add file again. (If file add with "copy" suffix, delete original file from source folder remove "copy" from file name)
Now try to connect with your reference, it will work

Xcode going crazy! while coding, loses classes, references and doesn't autocomplete giving often <<error type>>

After I installed the latest version of xcode i'm having a very annoying issue.
While I'm coding, xcode goes nuts. Without me doing anything weird, just typing code, xcode stop recognizing classes.
For example: I want to add UITableViewDelegate to my class, but it doesnt recognize it. After i type it manually sometimes it recognize it and it is shown in purple, some other time it doesnt. But both times it won't really consider it, so if I try to write down a method of that delegate, it won't show it.
Other times if I try to call a variable of a certain class, while trying to autocompleting it, it shows <>.
Other times if I try to call any class, let's say I try to type var test = UIActionSheet, it just shows a few elements in the autocomplete list (raw types, primitives, the classes of my main project, but it doesn't show the majority of classes).
It's like it's missing the documentation and the link with the main frameworks...
I'm working on a simple tabbed app from yesterday and it's the 3rd time i started all over because of this issue, thinking that starting over would fix the issue, but it's not working.
If i open a different project while the issue is going on, the other project works ( but i recoded all over my app so it's not that one the issue, and i also have the same issue on other project... it just doesn't affect 2 project at the same time )
i tried deleting derived data
i tried restarting both xcode and the comp
What's going on?
Here are two screenshoots where you can see what's happening:
I had the same problem earlier.
Exit Xcode and delete Derived Data folder here ~/Library/Developer/Xcode
Restart Xcode and you should see the autocomplete working again.
You have to learn how to take it apart and put back together.
Either reinstall Xcode, if it doesn't help, create a new project.
Then copy source files one by one and see when it breaks.
Freshly install the XCode IDE version 6.1
Use CMD + F to find all _element.
Check that if you named one variable _element
The following code may reproduce the error:
class _element:NSObject {
}
let _element:UIImage = UIImage()
// type _element under this line

xcode 6 assistant editor Automatic results will not display

I can not drag anything to the code from the storyboard. Files were in assistant editor under automatic but now there gone how do i get them back other then deleting and recreating them? Opening them up under manual it will come up but Xcode can't find the referance when dragging to the code and i get the error when naming it.
I don't know if anyone else is still having this issue, but I get it a few times a week on Xcode 6.1.1 and I usually do the following to fix it (once I have checked that there are no class name mismatches):
Clean build
Delete Derived Data (using Organiser)
Force Quit Xcode
Re-open and Build
I know this is crazy, but it continues to work for me o_O
The most common cause is a mismatch between your class name and the name registered in the identity tab of the view controller. This will happen if you for example rename your class but don't update the classname in the storyboard.
To set/check the class name, open the storyboard and click on the leftmost icon in the titlebar of your UIViewController. Then open the identity inspector in the utility pane (right side) and double check the name given as the custom class.
The issue is due to not completion of indexing - so there are few alternatives, that you can try for-
Way 01 : Check if indexing is showing in processes - then let it complete. Then, close the editor and reopen it
Way 02 : Just perform the clean action. It will start showing appropriate Viewcontrollers.
Way 03 : This is the most effective way - Just perform "Build" and then restart editor - it will surely going to work.
I had the same problem, and I managed to solve it by selecting the correct Target on the File Inspector of both files (Swift and XIB in my case, you can check the file inspector in the storyboard).
It can happen if your project has a lot of targets (mine had a few, the file was checked on the wrong one).
You'll want to turn XCode indexing 'on' and set the Assistant editor to “Automatic”. This helped in my situation when the other suggested answers didn't. Details on turning on indexing at Stopping xcode from indexing
I just deleted build folder completely.And it works for me!

Xcode 6 GM, IB Challenge and Swift

I'm hoping someone can help me or even just let me know that I'm not going out of my mind. I have been searching for an answer to my issue for the past 4 hours and have tried many solutions, none seem to help.
My challenge is that I don't seem to be able to make use of a custom class for a view controller within the GM release of Xcode 6. Here is what I have done.
Begin a new project using File -> New -> Project, selected for an iOS
single view application to start. Once the initial application has
been created, it runs fine within the simulator.
Now I go into my ViewController.swift and change class
ViewController: UIViewController { to class ViewControllerxxx:
UIViewController {
Next, I go into my Main.Storyboard, select the View Controller and
drop down the custom list class where I do not see my custom class.
Now here is where is gets strange.
If I open a project that was created on an earlier beta build of Xcode, the above process works just fine and I see my custom class, just not with newly created projects.
Does anyone else see this behavior, or is it just me?
Hoping someone can shed some light for me...
BTW - manually defining the custom class name doesn't work either - I get a runtime error saying the class is unknown.
Many thanks in advance,
Jon
It would appear that I have fixed it although I have no idea how or why. Basically all of my projects are stored in a folder \Users\jon\code. I renamed the code folder to code.old and then back to code again and for whatever reason, it works now without an issue. I have zero idea as to what caused this issue as nothing in the folder has changed, but the issue is certainly resolved, or at least it appears to be.
So to anyone else experiencing this issue. First try creating a project in a location different to where you are when experiencing the problem. For example, if you are creating your project in Documents, try creating it in the root of your home folder.
If this works, drop to a terminal and using the mv command, rename your projects folder to something else and then back again. After this, I was able to create as many new projects as I wanted, an none had the issue.
Hope this helps someone...

Xcode changes unmodified storyboard and XIB files

Storyboards are rather a royal pain from a git workflow perspective when multiple people are collaborating on them. For example, the XML in the .storyboard file has its starting <document> tag's toolsVersion and systemVersion attributes altered by whatever configuration the most recent file manipulator happens to be running. Synchronizing everybody's Xcode versions precisely seems to help with toolsVersion, but systemVersion changes no matter what, depending on the specific Mac and/or OS X version the developer is running.
This is idiotic, but mostly harmless. What worries us, though, is that at other times some other changes are automatically made to the storyboard just by opening them after a git pull. That is to say, Alice makes changes to a storyboard, commits and pushes them to the repository. Bob then pulls Alice's changes and opens up the storyboard to make further changes. The moment he opens the storyboard, the file icon immediately changes to a modified-but-unsaved state, and a git status shows that any number of weird changes have occurred. All this without Bob having changed anything or saved the file himself.
The most common automated change we're seeing is the disappearance or reappearance of the entire <classes> tag hierachy near the end of a storyboard file. We haven't figured out what is causing this. We may have several localized versions of a storyboard in various .lproj directories, and when opening them inside Interface Builder, the class hierarchy may spontaneously be removed from some and added into others, or left alone in some. This causes a lot of noise in git diff, but it doesn't actually break any functionality. We will often selectively add the actual changes we made into git's index, commit those, and then just discard the spontaneous, nonsensical <classes> changes. This is to keep commits small and nice, as they should be. Eventually, though, it just becomes too much to bother with since Xcode keeps re-doing the changes, and someone just ragecommits them along with some other stuff... which is fine until someone else's Xcode decides to want to change them back for no apparent reason. (Our commit history has a lot of swearing over this.)
Is anyone else seeing this behaviour? Is this an Xcode bug or a configuration issue on one or more of our developer Macs? We've seen some similar behaviour when collaborating with XIB files, but storyboards seem more susceptible to this.
This is not a bug, this is a consequence of how Xcode processes storyboard files.
I am writing a diff and merge program for storyboard files (GitHub link) and I have spent hours analyzing the storyboard files logic and how Xcode processes it. This is what I discovered:
Why do weird changes occur in storyboard files?
Xcode uses the NSXML API to parse storyboard files into some NSSet-based logical tree structure. When Xcode needs to write changes it creates an NSXMLDocument based on the logical tree structure, clears the storyboard file and calls XMLDataWithOptions: to fill the file again. Because sets do not preserve the order of their elements, even the slightest modification could change the whole storyboard XML file.
Why does the class tag disappear or reappear randomly?
The <class> section is nothing more than an internal Xcode cache. Xcode use it to cache information about classes. The cache changes often. Elements are added when class .h/.m files are opened and removed when Xcode suspects they are outdated (at least older Xcodes behave like this). When you save the storyboard, the current version of the cache is dumped, which is why the <class> section often changes or even disappears.
I have not reverse-engineered Xcode; I made these observations by experimenting with Xcode and storyboard files. Nevertheless, I am almost 100% sure it works this way.
Conclusions:
Cache section is unimportant; you can safely ignore any change in it.
Contrary to what you can find on all forums, merging storyboards files is not a complicated task. For example, let’s assume you changed MyController1 view controller in a storyboard document. Open the storyboard file, and find something like this
<viewController id=”ory-XY-OBM” sceneMemberID=”MyController1”>.
You can safely commit only changes in this section and ignore everything else. If you changed segues or constraints, also commit anything that has “ory-XY-OBM” inside. Simple!
This is a bug in XCode 4.5+, I hope it gets fixed, and yes its a PITA.
Here's the full bug at Apple
How to avoid Xcode gratuitous edits to storyboard files?
This issue can be mitigated somewhat by extremely judicious use of git add -p on any of Xcode's generated files, including storyboards, XIBs, Core Data models, and project files, all of which suffer from similar transient modifications that have no impact on the actual interface/model/project.
The most common junk changes I've seen on storyboards are the system version numbers (as you mention) and the constant addition and removal of the <classes> section, the omission of which I have never seen cause problems. For XIBs, it's the addition and removal of <reference key="NSWindow"/>, which isn't even a class in Cocoa Touch. Just wow.
Think of it like the sea: there is both a high and low tide. Let it wash over you.
Ahh. That's it.
You can ignore these modifications when staging your changes, reset the junk changes, and make a clean commit.
The single advantage I've seen with storyboards over XIBs from a technical standpoint is that Apple has not yet neutered FileMerge to refuse to merge conflicted storyboards. (FileMerge used to be able to merge XIBs, but newer versions broke that. Thxxxx guys 💜!!!)
Please file lots of bugs about all of these problems at http://bugreporter.apple.com/! And don't forget to create entries on OpenRadar.
Throwing on another answer here because this situation has improved greatly. The XML for the XIB file that represents the StoryBoard has been greatly simplified.
I have also recently bitten the bullet and started to use the interface in Xcode to Source Control. I have been on the command line for years and happy there, but the interface is nice and it lets you split commits, which is really important if you use a ticketing system that links to commits.
Anyway, I noticed today that there was a change on the storyboard and the built in diff showed me it was a single attribute in the document tag (systemVersion). So not a big deal.
I have read articles where people say SBs were outlawed on their teams because of merging issues. Total madness. They are so amazing, especially now that they have intelligent autolayout built in, you are really missing out if you are not using them.
It's helpful to know why this insanity is happening, but for those who believe in keeping their projects free of warnings and who just want a quick-and-dirty to get their projects back to a healthy state:
Don't commit anything until explicitly instructed.
Open Xcode and create a new storyboard (Command+N > iOS > User Interface > Storyboard). I'll assume you call it the default name of Storyboard.storyboard.
Open the storyboard that Xcode has violated. I'll assume this is Base.lproj/Main.storyboard.
Select and copy everything on the storyboard (Command+A then Command+C).
Open Storyboard.storyboard.
Copy and paste everything into Storyboard.storyboard.
Close Xcode.
Open a terminal and change directories to your repository.
Replace Main.storyboard with Storyboard.storyboard (mv Storyboard.storyboard Base.lproj/Main.storyboard).
git add Base.lproj/Main.storyboard; git commit -m "Fix Xcode's insanity."
Disregard the changes to project.pbxproj via git checkout -- project.pbxproj. If you git diff the file, you'll see that it has just added information about our temporary storyboard (which no longer exists).
Open Xcode back up and see that the warnings has disappeared.
Breathe.
Working on same storyboard is not a problem. But working on same viewcontroller which creates conflicts on pull/merge is frightening. we can not really avoid that working in same viewcontroller for a large team.
Good thing is, most of the time we can fixed the same viewcontroller conflicts if we understand the xml structure. I never failed to merge these while working in team. Suppose you are working with a viewcontroller. Your view is blank currently. Please ,have a look at the viewcontroller's xml structure from source code option.
Storyboard is xml bounded by document type tag. Everything in the storyboard contains in scene sceneID= tag. scene tag holds every viewcontrollers. Thats the basic.
Now we added a UILabel and a UIButton on the view. Also set the autolayout of the elements. Now it's looks like :
Adding a level/button to viewcontroller added some new code inside the subview tag of the view. Same thing will go for further element addition or any UI changes. Carefully check the tag structure which is really important to fix any conflicts.
Now we add another viewcontroller in the storyboard name Homeviewcontroller. Adding a new viewcontroller means it adds a new scene under scenes tag. Look at this:
At this point, we will change the structure randomly and observe the issues/warnings. We change first viewcontroller label end tag and save the file. Now run it and look at the warning. Error says end tag is not correct which created from line 23. In line 23 , we see a label constrains is set with no end tag. That's the problem. Now we put the end tag and build the project. After setting end tag, we can view the storyboard successfully.
When face any warning of conflicts , please compare with your previous source and changes source. We remove the old/redundant code , keep the new code with proper tag start-end and get things fixed.
[N.B , i will update the answer with some more test cases when get times]

Resources