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.

Asset Catalog Documentation

Posts under Asset Catalog tag

25 Posts
Sort by:
Post not yet marked as solved
0 Replies
138 Views
I try to get fullSizeImageURL and then calculate md5 of asset via url: var assetUrl = syncUrl(asset: asset) let assetMD5 = md5File(url: assetUrl) To get url I use requestContentEditingInput. The problem is contentEditingInput can be empty. I have had cases where my app worked on my new iphone the first few times. But after some tries, this problem was gone and contentEditingInput was always not empty. Not sure but I think it is because all assets were cached. So my questions are: Why contentEditingInput can be empty? How can to get asset url if contentEditingInput is empty? How can I clear asset photos cache to reproduce this issue if it is related to cache? Part of code which I use: extension PHAsset { func getURL(completionHandler: @escaping ((_ responseURL: URL?) -> Void)) { let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions() options.canHandleAdjustmentData = { (adjustmeta: PHAdjustmentData) -> Bool in return true } options.isNetworkAccessAllowed = true self.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput: PHContentEditingInput?, info: [AnyHashable: Any]) -> Void in !!!!!!contentEditingInput can be empty completionHandler(contentEditingInput?.fullSizeImageURL as URL?) }) } md5: func md5File(url: URL, isCancelled: @escaping () -> Bool) -> Data? { let bufferSize = 1024 * 1024 do { // Open file for reading: let file = try FileHandle(forReadingFrom: url) defer { file.closeFile() } // Create and initialize MD5 context: var context = CC_MD5_CTX() CC_MD5_Init(&context) // Read up to `bufferSize` bytes, until EOF is reached, and update MD5 context: while autoreleasepool(invoking: { if isCancelled() { return false } let data = file.readData(ofLength: bufferSize) if data.count > 0 { data.withUnsafeBytes { _ = CC_MD5_Update(&context, $0.baseAddress, numericCast(data.count)) } return true // Continue } else { return false // End of file } }) { } if isCancelled() { return nil } // Compute the MD5 digest: var digest: [UInt8] = Array(repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) _ = CC_MD5_Final(&digest, &context) return Data(digest) } catch { print("Cannot open file:", error.localizedDescription) return nil } }
Posted
by
Post not yet marked as solved
1 Replies
233 Views
So, it seems to be a bug in the Xcode 14 beta (M1). Some assets just can't be compiled and lead to fatal compilation error 'Command CompileAssetCatalog failed with a nonzero exit code'. Here (h ttps://morioh.com/p/2d58b31db5f7) is written that the problem is in SVGs but I had the same problems with some PDFs, PNGs and JPGs. The same project builds with no errors in Xcode 13.4.1 Seems to me that I'm not the only one with this problem but I haven't found any workaround for this.
Posted
by
Post not yet marked as solved
0 Replies
44 Views
I have an asset list in my swift ui app with 20 something assets which are all photos. When I go to add another, I am unable to do so and my app gives this error "Building [my app] failed. Build failed because certain resources could not be bundled". How can I add more images/assets without this error.
Posted
by
Post not yet marked as solved
0 Replies
54 Views
Using xCode 13.4.1, my assets catalog (assets.xcassets) has gone blank. Which is to say when I click on the icon in the left-hand Navigator, the normal OutlineView and DetailView are replaced by a large white area of screen. If I try, for example, to drag a new image file into this area, it bounces out. The existing assets are still there; when I run the app the images, etc., appear as expected. I just can't see them to manage them (or add new assets). I have restarted xCode several times to no avail. Has this ever happened before? Does anyone have a solution? BTW, in other app projects, the assets catalogs are working normally. It is just in one project where the catalog is "blank"
Posted
by