iOS App never gets Bluetooth connection

I am developing an iOS App for a Bluetooth peripheral using SwiftUI with Swift 5 or 6. I have a few past attempts that got so far (connected to a peripheral), and some downloaded examples that connect to peripherals. Lately (last month or so), my current attempt never gets BleManager to start, and every attempt ends at my View that says 'please enable Bluetooth'. The Xcode console is totally blank with no print outputs. Coding Assistant suggested the init() in my @main structure could contain print("App initializing"), but even that never prints.

Coding Assistant suggests:

"• Open your project's Info.plist in Xcode. • Make sure UIApplicationSceneManifest is present and configured for SwiftUI, not referencing any storyboard. • Ensure UIMainStoryboardFile is not present (or blank)."

but there is no info.plist because it is no longer required.

Downloaded sample code runs and connects to peripherals, so Bluetooth is working on my iPhone and the Bluetooth device is accessible. My older attempts used to work, but now have the same problem.

All attempts have "Enable Bluetooth to connect to Device" in the Privacy - Bluetooth Info.plist setting.

Something is fundamentally wrong with many different code attempts.

I have searched all the various settings for mention of SwiftUI or Storyboard, but not found them in working or failing projects.

The downloaded code which works has minimum deployment iOS 14.0 and Swift Compiler Language Version Swift 5. My latest code attempt has minimum deployment iOS 16 and Swift 5. All code is target device iPhone (I am testing on iPhone 16e running iOS 26.2.1) and developing with Xcode 26.2 on MacBook Air M1 running the latest Tahoe.

I do a Clean Build Folder before every test, and have tried re-starting both Mac and iPhone.

How can my coding fail so spectacularly?

I am going to suggest that your issue is more structural than a Bluetooth connection problem if even print("App initializing") is not printing.

Once you get that working (perhaps start with a clean "Hello world!" project to make sure your code is running. And then you can add the Bluetooth functionality to it using examples.

Unfortunately our sample projects are a bit dated, and outside the watchOS sample Interacting with Bluetooth peripherals during background app refresh, we don't have any SwiftUI examples that demonstrate CoreBluetooth.

Currently, the CoreBluetooth framework is not fully compatible with SwiftUI, and requires the use of

@UIApplicationDelegateAdaptor var delegate: ApplicationDelegate

and handle your CoreBluetooth logic in a UIKit class.

In the above example, you will find an iOS target BARBluetooth, which will show how the SwiftUI/UIKit integration is handled. (do not consider the code there as a full example though, as that is a specific app that only accompanies the watchOS app and it's special functions).

I have posted a skeleton project on Github

https://github.com/andrewknockin/BleTest

iOS App never gets Bluetooth connection
 
 
Q