SwiftUI Stepper Crashes (EXC_BAD_ACCESS) on My Mac (Designed for iPhone) but works fine on iOS device/simulator?

I've been working on an iOS project for the iPhone and would like to support running it on macOS computers with Apple Silicon. In the Targets / Supported Destinations we added "Mac (Designed for iPhone)" but experienced Thread 1: EXC_BAD_ACCESS crashes immediately when we tried to run it.

We've isolated it down to Stepper UI elements in our view. Starting a new project and just trying to present a single Stepper in the ContentView, we get the same crash.

Here is code that presents the issue:

//  ContentView.swift

import SwiftUI

struct ContentView: View {
    @State var someValue = 5
    var body: some View {
        VStack {
            Stepper("Stepper", value: $someValue, in: 0...10)
        }
    }
}

When run from Xcode on an iOS device or the simulator, it runs fine.

Trying to run it on the Mac, it crashes here:

//  Stepper_01App.swift

import SwiftUI

@main // <-- Thread 1: EXC_BAD_ACCESS (code=2, address=0x16a643f70)
struct Stepper_01App: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Xcode 14.3 (14E222b), MacOS Ventura 13.3.1 (a), Mac mini M2. Target: Mac (Designed for iPhone)

We have verified that the same code crashes on all the Apple Silicon Macs we have access to. Searching the Internet and Apple Developer forums I dont find other reports, so I kind of feel there must be some level of either user error or system/project misconfiguration going on?

If any iOS app that used Steppers was just crashing when trying to run on a Mac, it seems like this would be a big deal.

If anyone has input or can point out what we need to do differently, it would be appreciated!

finally someone with the same crap happening, im breaking my head today over this. have Sonoma 14.1.2 , using the stepper via macOS (designed for iPhone) is giving me the same EXEC BAD ADDR , I have a MacBook Pro m2 . today is feb 13 2024, and it crashes for me ... anyone has a fix ???

did someone got how to fix it ???

I’d like to see a crash report for this. Posting a Crash Report has info on how to get and post that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Report on :

https://qtext.io/jayr

Report on :

That links works but it doesn’t yield a crash report.

ill be sending you everything at your email

I’d be much happier if you posted your crash report here. That way I don’t have to worry about whether it’s OK to quote sections of it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Just did send you again at eskimo 1 at apple via email

I saw that. However, I’m asking you to reply here because I’m not able to provide one-on-one help via email.

Anyway, coming back to your technical issue, one of my colleagues reached let me know that this is a known problem in Stepper (r. 109980918). It crashes in this way for a Mac Catalyst app and for iOS Apps on Mac. OTOH, it should work just fine in an iOS app and in a standard macOS app.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hey @eskimo ! Foes your buddy has insights on whats happening…? And/or if theres a way to circunvemnt …?

i was thinking maybe having a conditional to detect if the app is being run on mac and if so maybe throw a custom made stepper …? But i dont think thats possible

Same issue. FB13481540

Personally I’d just build a native Mac app. Historically that was tricky because you had to write separate UI code (UIKit vs AppKit) but SwiftUI makes that a lot easier.

But:

i was thinking maybe having a conditional to detect if the app is being run on mac

That’s certainly possible. Check out the isiOSAppOnMac property.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hey @eskimo just to let you know I did fix and published already to the appstore, did a conditinoal check via ProcessInfo.processinfo.isiOSAppOnMac and did throw in a custom stepper which I had to build and act as the original stepper component :D

so everything is running smoothly on the Mac right now :D

I just hope that gets fixed by Apple , because just imagine... that's a very very common ui component to use.. so if any iOS app that has a stepper at some point integrate it into it, it will render the app unusable on the Mac, which I know with this M chips this compatibility thing is a Huge claim by apple on its software environment , I mean.. the whole compatibility thing its a sales point already...

but that little bug.. will make a bunch of apps crashing and unusable

anyone want to see the code to circumvent the issue and the CustomStepper ?

Click here to the StackOveflow link

@Robertsmania come check the link and how to fix, if you need any help with this let me know

SwiftUI Stepper Crashes (EXC_BAD_ACCESS) on My Mac (Designed for iPhone) but works fine on iOS device/simulator?
 
 
Q