Xcode 4.1 sudden strange compile behaviour after crash - iphone

I've suddenly got a very weird error in Xcode 4.1 that seems to have occurred after Xcode crashed.
I have some Model classes that inherit from a simple base class. Nothing unusual there.
What's happening now is that when I attempt to build for the "device" for one of these model classes that inherit (and only one) it throws a bunch of compile errors saying blah blah undeclared etc. Now if I switch it back to the simulator it builds and runs fine.
This was working perfectly well before the crash. I've done all of the usual clean build, delete derived data, restart XCode etc but still I can't make it work.
If I explicitly add the various bits from the base class into this problematic class it all works fine again.
I'm really perplexed. Any suggestions?
Thanks in advance,
Matt

You should try a "Product->Clean" and then recompile.
Sometimes Xcode doesn't seem to recognize changes made to files and gives weird errors and warnings.
Hope this helps.

If MrHus' clean doesn't work, Control-Click on your .xcodeproj and select Show Package Contents (Xcode projects are bundles). Remove everything but the project.pbxproj files; they may be corrupt.
If that doesn't work, try creating a whole new project from scratch. If that works, then your project.pbxproj was corrupt.

Related

Remote Swift Package: Xcode won't pause at this breakpoint because it has not been resolved [duplicate]

Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change their look and turn to dotted blue outlined. Xcode does not stop execution at these breakpoints although code has been compiled, loaded and executed. I checked it in Console by adding some prints.
When I hover over breakpoint Xcode shows a message:
Xcode won't pause at this breakpoint because it has not been resolved
Resolving it requires that:
The line at the breakpoint is compiled.
The compiler generates debug information that is not stripped out (check the Build Settings).
The library for the breakpoint is loaded.
All trivial solutions like reloading, reapplying breakpoints have not helped.
Did anybody else see something like this? Is there a way to solve it?
Screenshot for reference:
Ok, so in my particular case rebooting laptop has helped. All breakpoints are now good. But it would still be nice to know the cause of the problem.
Make sure that the file in which you are adding breakpoint is having correct target set in target membership.
Click on .m file in which you want to add breakpoint.
Select the file inspector.
Check if you have selected correct target for that file or not (check below image).
What worked for me, was to select the files, delete them with - Delete>Move To Trash - and then drag the files back from the trash to the project.
In my case the issue was happening, because class was not added to the target, which I was trying to build.
For my case somehow the code path was never invoked and very likely considered as dead code. The same thing applies when not adding the file to the target that you want to debug.
This can be the case or somehow debugger might not be able to resolve your breakpoint. The first thing in this case should be cleaning derived data and any caches.
But instead of recloning your repo you can just delete breakpoint config from the location described in this answer
In Xcode 14 the problem is much more prevalent and "consistent". I figured out one pattern where it always fails and how to mitigate it.
If you have a final class then breakpoints set on or inside a private method will have that issue. If you remove private from the method or final from the class the breakpoints will get resolved properly.
If tried everything and nothing worked I suggest the following:
Reclone your repo
This is what worked for me.
I just passed through this problem and the solution for me was recreating the files.
Note: The ones I was trying to originally breakpoint on were copied from another project. When I created the new files, even though their Identity and Type looked just the same (target membership, encoding, paths), for some reason breakpoints started to work again.
Note 2: When copying and pasting code to your new files (if done manually), migrated breakpoints - created in the older file - will continue to fail. Only the ones created in this new file will work properly.
Hope it helps.
My case
Working on framework development. Framework is injected into the sample app for development/run purpose. Breakpoints inside the framework won't work.
Fix
Just removing xcframework in sample app and replacing with framework.
Reason
xcframework are precompiled outside of the app, so lib isn't compiled when project is built and that's why breakpoints doesn't work.
For me reboot the Xcode, and it works~

Xcode8: Swift compile errors when my connected iPhone is the destination

When i run my program with the simulator it builds and runs with no errors. However when i change the destination to my connected iPhone, a whole bunch of swift compile errors are displayed:
Attempting to use the forward class 'UIViewController' as superclass of 'UIActivityViewController'
Attempting to use the forward class 'UIViewController' as superclass of 'UIAlertController'
a bunch of those, and then
Cannot define category for undefined class 'UIViewController' UINavigationController.h
and a bunch of these as well ...
I'm very new to Xcode and can't figure these errors out ...
Possibly your compiling towards different iOS versions on the device and the simulator. This may cause the compiler compiling towards different Swift versions.
I had the same problem. Solved it by cleaning the derived data.
Delete your DerivedData folder in ~/Library/Developer/Xcode/DerivedData.
But would also Clean the project and Reset Content and Settings.

xcode 6 symbol navigator shows each class twice

Looking at my project in the symbol navigator view, I noticed each class listed twice. They are identical, but the code runs fine, what is going on?
Even if Xcode 6 isn't in Beta anymore, there are still a lot of issues(Editor stops working etc.). In most cases these errors can be resolved by simply restarting Xcode.
If that doesn't help you, try to Clean your project: Product->Clean. Also you could clean Xcode manually by deleting all files inside ~/Library/Developer/Xcode/DerivedData

Does Xcode Always Compile from Scratch

I sometimes see that change I made shows up on third or 4th build run. It's as if xcode "cache" old compilation.
How to delete all compiled file and start from scratch
One thing that's particularly frustating is this:
I got a compile warning
for this code:
[self.currentBusiness addCategoriesObject:self.currentCategory];
I know what the problem. The automatically generated core data code do not have
- (void)addDistrictsObject:(District *)value;
- (void)addCategoriesObject:(Category *)value;
on Business.h. The function is defined in Business.m though.
So I added those 2 lines. Guess what, still the same warning. I had this exact same problem several time with no issue. I know the solution. I put the line right there in business.h. Nothing changes.
Yet now I get the same compiler warning even though the method is CLEARLY defined in business.h.
As if xcode do not care about the last change I put.
I am so frustated. I added #import "Business.h" again in my utilities.h. Shouldn't change anything given that "Business.h" is already included through other channel. Guess what, it works.
But then I thought, ah that's the problem. I curiously remove that //#import "Business.h" again so it's back like usual. If that's really the issue then the error should show up again right? Wrong.
The error is gone.
So changes I made do not show results right away. Either the compiler or the precompiler must use some sort of cache.
This is important. There are bugs that are introduced 2-3 builds before that I don't know how to debug. If code changes right after the first build after I make that change I know that something is wrong.
Also that autorestore doesn't seem to work. I create a snapshot, restore the snapshot into another directory and get lots of compile error.
NO, It only compile the file in which any kind of any editing took place.
Xcode does incremental builds. You can do a clean build by going to the Product menu item and select Clean (or press Shift+Cmd+K). That will delete all intermediate files and start from scratch.
Click xcode -> Empty Caches.
Here is a screenshot.

Can't make Xcode 4 run a barely empty project using SDK 4.2 (runs fine in 4.3)

I created a blank NavBar project and only touched a couple lines or so on one of the view controllers. I tested it fine in the 4.3 iPad and iPhone emulator but can't make it work for 4.2 at all. I get an error saying:
The selected run destination is not valid for this action.
This is what I have on my project settings:
Usually in XCode 3 that was all I needed to change but I guess I'm missing some setting in XCode 4.
What could this be?
#pokstad, you are right. I was looking at the wrong place indeed!
Choosing the target and changing the SDk there did the trick.
Thanks!
I really had troubles with this and none of the hints helped.
Finally I got an error message that pointed to an old file in the build folder, in the end a simple clean did resolve my issues (shift+cmd+K). It compiled fine. So remember to clean your current build after you changed the build settings in Xcode4.
This may be obvious, but at that moment it wasn't obvious to me.