OSX Notification Center Icon - macos

I'm using OSX's Notification Center APIs for the first time and can't seem to figure out how to make my app's icon to show up in the Notification badge.
The default "your app doesn't have an icon" icon keeps showing up:
Here's what I've done so far
I have created an icns file that includes 512, 256, 128, 32 & 16px versions
dragged the icon into the "App Icon" section of the target's summary
I made to sure to check the box to copy the icon into the project
the plist's "Icon file" section references the correct icon name (minus the .icns) part
Any ideas? The icon doesn't show up when I run the app thru Xcode or when I export an archive either.
I also have extracted the Sparrow.icns file from Sparrow.app and tried using that one instead of the one I made. That didn't work either.

I was able to fix this issue by incrementing the Build number in the General section for the build Target.

You can force the Notification Center to refresh all of the icons by deleting the Notification Center database file (~/Library/Application Support/NotificationCenter/SOME_UUID.db) and then killing the Notification Center process (e.g., from Activity Monitor).
Unfortunately this has the side effect of deleting your notification history, but this wasn't too much of an issue for me.

There's actually an ongoing debate on Apple's developer forums (link, link for people with access) about this. As far as I know, there's currently no real solution, but you can try the following:
Change your app's bundle ID and try it again. If you change it, clean your app, and change back, some people have reported success with seeing their icon show up.
Log in as another user. The caching Notification Center uses may be per-user, so you might be able to get the properly-iconned notifications as a different person.

The folder location has been moved for OSX 10.10+.
Following command takes to you to its new location:
$ cd `getconf DARWIN_USER_DIR`/com.apple.notificationcenter/db
and then
$ open .

Easiest way that I managed to get the icon to show up is change the Bundle Identifier in your project. This works on OSX 10.10.5 and XCode 7.2
(Once notification center picks up the change, you can change it back to your original bundle identifier if you already have a provisioning profile associated with it)

I have solved the issue by archiving my app and adding a copy to my applications folder. When the app is in Application folder, the icon is always visible even you run the app from XCode...

I tried all of the above suggestions but the only thing that worked for me on 10.14 was to delete DerivedData:
rm -rf ~/Library/Developer/Xcode/DerivedData

If anyone still having this issue, and none of the methods above worked, here is how I solved it:
open Notifications from the System Preference (easiest is to open Alfred or spotlight and type Notifications)
find your application and remove it (press backspace/delete button)
NOTE: this may remove all notifications

I am using Xcode 11.5 and I had the same problem. In my case tough, it was sufficient to clean build output, close and reopen the project. Then do a fresh build and let it run again. The icon was there afterwards.
Side note: I've placed the app icon for every size in the assets.xcassets file, except 1024 x 1024 pixels. Don't know if this is relevant or not. Hope that helps.

Related

XCode does not open at all on Mac Mini

I bought an M1 Mac Mini recently and tried to use XCode on it, but it does not open at all.
I tried re-install it and delete ~/Library/Developer directory, it seems nothing works.
This is my first Mac device and if I give more detail about what I mean by 'does not open at all' - it does nothing even if I double click the XCode from Applications directory or the bar at the bottom that has other installed applications showing on it(sorry, I don't know how this is called).
I can see the little grey dot under the icon which means it is running somehow, but nothing comes up on the screen. Then the grey dot goes away after few minutes with nothing happening.
How do I resolve this problem?
Making sure that the application itself is in the right place would be my first approach. Did you download Xcode from the App Store?
Here’s a link to someone with the same issue asking on the Apple developers forum
https://developer.apple.com/forums/thread/101265
Go to applications folder, right click, "get info" and then “Open using Rosetta”. Check the box.

WidgetKit on Mac with Intent doesn't work

I am trying to make a WidgetKit widget for macOS Big Sur. The widget itself works -- the same code on both the Mac and iOS. The issue is that on the Mac the intent (settings) does not work. When I click "Edit Widget" the options I defined do not appear. When I press "Done," it's replaced with a screen that says "Unable to load."
This seems to happen with a brand new target and just a simple new text parameter. These are the steps I took:
Create a new Mac project
Add a new Widget target
Change the generated Intent, adding a parameter. You also need to add a "Siri Dialog Prompt"
Click "Run"
Click "Info" in the Widget Simulator
Click "Configure Intent"
Am I missing something or is this a bug?
This has been an issue since at least Big Sur beta 5 and Xcode 12b6. I opened a ticket with Apple, but I'm also asking here as it seems that some people have it working and it's entirely possible that I'm missing something!
This seems to be a bug of the Widget Simulator. When I run the same Widget in the Widget panel of Big Sur, I see all configuration options.
The problem turned out to be an older copy of the app on my disk and macOS getting confused and looking in the wrong place.
I'm adding a Widget to an existing app that doesn't currently have one. I have the current, App Store version in /Applications. I've been running the updated version from Xcode or exporting it to my desktop and running it from there. The Widget itself -- as noted in the question -- runs just fine. But it seems that when looking for the Intent used for the configuration, it prefers to look in /Application rather than the Xcode version. As soon as I deleted the original app, the widget and its settings immediately started working.
Thanks to Ely for pointing me to this blog which didn't give the answer but pointing me in the right direction.

XCode won't update from App Store

This night I've update my iPhone which I use to test my applications but that caused a problem of "Developer Disk Image", which, as I understood, basically means that Apple wants me to update my Xcode.
However, when I try to do so from "updates" tab in App Store, after I press "update" button, it just simply goes to "waiting" and then back to no progress at all. It does not update after that and the icon of the app in Launcher becomes grey, has a progress bar below it and stays at 0bytes.
I tried to delete the app and download it from the App Store again, but it all ends with Xcode.appdownload file being downloaded and that's it. Even if I try to launch that file (I know it's dumb, but should have tried) nothing happens. How do I get my App Store to work again?
Ok, I solved the issue - even though it does not mention System Updates anywhere, all I had to do is to update OS first. C'mon, Apple inc. get your scheiße together, just bugging away is not an answer!
The Mac App Store is broken beyond repair. You can try to reload the update page using CMD-R. That helps sometimes. In addition, Launchpad normally shows the progress correctly.
You can also update from Terminal.app using the command
softwareupdate -l
Good luck!

OSX Removing app data from Xcode

New to OS X development and have tried removing ~/Library/Developer/Xcode/DerivedData from my system, Product>Clean but still wouldn't wipe the data. I know its much simpler in iOS simulator. Any advise on removing OS X app data completely so that it runs like as if its the first time?
Unlike iOS apps, macOS apps don't delete all of their data when uninstalled.
Assuming the data you are referring to is stored in the UserDefaults, this is the solution I found to test the app first launch.
Quit Xcode
Remove the DerivedData folder
Delete the UserDefaults plist file. Depending on your app's configuration it will be in one of these locations (more info in this answer):
Sandboxed apps:
~/Library/Containers/com.example.myapp/Data/Library/Preferences/com.example.myapp.plist
~/Library/Containers/com.example.myapp/Data/Library/SyncedPreferences/com.example.myapp.plist
Non sandboxed apps:
~/Libraryf/Preferences/com.example.myapp.plist
~/Library/SyncedPreferences/com.example.myapp.plist
Relaunch the app from Xcode
If the only thing you need to test is a flow based on a "first launch flag" (a Bool in the UserDefaults that is set to true after first launch), you can reset that one along with this command:
defaults write com.example.myapp "settingName" "0"
You'll still have to quit Xcode, delete the DerivedData, and re-open Xcode for the change to take place.
Note that sometimes this doesn't work on the first try. I'm not sure why but I'm guessing Xcode does some state tracking inside that gets in the way. In my experiments, I had to restart Xcode a few times before getting it to read the updated defaults.
Oh just open up the Simulator and click (and hold) on the app icon. Then it'll shake and you click the 'x' in the corner to delete the app and its data.

Launch image doesn't update

I'm using Xcode 4.3.1. Adding launch image is pretty simple -- just drag the image to the Project->Summary->Launch Images window.
So I set a launch image before and it worked. But when I dragged a different image and run the app on my iPhone again, the launch image still remain the same as the old one. Even after I delete the launch image from the Launch Images window, the old image still shows up upon launching.
I've tried clearing the build as well. Didn't work.
Help please. Very much appreciated!
I had the same issue, but with launch storyboard. I had to rename the image I've used as a background.
Deleting from the device didn't help with Xcode 4.5.1. The build process is caching the image. With a hint from Zorayr's answer to related question "Xcode, can't remove “Launch image” from project," I decided to track the cached image down and destroy it, so it wouldn't keep being built and showing up in my test App.
Eventually, I found that Xcode (at least 4.5) builds the images by default in the following path off your home directory:
~/Library/Developer/Xcode/DerivedData/<ProjectName>-<uniqueID>/Build/Products/<Scheme>-iphone{os,simulator}/<ProjectName>.app/
So in addition to removing the old App image from the device (or simulator,) you also need to remove the image file(s) from the build cache. But just doing something like
rm ~/Library/Developer/Xcode/DerivedData/MyProject-fpwnjlbayydgzxcdlyrwxrwntapr/Build/Products/Debug-iphoneos/MyProject.app/Default*.png
won't always solve your problem. Instead, you might get a strange error in a popup window saying something like "Signed product moved or deleted." (I can't reproduce it right now to get the exact text.) It doesn't show up in the log file, and it just hangs the build process (in Xcode 4.5.1.) To get around that, I deleted all of the files under the <ProjectName>.app/ directory tree and the sibling directory tree <ProjectName>.app.dSYM/ containing (seemingly) the symbol tables and signature files for the parallel products. The build process will then re-create everything with no more complaints.
What worked for me on iOS 10.2.1, iPhone 5s hardware test device, Xcode 8.2.1
I think it has nothing to do with Xcode. The test device appears to be caching the LaunchScreen.storyboard image. I needed to reboot my device by holding home + top button. Then I rebuilt, low and behold, the image updated.
You should delete the app from the device, then launch it again.
Quit the simulator and then run the project again.
For device, as mentioned in other answers, delete the app from the device and then run the app again.
Steps that worked for me in 2020 (xCode Version 11.4.1):
Delete derived data
Restart xCode
Delete app on device
Restart device
Clean rebuild and run
Except the last step, I think the order doesn't matter.
It's really annoying though and I'm not even sure if it always works.
Pretty pathetic on apple's side. Good luck guys!
If you were using an asset catalog, it can also help to delete the images from the Images.xcassets file, and then load them manually in General>Launch Images.
This is what worked for me
Put the new image in project folder
Run app on device/simulator
Put image in xcassets under a different name
Run app again and it works
I thought I would create an update for anyone who is XCode 10 (and possibly XCode 9) and experiencing a blank black or white screen after modifying a launch image.
In my case I had to create launch images for the iPhone XR, iPhone X, iPhone XS and iPhone XS Max.
Originally I just had a sample white launch image for testing. After creating my proper image for the XR and replacing the sample the change would simply never show (on the XR device). I would still get a white screen.
I tried all of these in combination and failed:
-deleting the app beforehand.
-deleting xcode derived data and cleaning the build.
-restart Xcode and the device and the computer.
-deleting any existence of the white launch image on the computer.
-manually editing the JSON in a new images asset with the correct file names
The XR device would continuously show a white screen and after meddling with the build setting and migrating back to image packs it turned to black.
Solution:
Ultimately it started working after I also replaced the white 'XS' launch image with a new one as well. Even though the device is an XR. This is an odd solution but solutions like this have helped with launch images throughout the years.
For me, quitting the Simulator and restarting it worked -- I can finally see the updated launch image. The note above from Emil Korngold triggered me to try this.

Resources