How to trace a fatal error with Xcode and Swift? - swift

I am trying to test a simple a program I have made while learning swift programming, but I always get a fatal error, and nothing will be shown.
I tried to copy my code to a playground, but there the custom classes I created are not recognized?

I found the error that one of the buttons is referencing the wrong outlet. This outlet was created by mistake, and it is name is the same as one of the Actions.

Related

swiftui Fatal error: attempting to create attribute with no subgraph

Hi whenever i run my ios app in the simulator i get the error Fatal error: attempting to create attribute with no subgraph: CachedView<KFImageRenderer, ImageBinder> (lldb) . however, the app seems to run fine in the preview. Does anyone know a fix for this issue?
In my case I had forgot to add the .environmentObejct(..) to the previews section. Also got it fixed by adding the environment to my preview.

App throwing error "This class is not key value coding-compliant for the key view." after a long time working well

I'm getting this error on a project i've been working on for a while : "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'" (it does with each of my outlets).
My app was working very well until I tried to bypass code-signing, and tried to do some Profiling with Instruments (I actually found out the error with Instruments).
(Additionnal info) I've built a subclass of UIViewController, with .h .m and .xib files, named EEMainViewController. I instantiate it in my EEAppDelegate to display it as a subview of my main window. In the .xib, I have 1 view, 3 UIPickers and 2 UITextField. As soon as only one of the outlets gets linked to the FO, the program exits and throws the error, and when none is linked, it says that the 'view' property has not been set (which is normal, since it's not connected).
I already checked all the IB and Bindings blahblah, and nothing seems to work in my case : all my outlets are connected properly (XCode is showing grey dots next to the #property in the .h file) and I'm instantiating the right classes in my code. It's pretty weird.
If you want a piece of code (only a piece, it's became really huge), feel free to ask me for some.
Thanks for reading !
I found a solution to my problem : I erased the EEMainViewController from my project (making sure all the outlets in my .xib were disconnected) and pasted the .h and .m content in a new class I created named EERootViewController, replacing all the occurrences of "EEMainViewController" by "EERootViewController" in my code. I rebuilt the .xib from scratch and connected as i was doing previously. Everything seems to work fine.
I don't know where the problem was coming from, unfortunately, so I guess we won't learn anything more about this case.
I still don't mark this thread as done, in case s.o finds the reason to the problem.
Sorry for bothering !

Error on empty project: "this class is not key value coding-compliant for the viewcontroller."

this error drives me crazy. I already spent hours on fixing this, unfortunately without success.
I tested my app in simulator, everything works fine. I'am testing it on my device (iphone 4 with ios 4.3.3) the app won't start.
So I tried creating a new project, build and go. And the end of the error now says instead of viewcontroller, key window.
To get further information about the error I setup an exeption breakpoint whicht breaks on throw and on all exeptions. Something interesting happend now: when I am launching the empty project on my iphone I get a warning:
warning: Unable to read symbols for /Users/xxx/Library/Developer/Xcode/DerivedData/testing-cmaekkzgdqyseidlqkorvrdvvodg/Build/Products/Debug-iphoneos/OLDAPP.app/testing (file not found). (The app which I am runnning is called testapp, not OLDAPP?! This was my last project!)
Some further errors now occure:
Unknown class OLDAPPAppDelegate in Interface Builder file. and Unknown class RootViewController in Interface Builder file.
I did clean all targets and made a clean build. Nothing changes…
I didn't change anything in IB, just edited the provisioning profile to run the app on my phone.
Help is very appreciated here :-) Hopefully someone can help me I would be really thankful.
The whole error message: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x18b410> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.'
This happens to me if I change the name of an outlet on the ViewController which was connected to something in the View in Interface Builder. For example, renaming 'labelFirstName' to 'lblFirstName' and forgetting to break and recreate the connection in IB.
I had the same problem where there were no !'s in my XIB and no re-naming problems. To fix it, I just created a new XIB, copied in the view from the old XIB, and rewired all the connections.

Issue with Duplicate symbol in link phase of project build in Xcode

I've been building a game application for iOS. The application was working fairly well, but I've done a fairly large restructure today to be a little more model-view-controller 'compliant'.
I've built the main game engine in C++, but use Objective-C for managing the viewControllers, views etc.
Now, when I compile the project, I'm getting an error in the link phase. Details are below:
ld: duplicate symbol ApplicationEngine::OnFingerUp(Vector2) in /Users/Dan/Library/Developer/Xcode/DerivedData/BlackHoles-exrlidtstxzdtsbyjghgquhlsqul/Build/Intermediates/BlackHoles.build/Debug-iphonesimulator/BlackHoles.build/Objects-normal/i386/ApplicationEngine.o and /Users/Dan/Library/Developer/Xcode/DerivedData/BlackHoles-exrlidtstxzdtsbyjghgquhlsqul/Build/Intermediates/BlackHoles.build/Debug-iphonesimulator/BlackHoles.build/Objects-normal/i386/AppDelegate.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 failed with exit code 1
OnFingerUp is a function within my C++ ApplicationEngine, and gets called from the viewController.
Is the problem likely to be caused by some confusion in my #includes / #imports?
My AppDelegate file needs to #include a MainViewController file to set up the initial viewController. The MainViewController in turn #includes the ApplicationEngine file to instantiate that class. ApplicationEngine contains the OnFingerUp method. The OnFingerUp method is then called from MainViewController when I get a touch input. Could this sequence of includes be causing the duplicate?
I've noticed that if I temporarily remove the OnFingerUp method from the app completely, then I get the same issue with another method within the ApplicationEngine.
There aren't any errors or warnings as the individual files compile. I've also tried to Clean All and recompile, but no joy.
Does anyone have any suggestions as to how I could approach solving the issue? Thanks, Dan.
I can think of 3 causes for this: 1) Accidentally #including a .cpp file, 2) forgetting #ifndef guards in the header file, 3) forgetting inline when writing the method definition in a header file.

IPhone App Build Successful But nothing shows

Very new to Iphone development here, I have a project which is successfully building (which is a first for me :) It loads the simulator but it just closes as soon as it loads, how can I debug this? It appears the Interface Builder xib files are not loading, I've added a xib thats from a hello world project, (they have different project names) Is this an issue?
Any advice would help,
Thanks!
You probably have an error in the Debugger Console. If it has to do with the XIB, it could be that you simply got the name wrong.
Another simple mistake is trying to use Outlets before viewDidLoad is called (for instance, in init).
In either case -- the message in the console will help.