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

37 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Native camera and AVCapture image difference
We are trying to build a simple image capture app using AVFoundation and AVCaptureDevice. Custom settings are used for exposure point and bias. But when image is captured using front camera , the image captured from the app and front native camera does not match. The image captured from the app includes more area than the native app. Also there is difference between the tilt angle between two images. So is there any way to capture image exactly same as native camera using AVFoundation and AVCaptureDevice. Native Custom
0
0
135
1w
App Icon all black on ios17, works on iOS18, building app in Xcode16 beta
In my app I added an AppIcon in the Assets.xcassets folder. I added a any/dark/tinted version of the app icon, in 1024x1024 resolution as a HEIC file, specifying a "single size" iOS option. When I build and run the app in xcode16 beta on iOS18 the icon works as expected, but when I run the same app on iOS17 the icon just shows up as a black rectangle. How do I get the app icon to work correctly on both iOS18 and iOS17?
1
0
308
Aug ’24
Assets are outrageously large in VisionOS builds
I'm developing an app for Apple Vision Pro. The asset directory in my project is small: $ du -sh Assets.xcassets 292K Assets.xcassets However, after build assets in the resulting bundle are 15MB! $ du -sh MyApp.app/Assets.car 15M MyApp.app/Assets.car That's two orders of magnitude! Considering that binaries of the app are a couple of MBs, the app bundle is basically all assets! ***?! It seems somewhere in build process several very large assets are generated: > assetutil --info Assets.car | grep "SizeOnDisk" | sed 's/^[[:space:]]*"SizeOnDisk" : //' | sed 's/,$//' | sort -rn | head 2860982 2860982 2859215 2749277 2658939 1049666 163374 163374 136454 79949 The top one has this in the output of assetutil: {{ "MipLevel" : 0, "RenditionName" : "avp_app_icon_frame.png", "SHA1Digest" : "1F511AC99BA7EE4B7735FDC84F64BA1CDCB044734ED7D3A4AEC1F07AEA90B969", "SizeOnDisk" : 2860982, "Texture" : { "AssetType" : "Texture Data", "Compression" : "lzfse", "Encoding" : "ARGB", "PixelHeight" : 1024, "PixelWidth" : 1024, "Rowbytes" : 4096, "Texture Pixel Format" : "R32 Float" } } Full 32bpp basically w/ lz compression?! Why? What's going on? How do I turn this off?
1
0
181
Aug ’24
Setting a custom icon for documents
I'm trying to set custom Icons for my documents created in a Mac Catalyst app. The icon I defined appears on iOS apps fine. But on my mac they all have a generic icon. I have added the CFBundleTypeIcons key to my info.plist and added an .icns file to my app but it changes nothing. What am I not doing here that I should be?
2
0
274
Aug ’24
Launch screen is black when using UIImageView in storyboard
I'm trying to add an SVG image to my launch screen. The SVG image is working fine in the main storyboard also used in a UIImageView, but the launch screen remains completely black; the launch screen is set with white background, so it seems to be completely ignored. When I remove the image from the UIImageView the launch screen is shown with correct background color but of course without the whished image. I can also correctly implement text in the launch screen, the launch screen shows the text and the background color correctly. As soon as I define an image from the asset catalogue for the UIImageView in the launch screen, the launch screen is completely black not showing anything. I tried also with a simple png image-set instead of the SVG image, but still the same issue. How can I implement a SVG image in my launch screen?
2
0
300
Jul ’24
Asset Symbol Generation - color and image accessors for Asset Catalogs
Hey, in Xcode 16's release notes there is this: Asset catalogs now provide an inspector property for enabling system color and image accessors for generated asset symbols, which allows Swift packages to opt-in to generating these accessors. (113704993) What exactly does this mean? Can we make the generated asset symbols public, so that we can share assets between local swift packages in the project? Unfortunately, I don't see this option in the inspector. I only see "Asset Symbols > Extensions On/Off". Not sure what that means, either. Thanks
1
4
397
2w
App Intent snippet view does't able to fetch color for xcassets.
We have an existing app in which we have implemented AppShortcuts. The snippet view works fine in iOS 17 while in iOS18 beta, it doesn't able to fetch color from xcassets. If we use system colours or UIColor it's working fine. Not working Color("progressColor") Working Color(uiColor: UIColor(named: "progressColor")!) Color.red Color(hex: "3881d3") // Note: We created Color extension to generate color from hex string.
0
2
378
Jun ’24
Public generated asset symbols
Is there currently an option to make generated asset symbols public? If not, would it be possible to set the generated asset symbol so they are public. It's quite common to have an apps design system implemented in a separate framework. Currently the generate assets symbols is useless for this as they can't be access in the framework consumer. It would be great to add it to this new dropdown in Xcode 16 or along side it. (113704993 in the release notes) So the options would be Internal, Public and Off. This should affect the symbols, the extensions and the framework support. (There's a post on the swift forums about this as well here: https://forums.swift.org/t/generate-images-and-colors-inside-a-swift-package/65674)
3
11
887
1w
Images retain memory usage
This is a very simple code in which there is only one button to start with. After you click the button, a list of images appear. The issue I have is that when I click on the new button to hide the images, the memory stays the same as when all the images appeared for the first time. As you can see from the images below, when I start the app, it starts with 18.5 mb, when I show the images it jumps to 38.5 mb and remains like that forever. I have tried various way to try and reduce the memory usage but I just can't find a solution that works. Does anyone know how to solve this? Thank you! import SwiftUI struct ContentView: View { @State private var imagesBeingShown = false @State var listOfImages = ["ImageOne", "ImageTwo", "ImageThree", "ImageFour", "ImageFive", "ImageSix", "ImageSeven", "ImageEight", "ImageNine", "ImageTen", "ImageEleven", "ImageTwelve", "ImageThirteen", "ImageFourteen", "ImageFifteen", "ImageSixteen", "ImageSeventeen", "ImageEighteen"] var body: some View { if !imagesBeingShown { VStack{ Button(action: { imagesBeingShown = true }, label: { Text("Turn True") }) } .padding() } else { VStack { Button(action: { imagesBeingShown = false }, label: { Text("Turn false") }) ScrollView { LazyVStack { ForEach(0..<listOfImages.count, id: \.self) { many in Image(listOfImages[many]) } } } } } } }
1
1
577
May ’24
XCode asset catalog causes NSImage to be unclickable
I'm having an issue where when my asset catalog have more than 2 images (all have @1x @2x and @3x and PNG format), my NSImage in my NSImageView cannot be clicked. Does anyone know why this happens? Thanks in advance! import SwiftUI struct ContentView: View { @State private var window: NSWindow? var body: some View { VStack { Button("Open Window") { // Create and show the NSWindow self.window = NSWindow( contentRect: NSScreen.main?.frame ?? NSRect.zero, styleMask: [.borderless], backing: .buffered, defer: false ) // Set up window properties self.window?.isOpaque = false self.window?.hasShadow = false self.window?.backgroundColor = .clear self.window?.level = .screenSaver self.window?.collectionBehavior = [.canJoinAllSpaces] self.window?.makeKeyAndOrderFront(nil) // Create an NSImageView let petView = PetView() // Add the NSImageView to the window's content view if let contentView = self.window?.contentView { contentView.addSubview(petView) // Center the petView petView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true petView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true } } } } } class PetView: NSImageView { override init(frame frameRect: NSRect = .zero) { super.init(frame: frameRect) self.image = NSImage(named: "dog_idle-1") self.translatesAutoresizingMaskIntoConstraints = false } required init?(coder: NSCoder) { super.init(coder: coder) } override func mouseDown(with event: NSEvent) { print("woof!") } } I've tried changing the amount of images in my asset catalog and found that 2 is the maximum amount for my NSImage to be clickable. It suppose to print "woof!" when i click on it.
0
0
350
May ’24
Xcode assets name conventions.
Hi community: I'm trying to replace it with drag-and-drop images in assets. I know for example that by adding a suffix @2 and @3, you can drag and drop and Xcode knows where they must be. Also, I remember that it could be possible to add a suffix like ~dark or ~light. There's no official documentation about it but I'm looking a way to drag and drop and autodetect assets per language. I've tried: image_es@fr.png image_fr@2x.png image_fr@3x.png But doesn't work. Any ideas where I can find the docs? Or can someone provide documentation about it? Thanks in advance.
0
0
398
May ’24
XCode 15.3 Command CompileAssetCatalog failed with a nonzero exit code
I just upgraded to XCode15.3 and now all my projects with Assets are getting this compile error. I have tried removing DerivedData caches and rebooting but still get this error. Anyone else hit this problem with XCode 15.3? I was only Building for IOS 16.4 and 17.0.1 and Xcode 14.0 and 15.0 Build Error: Command CompileAssetCatalog failed with a nonzero exit code *** Terminating app due to uncaught exception 'IBPlatformToolFailureException', reason: 'The tool closed the connection (AssetCatalogSimulatorAgent) Execution Context: <IBSimulatorToolCoreSimulatorCLIExecutionContext: 0x600003d5d260 busyCount=0, Idle for 0.0 secs, lifeTime=26.3 secs>, device=IBSimDeviceTypeiPad3x (865E7291-E467-4E8D-B535-D64F43A57F15, iOS 17.4, Shutdown), idiom=<IBIPhoneIdiom: 0x6000028b8000>
16
5
6.1k
May ’24
Error loading ReferenceImage
Currently, I try to test the ImageTrackingProvider with the Apple Vision Pro. I started with some basic code: import RealityKit import ARKit @MainActor class ARKitViewModel: ObservableObject{ private let session = ARKitSession() private let imageTracking = ImageTrackingProvider(referenceImages: ReferenceImage.loadReferenceImages(inGroupNamed: "AR")) func runSession() async { do{ try await session.run([imageTracking]) } catch{ print(error) } } func processUpdates() async { for await _ in imageTracking.anchorUpdates{ print("test") } } } I only have one picture in the AR folder. I added the size an I have no error messages in the AR folder. As I am trying to run the application with the vision Pro, I receive following error: ar_image_tracking_provider_t <0x28398f1e0>: Failed to load reference image <ARReferenceImage: 0x28368f120 name="IMG_1640" physicalSize=(1.350, 2.149)> with error: Failed to add reference image. It finds the image, but there seems to be a problem with the loading. I tried the jpeg and the png format. I do not understand why it fails to load the ReferenceImage. I use Xcode Version 15.3 beta 3
2
0
887
Feb ’24
how to read a file under project directory for both development and runtime?
For example I created a project aaa. aaa source folder is called aaa. that is aaa aaa/aaa then I put a data file in aaa/aaa/some.data now i want to test data in aaa/aaaTests/aaaTests.swift How can i access aaa/aaa/some.data in aaaTests.swift? If I want to access some.data inside aaa/aaa/ContentView.swift, how to write the code? I have been searching google and bing for days, but find no example answering my questions. Can anyone help me out? Thanks in advance.
1
0
699
Feb ’24