During a marathon session yesterday (from 7 am until past midnight), I suddenly ran into an issue where, immediately after launching the app in the simulator, button taps with prints to the console and swipes on views wouldn't result in any change for about 15 seconds. Eventually (10 - 15 seconds) the console output appears, the views swipe and it seems normal again.
I am using Xcode version 12.5 (12E262) on Big Sur 11.2.3
I have looked at these, and countless others:
iPhone Simulator suddenly started running very slow
Xcode freezes on startup while loading project
I removed the project's folder from Derived Data, I confirmed "Slow Animations" is not checked. I did not remove "xcuserdata" folder. I just don't know where to turn to debug this issue. Has anyone seen this behavior? Did I stutter and hit a key combination (Triple tap on Shift and CMD-T both used to toggle slow animations I've learned)? I feel like I've added code that is triggering this, but I can't be sure. I had spent the entire day refactoring my project to reduce the Objective-C and UIKit code and make better use of Composable Architecture (TCA). If people suggest debug steps I could perform I'll try them out and report back. I just don't know how to continue debugging this issue.
Backups from before the day's changes do not exhibit this behavior. I copied the project to a new directory and replaced all source code with the backed up source code. And that works fine. So I can lose the work from 3 pm to midnight last night or suffer through this until I have disk space to install 12.5.1
Any insights would be most welcome
So I ran a timer profile -- see this awesome article:
https://www.avanderlee.com/debugging/xcode-instruments-time-profiler/
I came up with this:
Which led to this:
And I understood where I introduced the problem:
var selectedNibIndex: Int = 0 {
didSet {
brush = WDBrush.from(index: selectedNibIndex)!
cameoImage = BrushStrokeImageView(paintBrush: brush)
dictionary = brush.wdPropertiesDictionary() as! [String: WDProperty]
}
}
this is new code, and it is placed inside a struct which is constantly being rebuilt.
I will move it out of there.
**
I guess the answer to my question is to run the app under the time
profiler and let it tell you where the problem is.
**
And marathon sessions aren't always a good idea. I would have caught the problem sooner if I hadn't bitten off such a big task. There was a two hour period where it wouldn't compile and I shouldn't have let that happen. By the time I got it to compile after some changes I had changed so many things I could no longer see the forest for the trees.
I hope this can help others, thanks for reading!
Related
I was playing around with the Playground feature of Xcode 6's first beta - and I notice half the time the Playground doesn't update (simply doesn't display the result calculation or how many loop iterations are happening) simple code/loops/functions that are in there. Even the Swift Tour https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html
has several lines of code that don't show up in Playground. If you mess with the code sometimes it will show up, by moving the code around or placing it elsewhere. Anyone else? Any fixes? Is this just a beta problem?
Make sure you haven't inadvertently added an error to your Playground code. Unfortunately, there is no inline notification of an error, and after an error is created, nothing in the Playground will update.
To help with this, open up the Assistant Editor (File > View > Assistant Editor > Show Assistant Editor), which should include a Console Output box. If there are any errors in your Playground, they will show up there. Once corrected, your Playground should hopefully update once more.
That said, it can be a bit slow depending on the complexity of your Playground and its size.
This answer (Undeclared Type 'NSView' in Playground) did it for me (restarting Xcode and the machine didn't help):
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
Had the same strange errors after upgrading to xcode 6 beta 6. For me the problem got fixed with a Product -> Clean. And if that does not fix the errors hold down option key and click again on Product in the Menubar then you will see in the dropdown menu Clean Build Folder... click on that. Or you could download Watchdog app from appstore. This little helper automatically cleans your xcode projects.
You have to be very careful with swift. the language is very case sensitive so while using playground make sure all things are spaced out.
The following code will NOT give you a syntax error but it will stop processing the rest of your code in playground :
for index in 1...5 {
if index %2 !=0{
continue
}
println(index)
}
The error in the code above is in line 2. The code has to be written
for index in 1...5 {
if index % 2 != 0 {
continue
}
println(index)
}
Hope that answers your question :)
When I "run" my app from XCode the simulator comes up and the app attempts to run, it animates to a black screen for a second and then the app closes immediately.
The app was running fine before and now suddenly won't work.
There is no output on the console, no errors or anything and the app isn't crashing (as far as I can tell).
I have tried deleting all my user specific files in the xcodeproj package, but this hasn't changed anything.
Is there any other reason why this would happen? How do I fix this?
Thank you.
ADDITION: NSLog(#"something"); in the application:didFinishLaunchingWithOptions method doesn't show up on the console.
A reboot of my Mac seems to have fixed it. Thanks guys for your help. :)
if you are using a new Xcode(4+) and previously 3, there may be issue. Try setting the Architectures (Target -> Build Settings -> Architectures) to support armv6 too, presently it supports armv7(standard) only. If my memory is not deceiving me I guess I had such an issue.
I use Xcode 4.0.1..Suddenly I noticed that my xcode stopped showing predictions...(for example if I use the name of the button and after that it use to show all the property of the button such as enabled,hidden etc)...My Xcode isn't showing any predictions now, it leads to some errors and consuming long time with out these predictions..Where I want to change this settings?
Sometimes exiting XCode and restarting clears up strange behavior like this. Also, Mac OS X needs a reboot from time to time. Unfortunate, but true.
Could it be that you haven't imported the correct class(es)?
I have this problem when I get the compiler confused -- like during a refactoring and a large block of code, protocol names, interface properties, etc. are being changed. I will clean and compile -- allow the errors, then it starts to work again.
Also, if I have unbalanced braces, brackets, parenthesis, etc. that precedes the code I am working on, then it will stop autocompletion. As soon as I balance the statement(s), it works again. Sometimes, I have to clean and recompile.
I've made an iPad App. I was able to run this App on my device and on simulator.
After I've updated several classes (which I tested in simulator) I wasn't able to run my App on my device. It gives no errors but just hangs when compiling.
I'm thinking it's something with a class which came out very large and has some mathematical functions inside (calculations of transforms etc.)
After a long runtime Xcode gives back this error (something about a 'clang error'):
Anyone has any experience with these kind of issues and could find a solution?
EDIT:
Within my viewdidload method i have set 112 float values (i.e. value = 12;) and save them (with NSUSerdefaults).
Only setting these values solved my problem. No idea why this was giving me compile errors. I'm thinking the mathematical functions (after setting the float values) took to much memory or CPU.
Did you try cleaning your build and rebuild again?
Menu > Product > Clean
close & reopen XCode, "Clean All Targets" then rebuild. It should work.
Clean your project, delete the app from you iPad and try again. Should work.
Hope it helps
Are you trying to "Build and Analyze" or an ad-hoc build or debug build?
If your code crashed because of any memory issues or bad access memory due to any infinite loop, try to enable NSZombieEnabled in your executable settings. It will point you to the code snippet where the code crashes.
To enable "NSZombieEnabled", go to
Edit Active Executables -> Arguments -> Variables in the environment -> Add name as "NSZombieEnabled" and value to "YES"
Hopes this helps.
I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in xcode) and they all have a warning saying 'expression result unused'. Has anyone ever seen this before or know what to do? Am i running in some kind of weird mode? Im running xcode 4.0.2.
Many thanks
Jules
for completeness, I had the same problem and the answer was different, hope it helps someone else who bumps into this post:
I had a framework (an Amazon one) redefining NSLog, went there (Cmd+Click on the Brown NSLog) and commented out the redefinition...
The actual problem was the release_build set to 1. So it wasn't recognizing nslog, as you said it was set for a release build.
I had the same issue :
what worked for me is given below:
Remove the derived data folder
After removing derived data perform the clean action (You can see this option in the product menu)
Quit the Xcode and start it again.
And this did the trick all my NSLog were working fine.
Hoep this helps
Ensure that scheme chosen corresponds to Debug mode because sometimes the pch file might have some definitions such that logging is done only in the debug mode
(Scheme is on to the left of the place where you select iPhone Simulator / iOS Device)
In the view select Debug Area
(There are 3 view buttons, on the top right hand corner of Xcode, press the center button)
Select "Show variables view and the console"
(In the debug area (bottom) there are ther 3 buttons, press the center button)
I had the same issue and the problem was that I was building an Ad Hoc version (schema was for Ad Hoc build). The warnings disappeared when I built for debug.
Try changing the dropdown menu at the bottom of the console to 'All Output'.
if you are using libraries like 'KScan' or 'iKEA' or 'kdc-scan', so it can happens that, they will call methods like this one 'redirectNSLogToDocuments'.
in my case the object of 'iKEA' call the method 'CheckIfDeviceConnected' and this one redirect all nslog outputs to documents. after commenting out, all nslogs works again :)
hope this will be useful for some one.
some steps :-
1) "Clean all targets" or delete your build and rebuild again.
2) If step 1 doesnt work , reinstall xcode