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

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

Related

Transferring Xcode Project from one computer to another brings random errors?

I have a Xcode project I got from another developer. Initially when I opened it it has a bunch of errors (most of which were un-updated frameworks). I got it to work after a while and I fixed it. I want pass it back to the manager since I'm leaving uni in a few months. I copied it over to my friends Mac to see what would happen if I just took the project and all it's folders and made it a zipfile. It didn't work for some reason. It gave me an error:
error: using bridging headers with framework targets is unsupported
But why did that come up? I mean it's the same code on the slightly different versions of Xcode (13.1 versos 14.1) but I doubt there was a massive change between the two that would cause this. I want to be able to pass these app later in the future without having to care about this stuff. I made a GitHub (link below) would cloning that work? Also the laptop I chose was just a fresh reset. Would it be due to not having coco-pods installed?
I feel like I could go through and fix it all on that laptop and document that but then I'm afraid that every time I put it on a new one it would come up with random errors every single time making my documentation moot.
https://github.com/AbdullahMSaid/SonicExperiment-Works
With big help this was Fixed.
Things that fixed it.
Having the correct version of Xcode
Turning everything from absolute path to relative
Lots of other code fixes. But those are my project specific.
You don't need bridging headers in framework. Use should have something like "YourFramework.h" where you can import your .h files.

Including a Playground in my project

I'm working in Xcode 9 on a Swift project, and I'm in table flipping mode with this.
Here's my end goal: put my tests next to my logic in a playground so that as I write the logic, I can see the tests pass in close to real time.
I will also accept how to put my tests in a playground by themselves, I just don't want to be running tests on a simulator for every little thing.
My problems in trying to get this to work are many. First and foremost, I can't find a way to add a playground directly to my project/workspace. When I right click on a group in the project navigator and select 'New file...' I get this:
As you can see, no option for playground. Filtering also returns no results. If I press the plus button at the bottom of the project navigator, the same dialog (with no playground option) pops up.
I thought it's in another menu so I went to the File menu, and in "New >" I find an option for creating a playground. I select a blank playground from the chooser, choose where to save it (strange that it wanted to save it under 'Unsaved Xcode Documents') and a basic playground comes up in a new tab. Odd thing I notice, though, is that there's no longer a play button or scheme/simulator selector at the top on this tab.
It now doesn't recognize ANY modules other than Apple provided ones! And sure enough, creating the playground didn't actually add it to my workspace. I guess I have to manually add it to my project. Upon doing so, it will recognize my pods but none of my project files! Any class I try to use gives me an Unrecognized identifier. Trying to import my project doesn't work either, it just gives me a No module.
I tried clearing DerivedData, I tried cleaning, I tried restarting Xcode, I even made sure I had an iPad Pro in the list of simulators (since that seems to matter for some people).
In frustration, I deleted the playground, and resolved just to deal with running my tests constantly. But now, my project has persistent errors! Despite moving the playground to the trash, Swift continues to error saying 'Unresolved identifier' for that playground!
As the excellent Brandon Williams says in his talk at FrenchKit, a playground "does not get access to anything in the application target." Which is ridiculous, but hey, what are you gonna do. So the answer is: there is currently no way to do this the way I asked.
It IS possible, however, to achieve this functionality if your logic is in its own framework/cocoapod. That is, move the logic you want to test out of your app target and into an outside library that your app, subsequently, imports. This will allow your playground to import it as well, and you can test to your heart's content.

Xcode 7 crash every time I try to print something in the debugger console

I've searched around and can't find anything on this.
Using Swift 2 and Xcode Version 7.0.1 (7A1001). Every time I execute something in the debugger console, Xcode crashes.
The project is not very big, and has less than 10 third party frameworks.
I can't think of much more information that's relevant, but I'm sure there's more, so please do ask me if there's anything I should add to my question that would help.
I've of course cleaned build and derived data.
It's driving me insane. Thanks!
UPDATE 16/11/12
Submitted rdar://23559366.
How are you maintaining your third party frameworks? Via Carthage?
If so then this is probably your issue: https://github.com/Carthage/Carthage/issues/924
This is an issue if the location of the /Carthage/Build/iOS folder is in a different location to where it was produced (i.e if it was compiled on a different machine and the absolute file path has changed).
A temporary fix would be to run carthage build --no-use-binaries on your machine to rebuild the symbols using the current absolute file path working around the bug.
But if you wasn't using carthage then its probably not your issue so sorry
I had similar problem with Xcode whenever I hit breakpoint.
In case you see this screen right before your Xcode crashes - you are lucky and my fix might save you. All you need to do is open this window and in the Project Navigator, select any file that you want, so that instead of that white blank view you would get your code. After this you are most likely will be able to successfully stop your app at your breakpoint and perform the debug.
I am not sure why this happens, but I suspect that the reason is Debug View Hierarchy mode, which you might have triggered prior to setting you breakpoint and trying to stop at it. At least this is when it happens to me.
I have similar problem earlier.
If you try to print non-optional variable and unfortunately it holds nil value then it breaks/crash. so that make sure declare all possible variables as "Optional type".

XCode 6.3 autocomplete not working

I'm learning basics of Objective-C and using XCode for writing code.
As you all know autocomplete option is perfect for new users that don't know (or remember) name of functions.
I have a problem with using autocomplete in XCode 6.3 couse its just.. not working - it is not showing anything or showing things that are not connected.
For example I just wrote simple few lines of code gusing NSMutableArray and NSEnumerator, when I'm trying to remind myself function/message 'nextObject' of NSEnumerator, XCode is not suggesting anything.
Here is a pic to show it:
Am I doing sth wrong or there is a way to fix it?
thanks in advance!
It must be a temporary glitch. Happens to me almost all the time while Xcode is "indexing". You might be typing too fast and by the time Xcode gives indexing a break and looks for the auto-completion you might have types something for which there is no method (or something that you expected)
Also, for custom classes & method, make sure you have included the respective header files.
It seems that autocomplete does not work when there is an error in the code.
The reason for autoComplete not working can be anything. Do any one of the following to debug it
Check if there are errors and if so try to solve it and then check autoComplete. If any error is present in any of the line then autoComplete will not work for below code. Try autoComplete above the error incase you want to check.
If debugger does not throw any error then try commenting out the all lines and uncomment it from top to methods to recheck the autoComplete
Quit Xcode and Reopen it
Clear Derived data and then launch Xcode and check

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...

Resources