Background Assets file diff?

Background Assets can support a maximum of 200G. Will the Apple server perform file comparison? For example, file0 is included in both a.aar file and b.aar file. On the Apple server, does it occupy twice the size of a single file?

Answered by Frameworks Engineer in 856627022

Hello! No, Apple servers don’t deduplicate files between separate asset packs. If you include the same file in two asset packs, then it’ll count twice towards the storage limit. If that puts you too close to the limit, then I suggest that you break out the duplicated file into a third asset pack that you download in conjunction with either the first or the second as is needed. Note that the system merges the directory hierarchies in your different asset packs on users’ devices, so the part of your code that loads the file doesn’t need to care that it came from a third asset pack.

Hello! No, Apple servers don’t deduplicate files between separate asset packs. If you include the same file in two asset packs, then it’ll count twice towards the storage limit. If that puts you too close to the limit, then I suggest that you break out the duplicated file into a third asset pack that you download in conjunction with either the first or the second as is needed. Note that the system merges the directory hierarchies in your different asset packs on users’ devices, so the part of your code that loads the file doesn’t need to care that it came from a third asset pack.

I performed the following code: let assetPackStatus = try await AssetPackManager. Shared. The status (ofAssetPackWithID: assetPackID) print("checkAssetPackStatus (assetPackStatus)"). The content of the print assetPackStatus is:(BackgroundAssets. AssetPack. Status) assetPackStatus = (rawValue = 69). I couldn't find the explanation for this content in AssetPack.Status. Could you please tell me what it means. Thanks.

AssetPack.Status is an option set, not an enumeration. One status value can include zero or more options. Its raw value is a mask on a bit field of the possible options. Each possible option is represented by a 1 bit at a particular location in the bit field—i.e., the binary representation of some power of 2. The bit mask selects some subset of those options. It’s just a sequence of bits, so it can be typed as an integer. In your case, the integer 69 in binary is 0b1000101. The three 1 bits, from right to left (least significant to most significant), correspond to 2⁰, 2², and 2⁶, respectively. Here’s what they mean in the context of AssetPack.Status:

  • 2⁰ means that the asset pack is available to download.
  • 2² means that the asset pack is up to date.
  • 2⁶ means that the asset pack is downloaded.

If you don’t want to deal with binary math, then you can take advantage of the fact that the OptionSet protocol, to which AssetPack.Status conforms, inherits from SetAlgebra, which provides high-level interfaces for checking whether an option-set value contains certain options of interest. For example, you could call contains(_:) on your AssetPack.Status value to check whether an asset pack is downloaded:

let assetPackStatus = try await AssetPackManager.shared.status(ofAssetPackWithID: assetPackID)
let isDownloaded = assetPackStatus.contains(.downloaded /* 2⁶ */) // Evaluates to true for a raw status value of 69

You could also check whether an asset pack has an update available:

let hasUpdateAvailable = assetPackStatus.contains(.updateAvailable /* 2¹ */) // Evaluates to false for a raw status value of 69

And what does the AssetPack.version means? The official documentation's tutorial on Manifest.json doesn't mention the version field. Thanks.

For Apple-hosted asset packs, AssetPack.version is the version number that App Store Connect assigned when you uploaded the asset pack. Every time you upload a new asset-pack archive with an existing asset-pack ID, App Store Connect increments the version number.


I hope that this helps! Please feel free to create a new thread if you have other questions or issues. Thanks!

Background Assets file diff?
 
 
Q