I have an app with two file types with the following extensions:
gop (an exported type),
sgf (an imported type).
The Save command fails after the following sequence of events:
I open a gop file, say the file "A.gop".
I save this file as an sgf file, say "A.sgf".
This Save As works perfectly and the document name in the document’s title bar has changed to "A.sgf".
I change something in the document and then try to Save this change.
This should just resave the document to "A.sgf", but "A.sgf" remains untouched. Instead I get a system alert with the message
The document “A.sgf” could not be saved. A file with the name “A.gop” already exists. To save the file, either provide a different name, or move aside or delete the existing file, and try again.
In the Xcode console I get the following diagnostic:
NSFileSandboxingRequestRelatedItemExtension: an error was received from pboxd instead of a token. Domain: NSPOSIXErrorDomain, code: 2 [NSFileCoordinator itemAtURL:willMoveToURL:] could not get a sandbox extension. oldURL: file:///Users/francois/Desktop/A.sgf, newURL: file:///Users/francois/Desktop/A.gop
The problem seems to relate to the sandbox. But I am at a loss to find a solution. (After closing the alert, I check that A.sgf did not register the change.)
If I open an sgf file, say "B.sgf", save it as "B.gop", make a change in the document and then try to save this change (into "B.gop"), I hit the same problem, with "gop" and "sgf" interchanged.
If, instead of saving "A.gop" as "A.sgf", I save it as "B.sgf", make a change in the document and then try to save this change into "B.sgf", I get the following system alert:
The document “B.sgf” could not be saved. You don’t have permission. To view or change permissions, select the item in the Finder and choose File > Get Info.
And in the Xcode console I get the following diagnostic:
NSFileSandboxingRequestRelatedItemExtension: an error was received from pboxd instead of a token. Domain: NSPOSIXErrorDomain, code: 2 [NSFileCoordinator itemAtURL:willMoveToURL:] could not get a sandbox extension. oldURL: file:///Users/francois/Desktop/B.sgf, newURL: file:///Users/francois/Desktop/B.gop
Again the sandbox ! (After closing the alert, I check that B.sgf did not register the change.)
It’s clear my code is missing something, but what?
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
In keyboard shortcuts this buttons at the bottom are overlappin.
Any one
else?
Topic:
UI Frameworks
SubTopic:
General
I want to record screen ,and than when I call the method stopCaptureWithHandler:(nullable void (^)(NSError *_Nullable error))handler to stop recording and saving file. before call it,I check the value record of RPScreenRecorder sharedRecorder ,the value is false , It's weird! The screen is currently being recorded !
I wonder if the value of [RPScreenRecorder sharedRecorder].record will affect the method stopCaptureWithHandler:
-(void)startCaptureScreen {
[[RPScreenRecorder sharedRecorder] startCaptureWithHandler:^(CMSampleBufferRef _Nonnull sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error) {
//code
} completionHandler:^(NSError * _Nullable error) {
//code
}];
}
- (void)stopRecordingHandler {
if([[RPScreenRecorder sharedRecorder] isRecording]){
// deal error .sometime isRecording is false
}else {
[[RPScreenRecorder sharedRecorder] stopCaptureWithHandler:^(NSError * _Nullable error) {
}];
}
}
here are my code.
In iOS 18, I've observed unexpected behavior related to the UINavigationBar when transitioning between view controllers that have differing navigation bar visibility settings. Specifically, when returning from a modal presentation or a web view, the navigation bar reappears with an unexpected height (e.g., 103 points) and lacks content, displaying only an empty bar.
Start with a UIViewController (e.g., HomeViewController) where the navigation bar is hidden using:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}
Present another UIViewController (e.g., a web view) modally.
Dismiss the presented view controller.
Observe that upon returning to HomeViewController, the navigation bar is visible with increased height and lacks expected content.
Expected Behavior:
The navigation bar should remain hidden upon returning to HomeViewController, maintaining the state it had prior to presenting the modal view controller.
Actual Behavior:
Upon dismissing the modal view controller, the navigation bar becomes visible with an unexpected height and lacks content, leading to a disrupted user interface.
Additional Observations:
This issue is specific to iOS 18; it does not occur in iOS 17 or earlier versions.
The problem seems to stem from setting the navigation bar to be visible in the viewWillDisappear method, as shown below:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
Removing or modifying this line mitigates the issue, suggesting a change in the view controller lifecycle behavior in iOS 18.
Request for Clarification:
Is this change in behavior intentional in iOS 18, or is it a regression? Understanding whether this is a new standard or a bug will help in implementing appropriate solutions.
Workaround:
As a temporary measure, I've adjusted the navigation bar visibility settings to avoid changing its state in viewWillDisappear, instead managing it in viewWillAppear or viewDidAppear.
References:
Similar issues have been discussed in the Apple Developer Forums: iPad OS 18 UINavigationBar display incorrectly
Topic:
UI Frameworks
SubTopic:
UIKit
My Mac app crashes for some users inside VideoToolbox, and I'm not sure what to do with that, and how to fix it.
Here are couple of examples that repeating again and again for macOS 15.*
Thread 10 Crashed:
0 libsystem_pthread.dylib 0x000000018535a8e0 0x185359000 + 6368
1 VideoToolbox 0x0000000194f3e218 0x194f28000 + 90648
2 VideoToolbox 0x00000001951de384 0x194f28000 + 2843524
3 libxpc.dylib 0x000000018506f2c0 0x185060000 + 62144
4 libxpc.dylib 0x000000018506da14 0x185060000 + 55828
5 libdispatch.dylib 0x00000001851ad674 0x1851a9000 + 18036
6 libdispatch.dylib 0x00000001851c9c88 0x1851a9000 + 134280
7 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672
8 libdispatch.dylib 0x00000001851ca9dc 0x1851a9000 + 137692
9 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672
10 libdispatch.dylib 0x00000001851b5764 0x1851a9000 + 51044
11 libdispatch.dylib 0x00000001851bf4cc 0x1851a9000 + 91340
12 libdispatch.dylib 0x00000001851bf260 0x1851a9000 + 90720
13 libsystem_pthread.dylib 0x00000001853602e4 0x185359000 + 29412
14 libsystem_pthread.dylib 0x000000018535b0fc 0x185359000 + 8444
and
Thread 10 Crashed:
0 libsystem_pthread.dylib 0x00000001981fc364 0x1981fb000 + 4964
1 VideoToolbox 0x00000001a85f9964 0x1a81e8000 + 4266340
2 VideoToolbox 0x00000001a847a840 0x1a81e8000 + 2697280
3 libxpc.dylib 0x0000000197f09830 0x197efb000 + 59440
4 libxpc.dylib 0x0000000197f0812c 0x197efb000 + 53548
5 libdispatch.dylib 0x00000001980638a4 0x198048000 + 112804
6 libdispatch.dylib 0x00000001980660e8 0x198048000 + 123112
7 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400
8 libdispatch.dylib 0x0000000198066e4c 0x198048000 + 126540
9 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400
10 libdispatch.dylib 0x0000000198052e60 0x198048000 + 44640
11 libdispatch.dylib 0x000000019805be30 0x198048000 + 81456
12 libdispatch.dylib 0x000000019805bbf0 0x198048000 + 80880
13 libsystem_pthread.dylib 0x0000000198201c0c 0x1981fb000 + 27660
14 libsystem_pthread.dylib 0x00000001981fcb80 0x1981fb000 + 7040
and this one is for macOS 14
Thread 10 Crashed:
0 VideoToolbox 0x000000018f12ac90 0x18f11d000 + 56464
1 VideoToolbox 0x000000018f130a80 0x18f11d000 + 80512
2 VideoToolbox 0x000000018f131090 0x18f11d000 + 82064
3 VideoToolbox 0x000000018f130f94 0x18f11d000 + 81812
4 Remote for Mac 0x00000001048d521c 0x1048d0000 + 21020
5 Foundation 0x000000018174796c 0x181709000 + 256364
6 Foundation 0x000000018174782c 0x181709000 + 256044
7 Foundation 0x00000001817477bc 0x181709000 + 255932
8 Foundation 0x0000000181746b64 0x181709000 + 252772
9 Foundation 0x00000001817468d4 0x181709000 + 252116
10 Foundation 0x00000001817467c4 0x181709000 + 251844
11 libdispatch.dylib 0x00000001803b0470 0x18039d000 + 78960
12 libdispatch.dylib 0x00000001803a13e8 0x18039d000 + 17384
13 libdispatch.dylib 0x00000001803a48ec 0x18039d000 + 30956
14 libdispatch.dylib 0x00000001803a3f08 0x18039d000 + 28424
15 libdispatch.dylib 0x00000001803b2ea8 0x18039d000 + 89768
16 libdispatch.dylib 0x00000001803b36b8 0x18039d000 + 91832
17 libsystem_pthread.dylib 0x000000018054dfd0 0x18054b000 + 12240
18 libsystem_pthread.dylib 0x000000018054cd28 0x18054b000 + 7464
I’m working with AppIntents and AppEntity to integrate my app’s data model into Shortcuts and Siri. In the example below, I define a custom FoodEntity and use it as a @Parameter in an AppIntent. I’m providing dynamic options for this parameter via an optionsProvider.
In the Shortcuts app, everything works as expected: when the user runs the shortcut, they get a list of food options (from the dynamic provider) to select from.
However, in Siri, the experience is different. Instead of showing the list of options, Siri asks the user to say the name of the food, and then tries to match it using EntityStringQuery.
I originally assumed this might be a design decision to allow hands-free use with voice, but I found that if you use an AppEnum instead, Siri does present a tappable list of options. So now I’m wondering: why the difference?
Is there a way to get the @Parameter with AppEntity + optionsProvider to show a tappable list in Siri like it does in Shortcuts or with an AppEnum?
Any clarification on how EntityQuery.suggestedEntities() and DynamicOptionsProvider interact with Siri would be appreciated!
struct CaloriesShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: AddCaloriesInteractive(),
phrases: [
"Add to \(.applicationName)"
],
shortTitle: "Calories",
systemImageName: "fork"
)
}
}
struct AddCaloriesInteractive: AppIntent {
static var title: LocalizedStringResource = "Add to calories log"
static var description = IntentDescription("Add Calories using Shortcuts.")
static var openAppWhenRun: Bool = false
static var parameterSummary: some ParameterSummary {
Summary("Calorie Entry SUMMARY")
}
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(stringLiteral:"Add to calorie log")
}
@Dependency
private var persistenceManager: PersistenceManager
@Parameter(title: LocalizedStringResource("Food"), optionsProvider: FoodEntityOptions())
var foodEntity: FoodEntity
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
return .result(dialog: .init("Added \(foodEntity.name) to calorie log"))
}
}
struct FoodEntity: AppEntity {
static var defaultQuery = FoodEntityQuery()
@Property var name: String
@Property var calories: Int
init(name: String, calories: Int) {
self.name = name
self.calories = calories
}
static var typeDisplayRepresentation: TypeDisplayRepresentation {
TypeDisplayRepresentation(name: "Calorie Entry")
}
static var typeDisplayName: LocalizedStringResource = "Calorie Entry"
var displayRepresentation: AppIntents.DisplayRepresentation {
DisplayRepresentation(title: .init(stringLiteral: name), subtitle: "\(calories)")
}
var id: String {
return name
}
}
struct FoodEntityQuery: EntityQuery {
func entities(for identifiers: [FoodEntity.ID]) async throws -> [FoodEntity] {
var result = [FoodEntity]()
for identifier in identifiers {
if let entity = FoodDatabase.allEntities().first(where: { $0.id == identifier }) {
result.append(entity)
}
}
return result
}
func suggestedEntities() async throws -> [FoodEntity] {
return FoodDatabase.allEntities()
}
}
extension FoodEntityQuery: EntityStringQuery {
func entities(matching string: String) async throws -> [FoodEntity] {
return FoodDatabase.allEntities().filter({$0.name.localizedCaseInsensitiveCompare(string) == .orderedSame})
}
}
struct FoodEntityOptions: DynamicOptionsProvider {
func results() async throws -> ItemCollection<FoodEntity> {
ItemCollection {
ItemSection("Section 1") {
for entry in FoodDatabase.allEntities() {
entry
}
}
}
}
}
struct FoodDatabase {
// Fake data
static func allEntities() -> [FoodEntity] {
[
FoodEntity(name: "Orange", calories: 2),
FoodEntity(name: "Banana", calories: 2)
]
}
}
Hello, the LocalizedStringKey does not work in the live activity. What do you suggest me to use in order to get localization in the live activity?
I'm trying to create a .pkg installer with productbuild/pkgbuild. But I'd also like to add my custom installer plugin to this. I'm using the following script. I'd like to add my bundle into this script. Since there are no official docs from apple how to do this nor there are a lot of updated resources, here are some things I have tried.
adding the following line to Distrubtion.xml
<bundle id="pluginid" path="path/to/myplugin.bundle"/>
adding component tag to pkgbuild also doesn't do anything
--component "path/to/myplugin.bundle"
The bundle itself is build with XCode - it is a simple UI for user to type some input in
Apple provides documentation for Distribution.xml file, which supports different UI elements but doesn't support text input - docs
I have been also looking at this tutorial , it is very outdated but i could still fit it to my needs except the part where the .bundle file needs to be inserted into .pkg.
Note - there is no option to view the contents of .pkg file build with pkbuild/productbuild
How can i do this process correctly? I would like to link my installer pane plugin to a generic .pkg(with licenses and so on). I'd appreciate any kind of help!
I am experiencing memory leaks in my iOS app that seem to be related to an issue between UIInputView and _UIInputViewContent. After using the memory graph, I'm seeing that instances of these objects aren't being deallocated properly.
The UIInputViewController whichs holds the inputView is being deallocated properly along with its subviews.I have tried to remove all of UIInputViewController's subviews and their functions but the uiInputView is not being deallocated.
The current setup of my app is a collectionView with multiple cell,each possessing a textfield with holds a UIInputViewController.When i scroll up or down,the views are being reused as expected and the number of UIInputViewController stays consistent with the number of textfields.However the number of inputView keeps increasing referencing solely _UIInputViewContent.
class KeyboardViewController: UIInputViewController {
// Callbacks
var key1: ((String) -> Void)?
var key2: (() -> Void)?
var key3: (() -> Void)?
var key4: (() -> Void)?
private lazy var buttonTitles = [
["1", "2", "3"],
["4", "5", "6"],
["7", "8", "9"]
]
override func viewDidLoad() {
super.viewDidLoad()
setupKeyboard()
}
lazy var mainStackView: UIStackView = {
let mainStackView = UIStackView()
mainStackView.axis = .vertical
mainStackView.distribution = .fillEqually
mainStackView.spacing = 16
mainStackView.translatesAutoresizingMaskIntoConstraints = false
return mainStackView
}()
private func setupKeyboard() {
let keyboardView = UIView(frame:CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 279.0))
keyboardView.addSubview(mainStackView)
NSLayoutConstraint.activate([
mainStackView.topAnchor.constraint(equalTo: keyboardView.topAnchor, constant: 16),
mainStackView.leadingAnchor.constraint(equalTo: keyboardView.leadingAnchor, constant: 0),
mainStackView.trailingAnchor.constraint(equalTo: keyboardView.trailingAnchor, constant: -24),
mainStackView.bottomAnchor.constraint(equalTo: keyboardView.bottomAnchor, constant: -35)
])
// Create rows
for (_, _) in buttonTitles.enumerated() {
let rowStackView = UIStackView()
rowStackView.axis = .horizontal
rowStackView.distribution = .fillEqually
rowStackView.spacing = 1
// Create buttons for each row
for title in rowTitles {
let button = createButton(title: title)
rowStackView.addArrangedSubview(button)
}
mainStackView.addArrangedSubview(rowStackView)
}
self.view = keyboardView
}
private func createButton(title: String) -> UIButton {
switch title {
///returns a uibutton based on title
}
}
// MARK: - Button Actions
@objc private func numberTapped(_ sender: UIButton) {
if let number = sender.title(for: .normal) {
key1?(number)
}
}
@objc private func key2Called() {
key2?()
}
@objc private func key3Called() {
key3?()
}
@objc private func key4Called() {
key4?()
}
deinit {
// Clear any strong references
key1 = nil
key2 = nil
key3 = nil
key4 = nil
for subview in mainStackView.arrangedSubviews {
if let stackView = subview as? UIStackView {
for button in stackView.arrangedSubviews {
(button as? UIButton)?.removeTarget(self, action: nil, for: .allEvents)
}
}
}
mainStackView.removeFromSuperview()
}
}
Environment
iOS 16.3
Xcode 18.3.1
Any insights would be greatly appreciated as this is causing noticeable memory growth in my app over time.
Something func applicationWillEnterForeground is not getting called for specific iOS 18.3.2
Topic:
UI Frameworks
SubTopic:
UIKit
Hello.
I use NavigationStack for navigating in app. I have 4 screens - A, B, C, D. In some moment I have path [A, B, C] for NavigationStack. After user did action I should show path [A, B, D]. In other hands I should replace screen C with screen D.
struct HomeView: View {
@ObservedObject var viewModel: HomeViewModel
var body: some View {
NavigationStack(path: $viewModel.path) {
ContentView()
.navigationDestination(for: HomeViewModel.Path.self) { destination in
// B, C, D views here...
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
Solution looks like same as for UIKit. I replaced last item in stack. It works, but "push" animation broke.
var updatedPath = self.path
updatedPath.removeLast()
updatedPath.append(newPathItem)
self.path = updatedPath
I found suggest in Internet that you can remove view from stack after some delay. But it has some magic. For example 1 second delay works properly on iOS 18, but cause crash on iOS 16. 1 millisecond delay works on iOS 16, but sometimes didn't.
self.path.append(newPathItem)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) {
UIView.setAnimationsEnabled(false)
self.path.remove(at: self.path.count - 2)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1)) {
UIView.setAnimationsEnabled(true)
}
}
It is easy task to replace current top screen in UINavigationController of UIKit. How I can do it properly in SwiftUI and save animation?
When I present a view controller, whose view is a SwiftUI View, via presentAsModalWindow(_:) the presented window is no longer centered horizontally to the screen, but rather its origin is there. I know this issue occurs for macOS 15.2+, but can't tell if it is from 15.0+. I couldn't find any documentation on why was this changed.
Here's an example code that represents my architecture:
class RootViewController: NSViewController {
private lazy var button: NSButton = NSButton(
title: "Present",
target: self,
action: #selector(presentView))
override func viewDidLoad() {
super.viewDidLoad()
// Add button to tree
}
@objc func presentView() {
presentAsModalWindow(PresentedViewController())
}
}
class PresentedViewController: NSViewController {
override loadView() {
view = NSHostingView(rootView: MyView())
}
}
struct MyView: View {
/* impl */
}
Various TextField and TextView elements of Apple apps have text edit actions for text correction, but also auto completion.
How can I create such a menu for a TextField in SwiftUI on macOS? the textCompletion modifier did not result in this menu.
Many thanks in advance!
Jan
Topic:
UI Frameworks
SubTopic:
SwiftUI
In SwiftUI for macOS, how can I animate the transition from one Tab to another Tab within TabView when the selection changes?
In AppKit, we can do the following:
let tabViewController = NSTabViewController()
tabViewController.transitionOptions = [.crossfade, .allowUserInteraction]
How can I achieve the same crossfade effect when using TabView?
Background Color Issue in Custom Keyboard Extension in Dark Mode for iOS 18.4.1
Issue Description
I'm developing a custom keyboard extension for iOS 18.4.1 and experiencing an issue with background colors when using Dark Mode. After a user makes a selection from a menu in the keyboard, the background color of a view unexpectedly changes to white instead of maintaining the dark theme color.
Steps to Reproduce
Enable Dark Mode on the device
Activate the custom keyboard in any text field
Perform a specific interaction (selecting an item from a menu)
After selection, the background of the view turns white instead of remaining dark
Technical Details
The issue appears to be related to UIScrollView's background color behavior
The problem doesn't occur on initial display of the menu, only after user interaction
I've attempted to set background colors explicitly on the view hierarchy, but the issue persists
Environment
iOS 18.4.1
Xcode 16.0
Custom keyboard extension
Questions
Has anyone encountered similar issues with view background colors changing after user interactions in keyboard extensions on iOS 18.4.1?
Is there a recommended approach to maintain dark background colors in keyboard extensions after user selections?
Could this be related to a change in how UIScrollView handles background colors in recent iOS versions?
Thank you for any assistance or insights.
Topic:
UI Frameworks
SubTopic:
UIKit
Dear all,
Sorry if the topic has already been commented but I could not be able to find it in over 10,000 picks using the forum search field...
My problem is that with any NSTextField in my app, a click will result in a memory leak. There is no code attached, just bindings to NSNumber properties. How can I fix this ?
Thanks for your help.
Best regards
Chris
Topic:
UI Frameworks
SubTopic:
AppKit
I have an app that run Monte Carlo simulations. I run thousands of simulations in the app and a simulation runs can take on the order of 30 seconds to a minute to complete. I would like to have a progress view that tracks the number of simulation runs. How can I implement this in swiftui?
In my CarPlay app, I am hiding the navigation bar by using the following:
self.mapTemplate?.automaticallyHidesNavigationBar = true
self.mapTemplate?.hidesButtonsWithNavigationBar = false
I don't want the navigation bar to show unless a user interacts with the map by tapping it.
Strangely, when I present a CPNavigationAlert the navigation bar will often appear and then disappear after the alert is dismissed.
Is there a setting or reason that the navigation bar would be appearing when presenting this alert? I would like to keep the nav bar hidden during this time.
In iPadOS 26, the Control Center includes a Multitasking button that lets users switch between full-screen and windowed apps. Is any UISceneDelegate method invoked when this happens, or is there another mechanism by which the app is notified?
Topic:
UI Frameworks
SubTopic:
UIKit
I am working on my app and encountering issues when promoting my app to TestFlight, after I download the app on testflight on my device I am able to log in, however if I minimize the app and try to re-open it again, I get a blank screen, after that, I have tried removing app and reinstalling but no sucess there.
I have compiled the app in release mode in xcode directly (Scheme > Release) and was able to run the app normally and no isues observed in logm only when promoted to testflight for testing
App stack:
Flutter (built using latest Flutterflow build 6.0.34)
Firebase backend
Topic:
UI Frameworks
SubTopic:
General