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)")
            }
        }
    }

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.

It's August 13, 2023. Still happening.

3 Nov, 2023. This still happening.

This is a perfect example of Apple's lack of concern about cleaning up their code and why you can't rely on them to fix reported bugs.

Their focus is always on the next best thing (which is often catching up with the competition).

Find a work around and keep on developing your code.

I've been working around issues in every release since iOS 3.

I used to update immediately to the latest iOS version in the hope that they had fixed some of the bugs I reported.

Instead I found myself an unwilling beta tester for their latest release.

Now, I give everyone else a few weeks to catch the latest bugs before I stick my toe in the water.

This problem isn't limited to Apple - I see the same thing everywhere - I just happened across this error again tonight and it made me sad to think there's nothing any of us can do to make them care about cleaning up their code.

invalid mode 'kCFRunLoopCommonModes'
 
 
Q