invalid mode 'kCFRunLoopCommonModes'

invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug


I get this warning when I tap either of the switches shown below. I've tried capturing the switch state in a var and using that to trigger the do/catch statement but no joy. I've even tried pulling the do/catch into separate functions and I still get the warning. Has anybody else run into this and how did you fix it?


@IBAction func greetingFormat_Tapped(_ sender: UISwitch)
    {
        let theQuery = theTable_Settings.filter(settingID == 1)
       
        if sender.isOn
        {
            do {
                if try Database.shared.databaseConnection!.run(theQuery.update(greeting_Format <- "true")) > 0
                {
                    greetingFormatLabel_Outlet.text = NSLocalizedString("HelloMrSmith_String", comment: "")
                } else {
                    print("greeting format true not found")
                }
            } catch {
                print("greeting format true update failed! Error: \(error)")
            }
        } else {
            do {
                if try Database.shared.databaseConnection!.run(theQuery.update(greeting_Format <- "false")) > 0
                {
                    greetingFormatLabel_Outlet.text = NSLocalizedString("HiJoe_String", comment: "")
                } else {
                    print("greeting format false not found")
                }
            } catch {
                print("greeting format false update failed! Error: \(error)")
            }
        }
    }


@IBAction func nonrefundableSwitch_Tapped(_ sender: UISwitch)
    {
        let theQuery = theTable_Settings.filter(settingID == 1)
        var itsOn: String = ""
       
        if sender.isOn
        {
            itsOn = "true"
        } else {
            itsOn = "false"
        }
       
        if itsOn == "true"
        {
            do {
                if try Database.shared.databaseConnection!.run(theQuery.update(nonRefundable_Bool <- "true")) > 0
                {
                    depositDueLabel_Outlet.text = NSLocalizedString("nonRefunddepositisdue_String", comment: "")
                } else {
                    print("nonRefundable true not found")
                }
            } catch {
                print("nonRefundable true update failed! Error: \(error)")
            }
        } else {
            do {
                if try Database.shared.databaseConnection!.run(theQuery.update(nonRefundable_Bool <- "false")) > 0
                {
                    depositDueLabel_Outlet.text = NSLocalizedString("depositisdue_String", comment: "")
                } else {
                    print("nonRefundable false not found")
                }
            } catch {
                print("nonRefundable false update failed! Error: \(error)")
            }
        }
    }

@eskimo writes: Other than the log message, is this causing ... any problems?

YES!

For a sheet with an @ObservedObject object with date and isToggle members having the UI with a DatePicker and Toggle, changing the date to today's date--whatever today happens to be when running--then toggling cause the sheet to go away--poof--back to the previous view WHEN IN DEBUG MODE. This does not happen in release.

January 18, 2022

January 21, 2022... and here I am! Yes, still happening.

I am also seeing problems when getting this error. The NavigationLink view that this toggle is on is dismissed when toggling and goes back to the previous view. It is quite annoying. As @swiftaero mentioned above the issue is happening in the sim and on device while developing the app, I have not released the app yet so I can't test it on deployment or in TestFlight.

2 Interesting things about my situation with this error is that it is happening when I toggle an @AppStorage binding. If I change it to an @State binding it does not dismiss the view back to the previous one. Also the view has a list of core data records from an @FetchRequest and this error happens and dismisses the view when I delete a record from the list with .onDelete.

I have tried to replicate this issue in another app and I get the error but not the dismissing of the view. My current line of thinking is that the error&dismiss is linked to editing an object that lives outside of the view. But I am defiantly stumped at this point and will have to see if it happens in TestFlight like @swiftaero mentioned.

Still happening for SwiftUI Toggle March 24 2022

5 April, 2022 and this still happening.Not an April foil! believe me!!— iSimoo less than a minute ago 

14 July, 2022 Still happening

"invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution."

still habbening

iOS 16.0 RTM, still happening with a plain SwiftUI Toggle.

Oct 12, 2022, and still receive the same error for UISwitch with and without actions attached. `2022-10-12 14:29:00.726306-0400 [REDACTED][4322:62624] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

still happening

2022-10-14 19:28:59.391056+0200 Solingen[2557:1069151] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

Still happening for SwiftUI Toggle October 28 2022

November here. Still a thing.

It's January 12, 2023. Still happening

One way to silence this warning is to:

  1. Go into your project's "Edit Scheme..."
  2. Select the Run (Debug) option, in the left-hand sidebar.
  3. Add a new Environment Variable by clicking on the "+" icon.
  4. Enter "OS_ACTIVITY_MODE" (without the quotes) for the name.
  5. Enter "disable" (without the quotes) into the value field.
  6. Click "Close" and then build and run your app.

Please note that this may hide other important info in the console. But, your print messages will still appear, as expected.

This is still happening on March 19th, when using Toggle with an @AppStorage binding.

invalid mode 'kCFRunLoopCommonModes'
 
 
Q