Xcode tab bar and SVG icons - ios

I was hoping I could use SVG icons on a tab bar. I'm currently using Xcode 12 beta 3 and whilst it works with these images, the icons don't seem to rescale.
Is there a solution to this?

A few observations:
See the Creating Custom Symbol Images for Your App for suggestions on how to build symbol SVG assets.
Historically in Xcode, we couldn’t easily use SVG assets. But we could convert them to PDFs, which we could then drag into our asset catalogs. When you use the asset in the app, it still ends up rasterizing it, which it saves you from having to create bitmaps of the three different sizes yourself. If you need to make it scalable (e.g., notably, for accessibility), check the “preserve vector data” option in the asset catalog.
In Xcode 12 (only beta right now), the importing of SVG assets has greatly improved. It still appears to rasterize the asset when you go to use it, though, just like the old PDF approach. You need to make sure your SVG/PDF has an artboard of the appropriate size for the eventually rasterized images.
If you consider these various vector graphic solutions, make sure to test this on your target minimum OS before you go too far. I had app with vector/PDF assets and got some unexpected edge-case behaviors on old OS versions.

Related

Strange glowing effect on PDF image assets in iOS?

I am having an issue where the images are rendered with a strange glowing effect around them, pictured here:
It is tough to see from this close but is extremely noticeable when viewing the app. Also, taking these screenshots into a design program and using the color dropper will prove that there is a glow around these images. Each of these images are PDF files, rendered as a template image so that I can change the tintColor instead of adding more images to my assets folder for each color.
I have read some other articles and questions that says there isn't full support for vector graphics yet (here). However, that is outdated as it specifies iOS 7 as the latest version at the time of writing. Now in iOS 13, I assume there have been changes. Another article I read said to never use vector graphics as they can get messed up when Xcode generates PNGs from the PDFs (here).
Information about the assets in my Images.xcassets:
Render as: Template Image
Resizing: Preserve Vector Data
Scales: Single Scale
I also tried to implement 3 PNGs at different sizes (#1x, #2x, #3x) for each image but got the same effect.
Creating new images with a smaller border size got rid of the glow but obviously, that doesn't fit the design style style that I want in an app. I designed these Icons in Sketch and used a border size of 3, then exported as PDF.
So, as I was writing this question I seemed to have found an answer.
It turns out it had nothing to do with anything in Xcode. The problem lies with Sketch. I redesigned each element in Adobe Illustrator, exported them as PDFs, set the same settings in the assets folder like so:
Render as: Template Image
Resizing: Preserve Vector Data
Scales: Single Scale
Here are the updated screenshots:
I am using:
Sketch (Version 52.5)
Adobe Illustrator (Version 24.2.1)
I don't know why this is an issue, but I hope it can help someone who has this issue down the road. If anyone has any more information on this, please write a comment :).

Xcode blowing up PNG size and ignoring Compress PNG = NO flag?

Currently, my Assets.xcassets folder is ~13MB with all images for my application. However, when I archive my app the Assets.car that results is closer to 33MB. When using iOSAssetExtractor as described here: What contributes to the size of assets in an IOS App and how can I shrink this? the issue appears to be that the PNGs are blowing up in size when they are "compressed" by Xcode. Many PNGs are 2-3x the size they were before going through the archiving process. This is a common problem that is referenced in multiple places.
The usual solution as referenced here: XCode png compression issue and here: https://imageoptim.com/xcode.html appears to be setting "Compress PNG Files" to No in build settings. This skips Xcode's unpacking and recompression of assets to avoid the asset size bloat that can be experienced. However, this doesn't appear to be working currently and might have stopped working in Xcode 7.3. There is a thread on this in the Apple forums here: https://forums.developer.apple.com/thread/43372 . However, the accepted solution appears to be changing the file type in the inspector to data which works for PNGs in a resources folder but does not appear to be an option for PNGs stored in an xcassets folder.
Note: I've also tried setting "Remove Text Metadata from PNG Files" to no as well with no success.
Can anyone recommend a solution for how to fix this issue in the current (7.3) version of Xcode so that my Assets.car file does not end up 2-3x larger than expected?
The specific problem of PNG sizes getting much larger seems to have been an Apple bug which appears to be addressed now. But, the more general problem of shrinking down each PNG to the smallest possible size is something that can still be solved more effectively. If you are interested in reading about a new delivery codec that can squeeze every last byte out of each PNG, then please have a look at this iOS framework.

The most efficient way of adding "AppIcon" to project in Xcode?

Im programming an app in xcode and something has recently come to my attention when designing app icons. Here is the current setup that I have in my project:
Right now I have a 87x87pixel image for the "29pt" option (far left of the image), I also have a 120x120 for the 40pt option(middle) and I have a 180x180 pixel png for the 60pt option(far right). This seems highly inefficient, not only this but I need to supply #2 resolution images too? Surely there is a better way of doing this?
There are a couple of approaches I've taken in the past. One way is to create your icons, etc. in GIMP, Photoshop, etc. If you need to resize them, there's a command line utility called ImageMagick which I find to be a lot easier for resizing images than setting sizes in an image editor. The command you would use for resizing is called mogrify.
Option two is to get your hands on an app called Asset Catalog Generator. You just dump your images in and it spits out the correct file sizes and naming conventions. It's probably the best $4.99 I've spent in a long time.
Update
It appears someone has written a script to create the icons, too. I haven't used it myself, so you might want to poke around and look for others.
Create your app icon (once) at a decent resolution say 1024x1024. Drop the file into MakeAppIcon (a free service) and out pops all your icons in a zip file properly sized, enhanced as necessary, and rendered. Just drop them into images.xcassets and you're done. This avoids having to tweak any icons that may be off by a pixel or two and avoids those annoying Xcode warning messages.This vendor also offer a service for bulk uploading your iTunes screenshots, but I haven't tried that yet. Luv it!
You can use the vector-based images from a PDF. Session 411 from WWDC “What’s New in Interface Builder” discussed—albeit very briefly—Xcode’s support for creating your PNG files at build time from a vectorised PDF.
There is good article on this, you can refer that as well. http://martiancraft.com/blog/2014/09/vector-images-xcode6/
(Note that this does NOT cover PDFs for icons, just for images)
I would suggest you try SquareIcon, which I believe makes creating Xcode app icon sets very easy. Just to let you know, this is my own app.
The app allows you to drop in a generic image file (like a JPG or PNG) and convert it to a .appiconset file which you can put into your project's asset catalog. This takes care of all the naming and resizing that you might have to do manually.
UPDATE 2: I might've misunderstood you. When I wrote this answer, I thought that by 'inefficiency' you meant memory consumption and the resulting app size. If you meant, that making an icon for all the sizes is a lot of work, and you're looking for a better way to do it, consider looking at Adrian B's answer instead.
First of all, no, there is no more efficient way of doing it (unfortunately). Xcode supports vector images, but they are only supported on OS X, AFAIK. On iOS it just generates all necessary images at compile time.
Second, the app icon is small. You won't save a lot of space by optimizing app icon size. If you need to decrease the app size, try finding something that really takes much space. The icon doesn't.
UPDATE: Luckily, Apple realizes, that forcing everybody to download resources that they don't need is no good. So they introduced App Thinning along with iOS 9. I haven't looked into it thoroughly yet, but the general idea is that you upload a binary containing all the resources as usual, but when your users download the app from the AppStore, they get a version containing only resources that they need.

Xcode 6 asset catalog automatically create images for smaller scales

With the need of 3x images in iOS 8 I figured it would be easier to manage images with an asset catalog in Xcode 6. I am trying to just provide a single image, the 3x scaled image to the asset catalog and I want Xcode to automatically downscale that image to generate 2x and 1x versions of the 3x image, so that I don't have to do it manually.
Right now this is what I have:
I really hope that Xcode has such a feature to automatically create 2x and 1x images and I just have not discovered it yet. If there isn't any such feature, are there any alternatives? (I know IconKit but it is annoying and hasn't been updated to support 3x images. If it was made properly in the first place it wouldn't even need an update..)
I know that Xcode automatically can generate all images from a vector pdf, but thats not what I am looking for!
I ended up making a small mac app that takes care of the dirty work. You can drag and drop one or multiple .jpg or .png files into the app's main view; it will detect the input image's scale and create the smaller scaled images. With this app I only need to create a single, 3x image and drag it into the app to create the two smaller images. It saves so much work!
The source can be found on my GitHub page, simply download it and run it on your mac! https://github.com/JonasGessner/ImageReducer
There is another way to solve this problem.
Use Automator to create Mac OS X service which create #3x, #2x and normal image on base of 1 image in #3x resolution automatically. It use just 3 methods: duplicate images, scale down, and rename.
Ready Mac OS X service made in Automator you can find here:
https://github.com/lukszar/iOS-Images-Prepare
late to the party but there is one tool which make all assets #1x, #2x, #3x and icons for you in just one click. And also export to XCAssets file.
You can find it here: https://github.com/angelvasa/AVXCAssets-Generator
Hope this will help someone
If you do not provide 1x or 2x assets, and your app is run on a 1x or 2x device, it should downsample the 3x asset at runtime. This may look fine, but depending on the scaling method used, it may also look really bad, so make sure this is really what you want.
If a folder named *.imageset, and the contents in it is well organized, Xcode will actually recognize them as an image. So this is another way to do this: https://github.com/albert-zhang/gen_xcassets
This python script will quickly auto generate #2x version for all images in a folder.

phonegap IOS application size

I created phonegap app for both android and IOS using eclips and xcode4.5
The size of Andorid app is 650KB
The size of IOS app is 9MB!!!
I created empty phonegap app (just did create on terminal) and got the same size
How can I reduce the IOS application size ?
Thanks!
The standard iOS App includes lots of Artwork, e.g. for the CDVCapture plugin.
If you don't use the Capture API (which is likely), you could save 2.3MB by deleting the Capture.bundle in the Resources folder and removing CDVCapture from the Plugins list in the Cordova.plist.
Of course much of the filesize is caused by the various splash screens, icons and maybe artwork you use yourself. There is a very good way to minimize the cost of these. Get ImageOptim and drop your Xcode project folder on it. This will reduce the filesize of your images dramatically (without losing quality). One last step: Xcode recompresses all of the artwork, so they have a bigger filesize again (stupid, right?). Go to the Build Settings tab and type PNG into the search field. Set Compress PNG files to NO.
further reading on imageoptim & Xcode
The whole process should reduce your App by at least 50%, please report back how much you could achieve, thanks.
That would be the retina splash screen images.
10MB is a normal app size, don't worry about it.

Resources