Posts

Post not yet marked as solved
1 Replies
514 Views
I have a SwiftUI document based app where multiple documents can be open at the same time. I now want to have menu items in the main menu that send commands to the active window. Additionally, I want menu items to be disabled if no matching object is selected in the active window. As an example Finder can be used, where in the "Edit" menu the entries are different depending on the selected files. I tried using a class as shown below to communicate between the views and the Commands structure, which basically works. Unfortunately, this causes a command to arrive at all open documents. And if I have an entry selected in one window but not in another, the AppState object only reflects the last selected state. If I change the window, the app does not notice this for the time being. class AppState: ObservableObject { static let shared = AppState() @Published var dirEntryCommand = PassthroughSubject<DirCommand,Never>() @Published var selectedDirEntry: DirectoryEntry.ID? } The Commands struct looks like this: enum DirCommand: Int, Identifiable, CaseIterable { case rename case moveUp case moveDown var id: RawValue { rawValue } } struct DirEntryCommands: Commands { @ObservedObject var appState = AppState.shared var body: some Commands { CommandMenu("Directory Entry") { Section { Button("Move up") { appState.dirEntryCommand.send(.moveUp) } .keyboardShortcut("u") Button("Move down") { appState.dirEntryCommand.send(.moveDown) } .keyboardShortcut("d") } .disabled(appState.selectedDirEntry == nil) Section { Button("Rename…") { appState.dirEntryCommand.send(.rename) } .keyboardShortcut("r") } .disabled(appState.selectedDirEntry == nil) } } } It is possible that I am taking the wrong approach and that there is another solution to this problem. In a pure AppKit application I would implement the relevant commands in the ViewController and use the "magic" of the ResponderChain.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
In a project that uses the Combine Framework, the following error suddenly occurs: Failed to build module 'Combine'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 (swiftlang-1300.0.24.14 clang-1300.0.25.10)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.24.13 clang-1300.0.25.10)'). Please select a toolchain which matches the SDK. I must confess that I do not understand what the problem is. Is this an Xcode problem or can I solve it myself? Strangely enough, I was able to compile and run the project several times before without any problem. Furthermore, the error is not displayed in my code, but in the package https://github.com/MaxDesiatov/XMLCoder which I included using cocoapods.
Posted Last updated
.
Post not yet marked as solved
4 Replies
790 Views
I've a small extension for the Date type with some simple helper methods like func dateByAdding(components: DateComponents) -> Date? { return Calendar.current.date(byAdding: components, to: self) } Now there's one class where Xcode 13.0 beta 2 keeps telling me Type 'Date' has no member 'dateByAdding' while in another class the extension works as expected. All files are 100% swift and all relevant files have a Target Membership of the same target. I've tried the usual things like removing the Derived Data folder, but without success. Any ideas what could cause this?
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.5k Views
Hi there, is there any way to select which interface the network link conditioner affects? I found an old article (https://discussions.apple.com/thread/3287471), which suggest using ipfw commands, but that does not seem to work in MacOS BigSur (I'm on 11.2.2 (20D80)). BR Dirk
Posted Last updated
.
Post not yet marked as solved
0 Replies
271 Views
Hi all, I've a UITableViewController wich display a search bar by assigning a search controller to it's navigationItem.searchController property. It also displays a section index with UITableView.indexSearchas first element. Is there any way to force the navigation bar to show the search bar, when the corresponding section index is tapped. In tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index; I'm only able to return a section index. navigationItem.hidesSearchBarWhenScrollingis set to true, so even returning 0 only displays the first section. I need to scroll down manually, for the search bar to become visible. Dirk
Posted Last updated
.
Post not yet marked as solved
0 Replies
482 Views
Hello,I'm trying to get a little smarter about core Bluetooth. :-)I have an app on device 1 which advertises a service using peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey:[serviceCBUUID], CBAdvertisementDataLocalNameKey: localName])On a second device I use centralManager.scanForPeripherals(withServices: [serviceCBUUID], options: [CBCentralManagerScanOptionAllowDuplicatesKey:true])to be notified as soon as a device with the desired service is available.So far everything works without any problems.However, if I carry out the following steps on device 1:Put the app in background (the corresponding background mode is activated)Bring the app back to foreground.End the advertising of the service with peripheralManager.removeAllServices() peripheralManager.stopAdvertising()Then the following delegate method is still called on device 2. func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi RSSI: NSNumber)The strange thing is that even when I connect to the device and useperipheral.discoverServices([serviceCBUUID])to ask for my service, I get an empty list. Which is ok, since I've stopped avertising on device 1, but why is the device detected at all when I explicitly ask for devices that provide my service?This only happens, when I put the app in background on device 1. If I keep it in foreground, the delegate method on device 2 is no longer called as soon as I stop advertising on device 1.I need to turn bluetooth off in settings on device 1 to stop this. Restarting the app and stopping advertising does nothing.BRDirk
Posted Last updated
.
Post not yet marked as solved
0 Replies
462 Views
Hi,was anyone able to submit a bug report using the feedback app? The data entry works, but when sending only an error message appears: "Error when sending...".So I tried the new web app (https://feedbackassistant.apple.com/) but this seems to ignore my entered text. All I get is an "Untitle Feedback" with none of the data (besides the attachements) saved.Dirk
Posted Last updated
.
Post marked as solved
1 Replies
1.4k Views
Hello,I prepared an iPad app for running on MacOs and after a few small corretions I was able to build the app. However, it crashes right on startup.The function - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions is called, where I prepare a window and the root view controller in code. After the function returns, the app crashes.This is what the log looks like:2019-06-08 13:25:04.804240+0200 myApp[3865:61331] Bundle is missing UIMenuBarItemTitleAbout key. 2019-06-08 13:25:04.806248+0200 myApp[3865:61331] Bundle is missing UIMenuBarItemTitleHide key. 2019-06-08 13:25:04.806325+0200 myApp[3865:61331] Bundle is missing UIMenuBarItemTitleQuit key. 2019-06-08 13:25:04.814513+0200 myApp[3865:61331] Bundle is missing UIMenuBarItemTitleHelp key. 2019-06-08 13:25:12.159975+0200 myApp[3865:61331] [General] An uncaught exception was raised 2019-06-08 13:25:12.160042+0200 myApp[3865:61331] [General] *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: title)myApp2019-06-08 13:25:12.160241+0200 StundenplanHD[3865:61331] [General] ( 0 CoreFoundation 0x00007fff3aaa7c63 __exceptionPreprocess + 250 1 libobjc.A.dylib 0x00007fff6ff7006b objc_exception_throw + 48 2 CoreFoundation 0x00007fff3ab6712a _CFThrowFormattedException + 202 3 CoreFoundation 0x00007fff3ab70ec5 -[__NSDictionaryM setObject:forKey:].cold.3 + 0 4 CoreFoundation 0x00007fff3a9fdf6e -[__NSDictionaryM setObject:forKey:] + 979 5 UIKitCore 0x00007fff76c3d9fc -[_UIMenuBarItem properties] + 99 6 UIKitMacHelper 0x00007fff6aaf0108 _insertUINSMenuItemsIntoNSMenu + 786 7 UIKitMacHelper 0x00007fff6aaf0c21 UINSNSMenuFromUINSMenu + 119 8 UIKitMacHelper 0x00007fff6aaf0d0b -[UINSMenuController _createNSMenu:forContextMenu:] + 79 9 UIKitMacHelper 0x00007fff6aaef9f2 -[UINSMenuController setMainMenuBar:] + 70 10 UIKitCore 0x00007fff7796044b -[_UIMenuBarController _rebuildRootCommandGroup] + 229 11 UIKitCore 0x00007fff76b12054 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 801 12 UIKitCore 0x00007fff775901f6 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 5764 13 UIKitCore 0x00007fff76b10745 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1342 14 UIKitCore 0x00007fff76eafd8e -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122 15 UIKitCore 0x00007fff772715c2 _UIScenePerformActionsWithLifecycleActionMask + 78 16 UIKitCore 0x00007fff76eb0891 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198 17 UIKitCore 0x00007fff76eb0361 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 467 18 UIKitCore 0x00007fff76eb06c6 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 811 19 UIKitCore 0x00007fff76eaff69 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 350 20 UIKitCore 0x00007fff76eb4383 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 159 21 UIKitCore 0x00007fff771d9126 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 832 22 UIKitCore 0x00007fff7728e1a4 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240 23 UIKitCore 0x00007fff76eb3fa0 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 167 24 UIKitCore 0x00007fff7728e0a7 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 84 25 UIKitCore 0x00007fff76eb3df4 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 365 26 UIKitCore 0x00007fff76d5f093 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 541 27 UIKitCore 0x00007fff76d5df4d -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 389 28 UIKitCore 0x00007fff76d5ee10 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 404 29 UIKitCore 0x00007fff76b0c635 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 551 30 UIKitCore 0x00007fff76b0c388 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361 31 FrontBoardServices 0x00007fff5630940c -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 453 32 FrontBoardServices 0x00007fff563284f2 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.162 + 102 33 FrontBoardServices 0x00007fff56311e49 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220 34 FrontBoardServices 0x00007fff56328185 __86-[FBSWorkspaceScenesClient sceneID:createWithParamet 35 libdispatch.dylib 0x00000001007f198f _dispatch_client_callout + 8 36 libdispatch.dylib 0x00000001007f51e3 _dispatch_block_invoke_direct + 289 37 FrontBoardServices 0x00007fff562f7c64 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30 38 FrontBoardServices 0x00007fff562f7a2a -[FBSSerialQueue _performNext] + 436 39 FrontBoardServices 0x00007fff562f785e -[FBSSerialQueue _performNextFromRunLoopSource] + 33 40 CoreFoundation 0x00007fff3aa12fa5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 41 CoreFoundation 0x00007fff3aa12f35 __CFRunLoopDoSource0 + 112 42 CoreFoundation 0x00007fff3a9f699e __CFRunLoopDoSources0 + 209 43 CoreFoundation 0x00007fff3a9f5f9e __CFRunLoopRun + 1272 44 CoreFoundation 0x00007fff3a9f5821 CFRunLoopRunSpecific + 499 45 HIToolbox 0x00007fff396d57fd RunCurrentEventLoopInMode + 292 46 HIToolbox 0x00007fff396d5449 ReceiveNextEventCommon + 356 47 HIToolbox 0x00007fff396d52c7 _BlockUntilNextEventMatchingListInModeWithFilter + 64 48 AppKit 0x00007fff37d84cf8 _DPSNextEvent + 990 49 AppKit 0x00007fff37d83a6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352 50 AppKit 0x00007fff37d7e1b7 -[NSApplication run] + 658 51 AppKit 0x00007fff37d7004b NSApplicationMain + 777 52 AppKit 0x00007fff381f4022 _NSApplicationMainWithInfoDictionary + 16 53 UIKitMacHelper 0x00007fff6aad1ef9 UINSApplicationMain + 424 54 UIKitCore 0x00007fff76af6a91 UIApplicationMain + 2206 55 StundenplanHD 0x0000000100001ed0 main + 112 56 libdyld.dylib 0x00007fff712ce7a9 start + 1 57 ??? 0x0000000000000003 0x0 + 3 )Is there anything I need to configure in addition?
Posted Last updated
.