Asset Catalog

RSS for tag

An asset catalog is a type of file used to organize and manage different assets and image resolutions used by your app’s user interface.

Posts under Asset Catalog tag

39 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

macOS app icon not updating. Cached?
Hi, If I change the AppIcon in Xcode's Assets.xcassets, and rerun my app, the image used in the dock and app switcher does not update. If I "Clean Build Folder", and re-run, then it updates. This is annoying when I keep tweaking the colors in the icon and want to see how they look. A full rebuild takes a while, because I have a few Swift Package dependencies. Anyone know a trick to get the AppIcon to stop caching (or whatever it's doing)? I tried killall Dock and killall Finder, but that didn't help. (macOS 11.2.3) Rob
4
0
3.4k
Oct ’23
Why would i not activate 'Preserve Vector Data' for SVGs?
First off, i believe i do know what the option 'Preserve Vector Data' does. But just in case, let me recap: When using PDFs or SVGs in my Asset Catalog, Xcode by default creates assets at fixed sizes from these files at buildtime. When i tick the 'Preserve Vector Data' box, the asset is scaled at runtime using the vector data, allowing for smooth scaling and crisp images at any scale. But the question i'm asking myself now is what exactly is the drawback - most likely performance-wise - to simply activating this option for each an every SVG or PDF Asset i use in my project? I would be very happy if someone could elaborate on this or direct me to some more in-depth documentation on Vector Assets :)
2
2
2.8k
2w
Missing App Icon in Asset Catalog - 1024 x 1024 on Xcode 14
I've searched and searched for the past 2 days and I can't seem to solve this at all, there seems to be a lot of different advice for different versions of Xcode, but nothing I try can get past this. I can't publish my ipa because of this. I have an app which has a Asset Catalog (Media.xcassets) which has an icon set called AppIcon - which I've generated a few times, directly in the UI of Xcode and Visual Studio. I've added all images to the ios section and the mac section within the asset catalog - choosing All Sizes (and not Single Size) and can see them referenced all nicely in the json file - there are no warning symbols against any of my icons to indicate they are the wrong size. None of the symbols have any alpha channel set against them, they are all pngs. I've even tried with a completely black image. I have this referenced in my info.plist (that refers to icons), and XSAppIconAssets is at the top: I have the Primary App Icon Set Name referenced in Asset Catalog Compiler - Options correctly and App Icons and Launch Screen options are as follows: If I remove some references to my images in the Asset Catalog - I get specific errors on them and when I add them back in, the errors disappear, so I know the Asset Catalog is referenced OK - I just can't seem to get rid of this obnoxious Missing App Icon error on the 1024x1024 one though Any help would be greatly appreciated, this is doing my head in!
5
1
3.9k
Sep ’23
Xcode console output is full of CoreUI warnings about image subtype mismatches when running on Mac Catalyst
CoreUI is sending warning messages to the Xcode console when creating a UIImage from an image file with Mac idiom from the asset catalog, while running on Catalyst. My target is set to support running on Mac Catalyst with Optimize for Mac enabled (the latter seems to be the most important part). Loading the image into a UIImage with the designated initializer and presenting it in a UIImageView produces the following console messages: 2023-02-15 10:53:18.014394+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014446+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014503+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014533+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. Working with more than a handful of images from the catalog makes the Xcode console output borderline unreadable because of these messages. The console doesn't have an option to filter out messages (and in general we consider it bad practice to ignore messages on the console). Tested on Xcode 14.2 with macOS 13.2. You can find a sample project at https://github.com/tamasjager/CatalystImageConsoleMessage.
4
5
2.4k
Oct ’23
Incorrect image alpha rendering on Xcode 15b3 and iOS 17
I'm not sure if I'm changed an unknown-to-me setting somewhere, but since this morning, after profiling an app (metal, allocations, etc), every project I run/build on Xcode 15b3, either on simulator or on device, displays partially-alpha images blended to black, as if there was some problem in the process of compiling the PNGs (lack of premultiplying, color space, etc). If I open those same projects on Xcode 14, they are displayed everything as they should. Also, If I open them on other computers with Xcode 15b3 other than mine, it also works fine. And it was working fine for me this morning as well, but not anymore. I've tried uninstalling Xcode beta and the simulator a few times, cleaning folders and preferences, hoping it was some setting I changed by mistake with some hotkey, but no luck so far. I'll attach two pictures, one from Xcode 14, and the other one from Xcode 15b3, hoping it's some silly thing I'm missing. xc15b3: xc14:
21
5
4.5k
Mar ’24
GenerateAssetSymbols wrongly renaming image assets
Xcode generates symbols for image and color assets now (which is super nice!). We noticed an issue when generating code symbols for our image assets. We have an image named inputContour and one named inputContourColor. Xcode was not able to generate a symbol for inputContourColor and instead produced the following warning: #warning("The \"inputContourColor\" image asset name resolves to the symbol \"inputContour\" which already exists. Try renaming the asset.") It turns out that the generator automatically removes the color suffix when creating the code symbol. For color assets, this probably make sense (so tealColor would become just teal), but this should not be applied to image resources.
10
1
4k
Dec ’23
Are SVG assets faster than PNG when rendered or not?
I recently was thinking about which is the best format to use for my little icons in the app, and was considering the performance of PNG versus SVG . I know that PNG decoders are hardware accelerated and parallelized, and the rendering is as simple as placing the pixels on the screen. On the other hand, SVG requires computation to determine the placement of pixels based on mathematical equations. Considering this, my current assumption is that PNG is faster to render than SVG. However, if SVG is also hardware-accelerated, it could alter the situation, although this may not be the case.
1
0
1.3k
Sep ’23
Assets.car increased in size significantly in Xcode 15
The Assets.car file in Archive and thus in exported .ipa file has significantly increased when archived in Xcode 15 compared to Xcode 14.3.1. For example, the Assets.car file size in the archive made in Xcode 14.3.1 is 125 MB, but in the archive made in Xcode 15 from completely the same project size is 200 MB. Assets have many images as PNG and PDF. What has changed in Xcode 15 for building Assets.car file and how the size can be reduced? Use SVG instead of PDF (and PNG?)? Thanks
0
0
870
Sep ’23
NSImages blurred-out in Sonoma
My app uses various PNG images for parts of its UI. In Sonoma these images are rendered all blurred. It looks like I'm putting a 10 or 20px gaussian blur on it, which of course I am not. In prior macOS versions they have rendered just fine. Occasionally some user action in the app will cause a part of one or two images to render sharply, but then it quickly reverts to the blur. I have added the PNGs to the app as image set assets, providing 1x and 2x versions for light and dark modes respectively (so four images each). I'm loading them using NSImage(named: ), and in most cases putting them into an NSImageView. I also use one of them as a patternImage: if let image = NSImage(named: "RackFrame") { let color = NSColor.init(patternImage: image) color.setFill() dirtyRect.fill() } Both methods result in the same issue. Any thoughts on what's going on would be gratefully received!
0
0
684
Sep ’23
WebP image in Asset Catalog?
It appears I can't add a WebP image as an Image Set in an Asset Catalog. Is that correct? As a workaround, I added the WebP image as a Data Set. I'm then loading it as a CGImage with the following code: guard let asset = NSDataAsset(name: imageName), let imageSource = CGImageSourceCreateWithData(asset.data as CFData, nil), let image = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) else { return nil } // Use image Is it fine to store and load WebP images in this way? If not, then what's best practice?
0
0
1.1k
Oct ’23
In-App purchase review screenshots for data assets
My In-App purchases are actually JSON files which provide metadata for my app. I am required to provide a "screenshot" for each of these IAPs before they can be accepted. What is the common practice for screenshots when it is just a JSON file of structured data to be used within the app. Surely someone else has run into this issue by now. What are we supposed to do?
4
0
890
Nov ’23
Avator Creator, null image issue
"I am developing a project called 'Avatar Creator.' In the HeadSelectionView, BodySelectionView, and LegSelectionView screens, the user will choose one of the images available there. In the final FinalSelectionView screen, I want to display the images the user selected, but I'm facing a problem. In the FinalSelectionView screen, only the last selected 'Leg' image is visible; the 'Head' and 'Body' images return 'nil' (null). I'm leaving the code I wrote below. Can you help?" import SwiftUI enum ImageHead: String, CaseIterable, Identifiable { case smile = "head-0" case smileWithEyebrow = "head-1" case happy = "head-2" case sad = "head-3" case verySad = "head-4" case shocked = "head-5" var id: ImageHead { self } } enum ImageBody: String, CaseIterable, Identifiable { case black = "body-0" case brown = "body-1" case red = "body-2" var id: ImageBody { self } } enum ImageLeg: String, CaseIterable, Identifiable { case blue = "leg-0" case grey = "leg-1" case black = "leg-2" var id: ImageLeg { self } } struct SelectionImageView: View { var image: String var body: some View { Image(image) .resizable() .aspectRatio(contentMode: .fit) .frame(width: 150, height: 150) } } struct ContentView: View { @State private var userSelectedHead: ImageHead? @State private var userSelectedBody: ImageBody? @State private var userSelectedLeg: ImageLeg? var body: some View { NavigationView { ScrollView(.horizontal) { LazyHGrid(rows: [GridItem(.flexible())]) { ForEach(ImageHead.allCases, id: \.self) { head in NavigationLink(destination: BodySelectionView(userSelectedHead: $userSelectedHead, userSelectedBody: $userSelectedBody, userSelectedLeg: $userSelectedLeg)) { VStack { SelectionImageView(image: head.rawValue) Text("Selected Head: \(userSelectedHead?.rawValue ?? "None")") } } .padding() } } } .navigationTitle("Select Head") } } } struct BodySelectionView: View { @Binding var userSelectedHead: ImageHead? @Binding var userSelectedBody: ImageBody? @Binding var userSelectedLeg: ImageLeg? var body: some View { ScrollView(.horizontal) { LazyHGrid(rows: [GridItem(.flexible())]) { ForEach(ImageBody.allCases, id: \.self) { body in NavigationLink(destination: LegSelectionView(userSelectedHead: $userSelectedHead, userSelectedBody: $userSelectedBody, userSelectedLeg: $userSelectedLeg)) { VStack { SelectionImageView(image: body.rawValue) Text("Selected Head: \(userSelectedHead?.rawValue ?? "None")") Text("Selected Body: \(userSelectedBody?.rawValue ?? "None")") } } .padding() } } } .navigationTitle("Select Body") } } struct LegSelectionView: View { @Binding var userSelectedHead: ImageHead? @Binding var userSelectedBody: ImageBody? @Binding var userSelectedLeg: ImageLeg? var body: some View { ScrollView(.horizontal) { LazyHGrid(rows: [GridItem(.flexible())]) { ForEach(ImageLeg.allCases, id: \.self) { leg in NavigationLink(destination: FinalSelectionView(userSelectedHead: $userSelectedHead, userSelectedBody: $userSelectedBody, userSelectedLeg: $userSelectedLeg, selectedLeg: leg)) { VStack { SelectionImageView(image: leg.rawValue) Text("Selected Head: \(userSelectedHead?.rawValue ?? "None")") Text("Selected Body: \(userSelectedBody?.rawValue ?? "None")") Text("Selected Leg: \(leg.rawValue)") } } .padding() } } } .navigationTitle("Select Leg") } } struct FinalSelectionView: View { @Binding var userSelectedHead: ImageHead? @Binding var userSelectedBody: ImageBody? @Binding var userSelectedLeg: ImageLeg? var selectedLeg: ImageLeg var body: some View { VStack { if let head = userSelectedHead { SelectionImageView(image: head.rawValue) Text("Selected Head: \(head.rawValue)") } else { Text("Default Head Image") } if let body = userSelectedBody { SelectionImageView(image: body.rawValue) Text("Selected Body: \(body.rawValue)") } else { Text("Default Body Image") } SelectionImageView(image: selectedLeg.rawValue) Text("Selected Leg: \(selectedLeg.rawValue)") Spacer() } .navigationTitle("Final Selection") .padding(.horizontal) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
0
0
567
Dec ’23
App crashed on reading image in bundle when there is only a color with the same name.
Related APIs: +[UIImage imageNamed:] +[UIImage imageNamed:inBundle:compatibleWithTraitCollection:] When there is only a color set with the name (no image set provided), reading the image with the above-mentioned APIs throws an exception: 2023-12-19 19:30:34.008701+0800 ***[57410:578064] *** Assertion failure in -[_UIImageCGImageContent initWithCGImageSource:CGImage:scale:], _UIImageContent.m:666 2023-12-19 19:30:34.031207+0800 ***[57410:578064] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Need an imageRef' Even when wrapped in a try/catch block, it still crashes due to a lock issue after calling the related API twice. Here is an example code snippet: UIImage *image; for (NSInteger i=0; i<10; i++) { @try { image = [UIImage imageNamed:@"sample"]; //image = [UIImage imageNamed:@"sample" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; } @catch (NSException *exception) { } } The crash backtrace is as follows: #0 0x0000000102b12214 in _os_unfair_lock_recursive_abort () #1 0x0000000102b0da50 in _os_unfair_lock_lock_slow () #2 0x000000010ab07624 in -[UIImageAsset imageWithConfiguration:] () #3 0x000000010b2f4634 in -[_UIAssetManager imageNamed:configuration:] () #4 0x000000010aaf2394 in +[UIImage imageNamed:inBundle:withConfiguration:] () #5 0x000000010aaf2200 in +[UIImage imageNamed:inBundle:compatibleWithTraitCollection:] () #6 0x0000000105442154 in +[UIImageAccessibility imageNamed:inBundle:compatibleWithTraitCollection:] () It seems that the color set is being treated as an imageRef in this image reading process. It's a bug of UIKit?
1
0
746
Dec ’23
Alternate app icons and AppStore test treatments
We want to provide an alternate app icon in our bundle specifically for testing with an App Store test treatment (A/B test). What I'm unclear about is whether we then need to enable users to choose from the available app icons, since there are now multiple. I have seen reports of apps being rejected because they didn't offer this feature when multiple alternate icon sets were bundled. We do NOT want to allow users to select an app icon. Also, is it permissible to have a different icon for the App Store than what is used for the device app-launcher? I believe the guidance here is that all sizes of the icon should have the same content (just resized), but our marketing people want to test a different icon for the app-store specifically. Is there guidance on this somewhere that I haven't found?
0
0
686
Jan ’24
About .svg file, If 'x' inside 'text' represents multiple values, it will result in a rendering error.
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill-rule="evenodd" height="48" preserveAspectRatio="none" stroke-linecap="round" viewBox="0 0 2240 480" width="224"> <style type="text/css"> .brush0 { fill: rgb(255,255,255); } .pen0 { stroke: rgb(0,0,0); stroke-width: 1; stroke-linejoin: round; } .font0 { font-size: 303px; font-family: "Times New Roman", serif; } .font1 { font-style: italic; font-size: 303px; font-family: "Times New Roman", serif; } .font2 { font-size: 274px; font-family: Symbol, serif; } .font3 { font-weight: bold; font-size: 16px; font-family: System, sans-serif; } </style> <g> <text class="font0" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="154 264 836 1473 1925" xml:lang="en" xml:space="preserve" y="320">(3)13</text> <text class="font1" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="49 731 2077" xml:lang="en" xml:space="preserve" y="320">iii</text> <text class="font2" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="484 1026 1290 1678" xml:space="preserve" y="320">+=-+</text> </g> </svg> Review the specific issue
0
0
505
Jan ’24