What's difference between Assets.xcassets and images.xcassets? - ios

When I new a xcode project, there was a image folder by defalut, I wanna to know that is there any difference between them? Is Assets.xcassets newer?

What is Asset?
Asset catalogs to organize and manage the different asset types and image resolutions used by your app’s user interface.
You can have multiple asset catalogs in your project and within each catalog, multiple sets of assets. In addition, you can organize sets into folders.The common types of sets you can add to a catalog are image, data, and texture sets.
Now you understand that image asset is one of the asset catalog.
It will automatically created by Xcode when creating new projects.
Common use of Asset catalog :
In particular, use asset catalogs to manage images that are required
to launch your app on a device and submit your app to the App Store.
As above statements from apple there are multiple asset types are available.You can create catalog for each type if you want.
Asset types
You can get more info from help.apple.com

Not really sure but I think since Xcode 7 you have this new Assets.xcassets catalog to store several types of resources, not just images as you can have sounds, images, fonts and movies in your project.

Related

How to use different assets with same name using multiple targets

I'm trying to build an app with multiple targets, each should have different asset versions. The business requirement is to have the same app but with different branding assets. I don't want to copy and paste the project and change icons manually because this won't be efficient.
As an example, I have a logo in the assets catalog, both Target X and Target Y need to see the asset, but both targets need to see a different version of the asset.
You can do this by creating additional Asset Catalogs, these can be named accordingly, they will need to be added to your required target, Target Membership.
Having different collections you are able to have the same asset names and the targets will work as expected.

Using XCAssets Properly (adding assets)

I had two people discuss two different approaches with me on how to add assets such as images to a project in Swift.
Person 1: "You should create a new folder within your actual project workspace and then add all of your assets to it directly (so it's within the project). Then drag & drop the assets from this project folder to XCAssets, to actually create the icons you will use."
Person 2: "Just download your images from wherever, and drag and drop them directly. They can be from different locations. When you deploy to ITunesConnect it will copy the images."
Now I'm confused - when I drag and drop an image (let's say from my Downloads folder) doesn't Xcode copy the image locally into its own private location? Once I drag it into XCAssets, does it need that source location anymore? I thought maybe approach #1 would end up forcing Xcode to store duplicate images/assets and take up more size on the app.
What is the "correct" approach to adding assets?
Thanks!
Both actually can work (drag and drop/use asset folder). But the latest method introduced by Apple by xcasset folder. XCAsset folder is superior in the way that you can see a list of assets nicely one by one, even you have multiple sizes on it (.png #2x.png #3x.png etc). Easier to manage and see which size you are missing etc.

Xcode: Exclude images in build from asset catalog according to preprocessor flag

I have two apps that share almost everything except that one shows ads according to a preprocessor macro that is configured on the Build Settings tab.
Now, following the same rule, I need to exclude images from the Asset Catalog, so this way the app with ads doesn't include things that it shouldn't, but I don't know how to do it. Any guidelines?
Thanks
Since you have two targets in your project, the simplest solution is to have three or more image assets (xcassets) in your project.
One with images common to both targets, one with images specific to target A, and one with images specific to target B.
Then ensure that the two target-specific assets are only targeted to their respective project target.

What contributes to the size of assets in an IOS App and how can I shrink this?

I have an iOS app built in Xcode 6 which uses an Asset Catalog to store 71MB of images. I have only includes the #3x images in my Asset Catalog to try and keep the size of the app under 100MB. The only exception to the #3x rule is that I have included #1x and #2x images for the AppIcon group.
All images are .JPG files with the exception of the AppIcon files which are .png files.
When I archive and create an .IPA file, the size of the IPA is 117MB. When I open and look at the size of the Asset.car file within the .IPA I see that it is 130MB. Contrast this to the Asset Catalog in the project which is 71MB. I am pointing this out to be clear that it's not other compiled code that is taking up 40 MB.
I would like to archive this app so that the file size stays under 80-90-MB if possible. The IPA should stay under 100MB given the 70MB of assets but I would like to know how to accomplish this or what other steps I might need to take or review to see why I am getting 130MB of an asset file in the IPA for 70MB of images.
There is a new CAR tool: iOS-Asset-Extractor. This seems to be a better solution than "cartool" below.
Get cartool, build and run against your Assets.car file. That will create a directory containing the image files from the Assets.car.It is a simple command line tool. Not perfect but that should give you help understanding what is going on.
Then compare with what you expect and hopefully you will be able to figure out what is going on..
From what I understand .jpg files are converted to .png. If you have assets that are large consider including them directly or as a folder reference. This is particularly true if you are reading in the images in your code.
The article at Assets.car is 6 times larger than actual Images.xcassets folder when archived seems to be the answer.
The entire set of JPEGs in my Asset Catalog is converted to PNG's which are substantially larger. I converted everything except for my AppIcons and LaunchImage out of the Asset Catalog and into a normal folder. So at that point i had a folder full of JPEGs and a small Asset Catalog.
When I created an archive it was 67 MB so significantly smaller!

One Project For Multiple Applications in XCode

I am trying to use the approach of having a single project that uses different targets with different plist files. However, each target has a different set of launch and icon images. I cant however use a duplicate set of these since adding a duplicate image when the same name gives the error that its already in use. Is there anyway around this in xcode?
To save the file, either provide a different name, or move aside or delete the existing file, and try again.
You should use Xcode 5's assets catalogs. You can define a different assets catalog for each target, and in each assets catalog you can define different launch images. Names are handled by the content generator.
You can mix asset catalogs, so you can have, for example, one shared catalog for shared images, and individual ones for each different target, where you can have distinct icons and launch images.
OK, so I have changed my approach and found the easiest and a simple solution which I ignored before. All you have to do is keep the file names same but keep the files in different folders. And when adding them to project, check the target to which the files belong to and uncheck other targets. See the image.

Resources