I have a question about the app lifecycle when my app is launched via a Shortcut. I'm adding a INIntent to a Mac app. So my app delegate implements:
- (nullable id)application:(NSApplication *)application handlerForIntent:(INIntent *)intent
Then my custom intent handler implements the two protocol methods -confirmIntentNameHere:completion: and -handleIntentNameHere:completion:
During my testing -applicationDidFinishLaunching: is called before the intent methods, so I can forward methods to my main window controller to perform the shortcut actions, since it's already ready.
....But if this is not always the case, I can still perform them but I'd have to move the code out of the window controller to perform the action "headless" if invoked before my app has built its UI. Just wondering if this is something I should be prepared for.
Thanks in advance.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have an outside Mac App Store app. It has an action extension. I can't get it to run from Xcode. I try to debug it from Safari. It shows up in the menu when I click the 'rollover' button but it doesn't show up in the UI at all. Xcode doesn't give me any indication as to what the problem is. I see this logs out in console when I try to open the action extension:
Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={TCCDProcess: identifier=BundleIdForActionExtHere, pid=6650, auid=501, euid=501, binary_path=/Applications/AppNamehere.app/Contents/PlugIns/ActionExtension.appex/Contents/MacOS/ActionExtension}, requesting={TCCDProcess: identifier=com.apple.appleeventsd, pid=550, auid=55, euid=55, binary_path=/System/Library/CoreServices/appleeventsd},
I don't see why the Action extension needs Apple events but I added it to the entitlements anyway but it doesn't seem to matter. The action extension fails to open.
If I do this:
NSString *name = @"Jim";
NSMenuItem *menuItem = [[NSMenuItem alloc]init];
// Analyze does show localization warning when format string is used.
menuItem.title = [NSString stringWithFormat:@"Hello %@",name];
I expect to get the following warning:
User-facing text should use localized string macro
But I don't. However if I do this:
menuItem.title = @"What";
I do get the warning about localization as expected and as desired when I run Analyze. Is this considered a bug?
Thanks!
If I try making a bitmap of a NSButton using the following code:
NSBitmapImageRep *rep = [button bitmapImageRepForCachingDisplayInRect:button.bounds];
[button cacheDisplayInRect:button.bounds toBitmapImageRep:rep];
NSData *tiffData = rep.TIFFRepresentation;
I get a blank image if the NSButton has its bezelStyle set to NSBezelStyleGlass.
If I change the bezel style to something else like NSBezelStyleFlexiblePush I do get an image
I just updated to macOS 26.1.
I have a pure AppKit app (I guess that's not possible anymore but as close to a pure AppKit app as you can get).
I use NSButton with the glass bezel style and SF symbol images. It looks like the minor OS update brought layout changes because now some of these buttons are scaling the symbol image much larger than was being done on macOS 26. The image can sometimes draw outside the glass 'bezel'. It looks like using the 'info' symbol in a button results in much larger image scaling than it did on the previous Tahoe for some SF Symbols.
With the glass bezel style and a SF Symbol image how am I supposed to consistently make the button look good? With certain symbols I have to use imageScaling NSImageScaleProportionallyUpOrDown and on others I have to use NSImageScaleProportionallyDown. If I'm using a system image shouldn't it just do the right thing? Is trial and error the only way to tell? That's what I was doing before but it seems that the minor 26.1 update changed things.
Additionally calling -sizeToFit on a button multiple times can cause it to shrink for example:
[button sizeToFit]; // <-- At fitting size
// Then later
[button sizeToFit]; // Now button is shrunk
But if the button is already at its fitting size an additional call later shouldn't make it shrink, it should stay the same size. FB20517174
I see I now inherit SwiftUI, not sure if that has anything to do with this but if I wanted to opt in to fragile layout I wouldn't be using Appkit...
When I run my Mac Catalyst app I'm getting unacceptable performance when resizing the window. Window resizing is very unresponsive/laggy.
Configuration:
The root view controller is a UISplitViewController (three pane split using UISplitViewControllerStyleTripleColumn).
Sidebar is configured. It's using a UICollectionView sidebar style (so it looks like NSOutlineView in AppKit).
On initial launch there is no selection and the second and third view controllers in the split have empty placeholder view controllers.
At this point window resizing is fine.
Now I make a selection in the sidebar. This populates the supplementary view controller with a view controller that uses a UITableView.
Now resizing the window performance is awful. Basically this is unusable. When resizing the window a bunch what looks to be Core Animation related logs flood the console during window resize:
cannot add handler to 3 from 1 - dropping Library: QuartzCore | Subsystem: com.apple.coreanimation
Now if I go to my app's Info.plist and add: UIDesignRequiresCompatibility entry with a value of TRUE and follow the same steps described above window resizing works as expected and I do not experience performance issues. Also with UIDesignRequiresCompatibility there is no "cannot add handlers" error logs flooding the console on window resize.
So I noticed this:
A sheet window is presented.
The sheet window has some UI that makes it expandable say a little arrow expandable button.
Click the little expandable button. Now the sheet window controller calls - (void)setFrame:display:animate: on its window to resize.
The parent window flies across the screen to the lower left corner.
I'm on Tahoe 26.1. Seems to be related to NSSheetMoveHelper. Not sure how long this bug has been around. Workaround is to call -setFrame:display:animate: and pass NO to the animate flag. Then the sheet window resizes (but not animated which doesn't look as good as the old behavior but better than suddenly disappearing).
I think Apple may already knows about this bug b/c in an Apple app on Tahoe I see a sheet resizing being done with no animation...
So my app creates user notifications. Sometimes when I tap one of these notification to open the app, it crashes. It happens seemingly randomly and is not easy to reproduce. My app's UNUserNotificationCenterDelegate does something like this (shortened to keep the post concise):
-(void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void(^)(void))completionHandler
{
if (![response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier])
{
//only care about the default action...return out otherwise.
completionHandler();
return;
}
completionHandler();
UNNotificationRequest *request = response.notification.request;
NSString *requestIdentifier = request.identifier;
if (requestIdentifier == nil)
{
return;
}
[database selectModelFromId:requestIdentifier withCompletionHandler:^(MyModel *modelObj,
NSError *errorOrNil)
{
if (modelObj != nil)
{
[self makeWebViewControllerForModeAndPutOnScreen:modelObj];
}
else
{
NSLog(@"error loading data for notification...");
}
}];
}
Okay so the view controller loaded uses WKWebView to load web content. Again every once in awhile the app crashes when I tap a notification. No crash report is ever generated for my app. I don't know why this is happening. Anybody experience anything similar and know what the issue could be? Thanks in advance.
I'd like to test how my app behaves when the user signs out of iCloud and my app is in memory. In the iOS Simulator, the "Sign Out" button for iCloud is grayed out so I can't use the simulator to test. I'm hesitant to use a real device tied to my Apple ID because signing out of iCloud System wide has side effects with many apps and I don't want to potentially lose any data.
However, I did test on a real device by going the Settings app -> iCloud and disabled iCloud only for my app. When I do this, the system terminates my app and does not post a CKAccountChangedNotification.
I only tested turning off the iCloud switch for my app. Does the system simply terminate apps when the user logs out of iCloud system wide too? In what cases is the CKAccountChangedNotification posted? Detecting sign out by listening for CKAccountChangedNotification would seem to be pointless if apps are terminated when the user signs out of iCloud.
I'd like to resize a UITargetedPreview as part of a custom animation.
I tried doing this by using the animator provided in:
- (void)tableView:(UITableView *)tableView willDisplayContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(nullable id<UIContextMenuInteractionCommitAnimating>)animator
But resizing the source view for the target preview does not cause the container view to resize with it (leaving a large gap after my custom animation completes). So my preview is wrapped in a visual effects view that doesn't downsize with UITargetedPreview's view I provided.
I also tried wrapping a snapshot view in a UIViewController and using previewProvider block instead of using a UITargetPreview.
I am able to resize the previewViewController by setting the preferredContentSize property and resizing works, but it still doesn't look right because the default animation for the preview view controller breaks with the custom animation I'm trying to implement.
Anyone know if this is possible?
Testing my app, I noticed a button in my UI which presents a UIAlertController appeared to do nothing all of a sudden, after a few days.
So hooking up the console app I see UIKit spit out the following log when I press the button:
"Warning: Attempt to present UIAlertController on MyViewController which is already presenting SomeOtherViewController.
No view controller appears to be presented. SomeOtherViewController is not currently in the UI but for some reason after it was dismissed the presentedViewController property wasn't set to nil (haven't been able to reproduce the issue yet).
So SomeOtherViewController I know is a "Detail View Controller" which only get pushed on the UINavigationController stack (I never present it modally). The only time it gets presented modally is when it is a "preview view controller" used in UIContextMenuConfiguration, but otherwise it doesn't get presented. Has anyone run into this sort of situation before and know of a potential cause/solution?
The presentedViewController does not appear on screen but for some reason UIKit is holding a strong reference to it in the presentedViewController property which prevents subsequent calls to -presentViewController:animated:completion:
As a workaround I could try using the code below but I'd really like to find the root cause of the issue:
-(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
UIViewController *currentPresentedVC = self.presentedViewController;
if ([currentPresentedVC isKindOfClass:[SomeOtherViewController class]])
{
//this is unexpected.
[currentPresentedVC dismissViewControllerAnimated:NO completion:^{
[super presentViewController:viewControllerToPresent animated:flag completion:completion];
}];
}
else
{
[super presentViewController:viewControllerToPresent animated:flag completion:completion];
}
}
Trying to use UISplitViewController. Since this app can be run on many different monitor sizes I want to allow the splits to be resized reasonably. There is this API:
//Allow setting the primary column width with point values. This is especially useful in Catalyst where the window may be resized more often.
// If set to non-Automatic, takes precedence over preferredPrimaryColumnWidthFraction.
@property(nonatomic, assign) CGFloat preferredPrimaryColumnWidth API_AVAILABLE(ios(14.0)); // default: UISplitViewControllerAutomaticDimension
> > @property(nonatomic, assign) CGFloat minimumSupplementaryColumnWidth API_AVAILABLE(ios(14.0));
@property(nonatomic, assign) CGFloat maximumSupplementaryColumnWidth API_AVAILABLE(ios(14.0));
// An animatable property that can be used to adjust the minimum absolute width of the primary view controller in the split view controller.
@property(nonatomic, assign) CGFloat minimumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: UISplitViewControllerAutomaticDimension
// An animatable property that can be used to adjust the maximum absolute width of the primary view controller in the split view controller.
@property(nonatomic, assign) CGFloat maximumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default:
At what point in time should I be changing the preferredPrimaryColumnWidth, the min/and max width values? What event? If I was in Appkit I could maybe use something like NSWindowDidResizeNotification, then compute min/max sizes for each column based off the current window size (but I think NSSplitView gives the delegate an opportunity to control constraining column sizes if I remember correctly so I don't think that it would necessary to listen for a window resize event).
I find the default sizes set by UISplitViewController to be insufficient (I want to allow users to size columns wider). Ideally this would be easier if there was minimumPrimaryColumnFraction and maxPrimaryColumnFraction. Then I just set the min/max fractions once to reasonable values and not worry about changing them on window resize. But since we can only set min/max with a hardcoded point size it seems more complicated?
I can't seem to get rid of the "vibrancy" effect on the titlebar/toolbar area of the window on Mac Catalyst. I have a triple Split View controller.
The primary vc style is sidebar in the split vc.. And that has the blur/visual effect and that's all well and good.
But the title bar area on the supplementary column has the blur effect too and it looks kind of terrible (the navigation bar in the supplementary view controller has all of its navigationBar appearances configured with opaque content:
UINavigationBarAppearance *opaqueAppearance = [[UINavigationBarAppearance alloc]init];
[opaqueAppearance configureWithOpaqueBackground];
opaqueAppearance.backgroundEffect = nil;
opaqueAppearance.backgroundColor = [UIColor myColor];
//set to all appearances
But I still get the blur effect on the navigation bar, which presumably is being mapped to NSToolbar. Is it possible to disable this blur effect for the column? It really doesn't look good in my app.
Is it possible to create a popover in Mac Catalyst that allows you to detach it into a new window like NSPopover?
https://developer.apple.com/documentation/appkit/nspopoverdelegate/1534822-detachablewindowforpopover?language=objc
Thanks in advance
On macOS it is typical for apps to have a "Done" button showing at the bottom of a window sheet. Usually the button is blue (or whatever your system accent color is set to) and this button can be invoked by pressing the return key.
On NSButton all you do is assign the return key as the key equivalent. So in the Mac Catalyst environment how do I achieve this behavior? I'm able to get the button to look exactly how I want configuring UIButton like this:
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeSystem];
[doneButton setTitle:@"Done" forState:UIControlStateNormal];
doneButton.role = UIButtonRolePrimary;
Is there a quick way to get its action to be invoked when the return key is pressed or do I have to manually implement UIKeyCommand?
Thanks in advance to anyone who answers.