Can any one please tell me if toggle switch is working well on your end?


I am reading some great articles here along with my ios apprentice book, well, as it turns out if i am trying to use the switch toggle object available to me , eve if i am not doing any thing with it and just drag it on story board and then change it form on to off i get this error

2020-01-11 14:12:25.487218+0530 test[2807:300764] invalid mode ‘kCFRunLoopCommonModes’ provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

Then even if i try and add action still the same problem is there, i have tried changing many values and still no success, i am using xcode 11.3 and catalina , can any one please guide me how i can overcome this issue …

here is snapshot

Thanks a lot


Is there any chance you somehow referenced the UISwitch twice ? Can you show us the outlets section of your ViewController from storyboard?

Also could you give more info about your stack trace crash error ? When you app crashes it tries to print all the steps it passes before getting to that state where it crashed. Not sure this will solve the problem, but the stack trace might give info that does not meet the eye.

1 Like

Hi @amitsrivastava, after doing a quick lookup of the error you provided above it seems like a common issue with the toggle switch. Unfortunately I did not see a solution. Might be a bug in Xcode. I will give you an update if I find a possible solution.


1 Like

@2dino1 - thanks for your time, well the issue come up even if i just simply add a switch toggle button and try and flip it , no code no functionality just try and use it by flipping it, the error comes up, now here is the update, i tried and run the app on an actual iphone , the error shows up on xcode but does not crash the app on iphone, even in xcode the app does not crash … I have no idea why this is happening , i will update you , for the time being i am going ahead with learning and trying new stuff in xcode

@gdelarosa - thanks mod for the help, i just want to update as mentioned earlier , the app does not crash on iphone and even in simulator but the error pops up every time i try and use the toggle switch

Just one more thing about trying the app on iphone device instead of simulator —

the app in ios 13 by default started in dark mode making my black fonts fade in dark black color , so i was able to change the code in viewDidLoad func to make it load in light mode if #available ( iOS 13.0, *){
overrideUserInterfaceStyle = .light

this was very useful to see on a real iphone as in simulator this problem was not there, now it seems all apps in ios13 load in dark mode by default …


Hi @amitsrivastava,
there are a lot of warnings that appear in the console when you run a project in xcode. While some are about deprecated APIs but they do not cause a crash. I can share a very interesting thing that happened with us,

In the Assets, We added a named color and added a dark mode color and a light color for it. The way Xcode deals with it is, the color name creates a folder with that name and contains a Json file with the color value. However the name could be lowercased, the folder name is created with an uppercased first letter. We were doing something really smart which broke because the color did not return a lowercase name. This code worked fine int he simulator and running from Xcode, however when deployed to TestFlight and thereby to the device - CRASH!!

Short version, Xcode IDE has issues and if it does not crash, it should be fine in most cases, and when it crashes, it can really stump you.


1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.