My team is developing an enterprise VPN application that needs to respond to Mobile Device Management (MDM) profile installations and removals in real-time. Our app uses the NetworkExtension framework and needs to update the UI immediately when VPN configurations are added or removed via MDM.
We are currently observing NEVPNConfigurationChangeNotification to detect VPN configuration changes:
While NEVPNConfigurationChangeNotification fires reliably when users manually remove VPN profiles through Settings > General > VPN & Device Management, it appears to have inconsistent behavior when MDM profiles containing VPN configurations are installed programmatically via MDM systems.
STEPS TO REPRODUCE
From MDM Admin Console: Deploy a new VPN profile to the test device
On Device: Wait for MDM profile installation (usually silent, no user interaction required)
Check Device Settings: Go to Settings > General > VPN & Device Management to confirm profile is installed
Return to App: Check if the UI shows the new VPN profile
Swift
RSS for tagSwift is a powerful and intuitive programming language for Apple platforms and beyond.
Posts under Swift tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
When using the new RealityKit Manipulation Component on Entities, indirect input will never translate the entity - no matter what settings are applied. Direct manipulation works as expected for both translation and rotation.
Is this intended behaviour? This is different from how indirect manipulation works on Model3D. How else can we get translation from this component?
visionOS 26 Beta 2
Build from macOS 26 Beta 2 and Xcode 26 Beta 2
Attached is replicable sample code, I have tried this in other projects with the same results.
var body: some View {
RealityView { content in
// Add the initial RealityKit content
if let immersiveContentEntity = try? await Entity(named: "MovieFilmReel", in: reelRCPBundle) {
ManipulationComponent.configureEntity(immersiveContentEntity, allowedInputTypes: .all, collisionShapes: [ShapeResource.generateBox(width: 0.2, height: 0.2, depth: 0.2)])
immersiveContentEntity.position.y = 1
immersiveContentEntity.position.z = -0.5
var mc = ManipulationComponent()
mc.releaseBehavior = .stay
immersiveContentEntity.components.set(mc)
content.add(immersiveContentEntity)
}
}
}
I have a question regarding the behavior of AVAudioSession.sharedInstance().outputVolume.
Observed behavior:
When the app is in the foreground, I read audioSession.outputVolume (for example, 0.1).
The app is then moved to the background.
While the app is in the background, the user changes the system volume using the hardware buttons (for example, to 0.5).
When the app returns to the foreground, audioSession.outputVolume still reports the previous value (0.1).
From my testing, outputVolume only seems to update when the system volume is changed while the app is in the foreground. Volume changes made while the app is in the background are not reflected when the app returns to the foreground.
Questions:
According to Apple’s documentation for AVAudioSession.outputVolume:
“The systemwide output volume set by the user.”
https://developer.apple.com/documentation/avfaudio/avaudiosession/outputvolume
However, based on our testing on iOS 18.6.2 and iOS 18.1, the observed behavior seems to differ from this description.
Questions:
The documentation states that outputVolume represents the system-wide volume set by the user. In our testing, the value does not reflect volume changes made while the app is in the background and only updates when the app is in the foreground.Is this the expected behavior of AVAudioSession.outputVolume?
Is there any other recommended way in Swift to retrieve the current system volume that reflects user changes made both while the app is in the foreground and while it is in the background?
Any clarification on the intended behavior or recommended handling would be greatly appreciated.
In an NSTableView (Appkit), I need to colour a cell background when it is selected.
That works OK, except that the colour does not span the full cell width, nor even the text itself:
The tableView structure is very basic:
I see there is a TextCell at the end that cannot be deleted. What is this ?
And the colouring as well:
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let p = someDataSource[row]
if let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: self) {
(cellView as! NSTableCellView).textField?.stringValue = p
if selected[row] {
(cellView as! NSTableCellView).backgroundColor = theLightBlueColor
} else {
(cellView as! NSTableCellView).backgroundColor = .clear
}
return cellView
}
}
I've tried to change size constraints in many ways, to no avail.
For instance, I changed Layout to Autoresising :
I tried to change TableCellView size to 170 vs 144:
Or increase tableColum Width.
I have looked at what other object in the NSTableView hierarchy should be coloured without success.
Nothing works.
What am I missing ?
Hello every developers. I need your help. Do you know how to attach animation to appearance, like a smooth transition from dark to light and vise versa. My code here:
@main
struct The_Library_of_BabelonApp: App {
@AppStorage("selectedAppearance") private var selectedAppearance = 0
@StateObject private var router = AppRouter()
var scheme: ColorScheme? {
if selectedAppearance == 1 { return .light }
if selectedAppearance == 2 { return .dark }
return nil
}
var body: some Scene {
WindowGroup {
RootView()
.preferredColorScheme(scheme)
.environmentObject(router)
// this is doesn't work correctly
.animation(.smooth(duration: 2), value: selectedAppearance)
}
}
}
And my appearance switching looks:
struct SettingsView: View {
@AppStorage("selectedAppearance") private var selectedAppearance = 0
var body: some View {
List {
Section(header: Text("Appearance")) {
HStack(spacing: 20) {
ThemePreview(title: "Light", imageName: "lightTheme", tag: 1, selection: $selectedAppearance)
ThemePreview(title: "Dark", imageName: "darkTheme", tag: 2, selection: $selectedAppearance)
ThemePreview(title: "System", imageName: "systemMode", tag: 0, selection: $selectedAppearance)
}
.padding(.vertical, 10)
.frame(maxWidth: .infinity)
}
}
}
}
struct ThemePreview: View {
let title: String
let imageName: String
let tag: Int
@Binding var selection: Int
var body: some View {
Button {
selection = tag
} label: {
VStack {
Image(imageName)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 120, height: 80)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(
RoundedRectangle(cornerRadius: 12)
.stroke(selection == tag ? Color.blue : Color.clear, lineWidth: 3)
)
Text(title)
.font(.caption)
.foregroundColor(selection == tag ? .blue : .primary)
}
}
.buttonStyle(.plain)
}
}
I guess my code works but animation working another way, its turn my Section, I don't know.... Thank you in advance
When inputting data within a sheet, I'm allowing the user to take a photo, so the camera is called and presents itself within a 2nd sheet, however the controls are centered within the iPhone's entire screen, cropping the top controls and not extending down to the bottom of the phone's screen.
Any help on how to fix this?
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?
Hello,
After upgrading to macOS 26.2, I’ve noticed a significant performance regression when calling evaluateJavaScript in an iOS App running on Mac (WKWebView, Swift project).
Observed behavior
On macOS 26.2, the callback of evaluateJavaScript takes around 3 seconds to return.
This happens not only for:
evaluateJavaScript("navigator.userAgent")
but also for simple or even empty scripts, for example:
evaluateJavaScript("")
On previous macOS versions, the same calls typically returned in ~200 ms.
Additional testing
I created a new, empty Objective-C project with a WKWebView and tested the same evaluateJavaScript calls.
In the Objective-C project, the callback still returns in ~200 ms, even on macOS 26.2.
Question
Is this a known issue or regression related to:
iOS Apps on Mac,
Swift + WKWebView, or
behavioral changes in evaluateJavaScript on macOS 26.2?
Any information about known issues, internal changes, or recommended workarounds would be greatly appreciated.
Thank you.
Test Code Swift
class ViewController: UIViewController {
private var tmpWebView: WKWebView?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setupUserAgent()
}
func setupUserAgent() {
let t1 = CACurrentMediaTime()
tmpWebView = WKWebView(frame: .zero)
tmpWebView?.isInspectable = true
tmpWebView?.evaluateJavaScript("navigator.userAgent") { [weak self] result, error in
let t2 = CACurrentMediaTime()
print("[getUserAgent] \(t2 - t1)s")
self?.tmpWebView = nil
}
}
}
Test Code Objective-C
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
WKWebView *webView = [[WKWebView alloc] init];
dispatch_async(dispatch_get_main_queue(), ^{
[webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
NSTimeInterval endTime = [[NSDate date] timeIntervalSince1970];
NSLog(@"[getUserAgent]: %.2f s", (endTime - startTime));
}];
});
}
Hello. We are facing very silent and hardly replicable issue. All UserDefaults.standard data the application saved and was using to determine the state of app is lost and app behaves as if it was freshly installed.
The issue always occurs only if we leave app on background for long time or if we manually swipe the app from the background apps. In case we swipe, this issue can occur in minutes, hours or up to 2 days by our latest testing.
One important factor is that the app was developed using iOS18 in which issue never occured. Next it was being tested on iOS26 and it did everytime. Any currently available version of iOS26 reported this issue, all the way up to 26.2.1 (23C71). Our application is going through major upgrade of its whole lifecycle and services so it is possible this issue is caused by a bug in development as the production version does not report this issue neither on iOS26 of any version.
The following list contains how we tried to fix this issue but none of which helped.
App prewarming in the background (postpone all initialization including searching UserDefaults.standard for when isProtectedDataAvailable)
Calling UserDefaults.standard.synchronize() everytime after saving data despite it is not recomended
Built app using different SDK's (tested on iOS18 and iOS26 SDK)
Distributed the app from local machine aswell as on TestFlight itself
We searched through currently opened and closed issues for third-party libraries app uses regarding 'iOS26' and 'UserDefaults', especially those who were added recently with no success.
The structure using which we save data into UserDefaults.standard did not change, we have only added few more settings to save through the lifecycle of the app after update. We estimate the overall increase is merely 30% more of what it used to be in previous version.
Any ideas are much appreciated. We are considering to use different or fully custom ways to store app's settings.
In this app I use tooltips extensively.
They work perfectly well, except in a popover where they may appear or not (just some flash and immediately disappear).
In the popover there are 12 colour buttons, each with its own tracking area and 3 control buttons, with their tracking areas.
Here when it works, hovering over "C" button or "Annuler" button:
But then, when I move to another colour button, a few 2 or 3 may work, but most don't display their tooltip at all.
I know that the tooltip is set because I replicate the message in a help line at the bottom of the screen and this line always update:
Let messageForColor = "Choisir la couleur…"
if button.isEnabled { // show tooltip
button.toolTip = messageForColor
} else {
button.toolTip = nil
}
if button.isEnabled { // Shows helpline at the bottom of screen
button.helpMessage = messageForColor
}
Maybe it comes from some useDefault (I modified NSInitialTool TipDelay and I'm not sure I have reset to the default value)
I noted that if I wait for 10 seconds or so (keeping the popover opened), everything seems to work properly again. Just as if there was some lengthy initialisation going on.
So questions:
Is there a known issue of Tooltips in a popover ?
Are there other parameters to set in userDefaults to avoid immediate disparition of the tooltip in popover ?
How to reset the factory setting for the UserDefaults in the app ?
Hello,
We are seeing an intermittent crash when initializing a base UITableView with Apple's [initWithFrame:style:] initializer.
Crash stack:
Role: Foreground
OS Version: iOS 26.1
Exception Type: EXC_BREAKPOINT
Exception Subtype: KERN_INVALID_ADDRESS
EXC_BREAKPOINT:
0 libswiftCore.dylib +0x1358c0 _assertionFailure(_:_:file:line:flags:)
1 UIKitCore +0x1fdca0 0x188c26ca0 (0x188c26b20 + 384)
2 UIKitCore +0x1ffa60 0x188c28a60 (0x188c2890c + 340)
3 UIKitCore +0x2012d0 0x188c2a2d0 (0x188c2a1ec + 228)
4 UIKitCore +0x200f20 0x188c29f20 (0x188c29cac + 628)
5 UIKitCore +0x200428 0x188c29428 (0x188c29384 + 164)
6 UIKitCore +0x18af7f4 -[UITableMetricsAdapter _updateSharedSectionMetricsForListGeometry:]
7 UIKitCore +0x201da8 -[UITableMetricsAdapter tableBackgroundColor]
8 UIKitCore +0x1643a44 ___39-[UITableView _applyAppearanceDefaults]_block_invoke
9 UIKitCore +0x196f3d0 +[UIView _performSystemAppearanceModifications:]
10 UIKitCore +0x1643978 -[UITableView _applyAppearanceDefaults]
11 UIKitCore +0x202854 -[UITableView _setupTableViewCommon]
12 UIKitCore +0x1643760 -[UITableView initWithFrame:style:]
13 Application +0x30b6a40 closure #1 in variable initialization expression of MyAppClass.tableView
14 Application +0x30b6ef0 MyAppClass.init(frame:)
Has anyone else seen something like this?
Any insights or advice is much appreciated, thank you!
Hi, I recently built an app and I’m planning to publish it on the App Store. Since the Swift Student Challenge (SSC) is coming up, I’m also considering submitting the same project by converting it into a Swift Playground (with some content trimmed to meet the rules). I believe both I and the project are eligible.
My question: if I publish the app on the App Store first and then submit it to SSC, could that violate the rules or lead to rejection?
I also have a concern: because I’m a minor, Apple requires the App Store developer name to be my mother’s. However, the app was entirely developed by me. my mother and anyone else did not participate(My mother can't even use a computer.). I’m worried this might create confusion and make judges think I copied someone else’s work, which I did not.
Would you recommend publishing on the App Store now, waiting until after SSC, or taking a different approach? Thank you.
Topic:
Community
SubTopic:
Swift Student Challenge
Tags:
Swift Student Challenge
App Store
Swift
Swift Playground
Hello everyone. I want to do navigationTitle (located on the top side on MacOS system) in LiquidGlass style. now my solution look like:
just black rectangle. But i want like this:
opacity and LiquidGlass. Like in Photo app in MacOS. Please help me, thank you in advance.
My code:
struct RootView: View {
@Environment(\.horizontalSizeClass) var hSize
var body: some View {
if hSize == .regular {
DesktopLayout()
.navigationTitle("title")
.toolbarBackground(.ultraThinMaterial, for: .automatic)
} else {
MobileLayout()
}
}
}
Hi, we are developing a screen time management app. The app locks the device after it was used for specified amount of time.
After updating to iOS 26.2, we noticed a huge issue: the events started to fire (reach the threshold) in the DeviceActivityMonitorExtension prematurely, almost immediately after scheduling. The only solution we've found is to delete the app and reboot the device, but the effect is not lasting long and this does not always help.
Before updating to iOS 26, events also used to sometimes fire prematurely, but rescheduling the event often helped. Now the rescheduling happens almost every second and the events keep reaching the threshold prematurely.
Can you suggest any workarounds for this issue?
Lately I am getting this error.
GenerativeModelsAvailability.Parameters: Initialized with invalid language code: en-GB. Expected to receive two-letter ISO 639 code. e.g. 'zh' or 'en'. Falling back to: en
Does anyone know what this is and how it can be resolved. The error does not crash the app
Hi everyone. Can you help me with my settings icon design. I`m trying to create circular setting button using Menu. My code here:
struct MenuView: View {
var body: some View {
Menu {
Text("Hello")
Text("How are you")
} label: {
Image(systemName: "gearshape.fill")
.clipShape(Circle())
}
.clipShape(Circle())
.padding(.top, 10)
.padding(.leading, 20)
}
}
You can see my try, this one looks wrong.
It should be like this:
Just Circle with setting image inside. Thank you an advance 😭🙏🛐
Hi Everyone. Can you help me with my settings icon design. I'm trying to create a circular settings button using Menu. My code here:
struct MenuView: View {
var body: some View {
Menu {
Text("Hello")
Text("How are you")
} label: {
Image(systemName: "gearshape.fill")
.clipShape(Circle())
}
.clipShape(Circle())
.padding(.top, 10)
.padding(.leading, 20)
}
}
You can see my try, this one looks wrong.
It should be like this:
Just Circle with setting image inside. Thank you an advance 😭🙏🛐
I added a Content Filter to my app, and when running it in Xcode (Debug/Release), I get the expected permission prompt:
"Would like to filter network content (Allow / Don't Allow)".
However, when I install the app via TestFlight, this prompt doesn’t appear at all, and the feature doesn’t work.
Is there a special configuration required for TestFlight? Has anyone encountered this issue before?
Thanks!
I am using the native SwiftUI WebView and WebPage APIs (iOS 26+) and would like to implement file download functionality using the native SwiftUI WebView. However, I have not been able to find any APIs equivalent to WKDownload.
In WKWebView, the WKDownload API can be used to handle downloads. I am looking for a similar API or recommended approach in the native SwiftUI WebView that would allow downloading files.
If anyone has guidance or suggestions on how to implement this, I would appreciate your help.
I'm currently using Swift to write an independent Apple Watch app for watchOS 7+. My app uses Location Services, and in case the user doesn't allow that at first, I'd like to have a button inside my watchOS app to send my user to the part of the Settings app (inside watchOS) where he can give the appropriate permissions for the app.
I know that in iOS/macOS you can use the openSettingsURLString string from UIApplication to do what I want, but it's not available in watchOS and I haven't found any equivalent resource inside the WKExtension class (normally the equivalent for UIApplication in the watchOS environment).
Does anyone know if there's any way to programatically open the Apple Watch Settings app from my watchOS app?
I'm asking since as far as I understand asking for Location permissions again would not work since the user has already refused to allow the permissions before, making the authorization status "denied".
I understand as well that there's the possibility of showing a modal and directing the user to go to Settings and allow the use of location services (as in "Please go to Settings > Privacy > Location Services > [AppName] to allow the use of location services") but I'd like if I could direct the user there instead as one might do in iOS.
The code below is what I'm trying to do - but (of course) it crashes since I'm not actually passing any system URL.
.alert(isPresented: $alertVisible) {
Alert (title: Text("Please allow our app to use location services in order to get Weather Data"),
message: Text("Go to Settings?"),
primaryButton: .default(Text("Settings"), action: {
WKExtension.shared().openSystemURL(URL(string: "")!)
//UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
}),