I'm in the process of making my iPhone application compatible with the iPad. I want to include larger image files for higher resolution artwork for the iPad version that I don't want included in the iPhone version (don't want the binary to become huge). Is there a way to accomplish this, or am I pretty much stuck with having to include the iPad art work with the iPhone version and vice versa?
You have to include both for a universal app, but as of iOS7 and when you use an Asset Catalog, the user won't have to download any unnecessary images. Apple takes care of this for you.
Asset Catalog Help
Quote:
For projects with a deployment target of iOS 7, Xcode compiles your asset catalogs into a runtime binary file format that reduces the download time for your app.
If you want to have one version in the store, it must include both. But if you want to have separate iPad and iPhone versions, then they each only need the images for that version. Just have two separate targets in the Xcode project for each, and make sure that you only have the assets included for the versions that need them.
Related
I can put files into Assets.xcassets or I can put files into folder references (the blue folders). When would I choose one over the other?
You should probably use asset catalogs as that's what Apple wants you to use going forward (the tools will reflect that) and they bring many advantages:
App thinning
Setting asset properties without code, e.g., rendering mode or slicing
You don't have to remember naming conventions like #2x, ~ipad, -568 etc to get device-specific assets automatically
Asset catalogs will point out missing assets if you tick the right boxes for the versions and devices you support, and they provide a nice overview
You should get used to them as some platforms (e.g., watchOS) require you to use asset catalogs
There are a few caveats:
If you deploy back to iOS 6, some features don't work as expected – asset catalogs still help to organize your assets, but the runtime features won't work as Xcode will just dump plain image files into your bundle.
If you deploy to iOS 7 or later, Xcode will compile all assets into one .car file (that's the whole idea). However, this can be harder to debug because you cannot look into the compiled file, and it also means you cannot simply get a file URL from a single asset. To create a file URL, you always have to load the asset (by its name) and write it to disk first. *
The last point also implies that you cannot use the NSBundle (in Swift 3.0: Bundle) APIs to retrieve URLs or paths to image files. In order to load assets from a bundle other than the main bundle, you rely on Apple to provide an API, which they do since iOS 8.0. If you organize shared code in resource bundles and deploy to iOS 7 or earlier, you shouldn't use asset catalogs. This is probably mostly relevant if you intend to develop a framework.
* E.g., the CoreSpotlight API allows you to set a thumbnailURL, but if your image is within an asset catalog, you must either write it to disk separately yourself, or use the thumbnailData property. If you had a file URL to begin with, you'd never have to load the asset into memory. I'm not sure if Spotlight could access file URLs from within your app bundle. It's just an example.
You should use Assets. Many benefits the folder references can't do
1) Change color of image without any code
2) Support vector, pdf better.
3) Support Slicing image.
4) Manage resource easier for autolayout. If your resources has 1x, 2x, 3x and ipad image size != iphone image size, you can add 6 files into 1 asset item.
You can read more here
http://krakendev.io/blog/4-xcode-asset-catalog-secrets-you-need-to-know
I am a newbie on iOS development and am developing my first serious app (Objective C).
I am using an external API and have gotten to a point where I need to download an image from said API to keep offline as cache.
Now, if I understood correctly I can add images to my app on XCode using the asset catalog. For example, if I add an image with image#1X.png, image#2X.png and image#3X.png versions, in order to use them later I only need to provide the "image" part to iOS and it will automatically return the version appropriate for the currently used device.
I cannot however add images to the asset catalog on runtime - I must create an NSData from the image URL and save it to the Documents folder.
The thing is, this API gives me a bunch of URL's for different versions of the image I need to download and among them are the #2X, #3X etc versions of the image, so I need to download all versions and use the asset catalog feature of retrieving the appropriate one for the device.
How can I achieve this?
Thank you very much in advance for your help and please correct me if I got something wrong.
so I need to download all versions and use the asset catalog feature of retrieving the appropriate one for the device.
You don't need to. We add 2x and 3x images to our asset catalog because we don't know on what device our app is running. But in your case, you need to know this at runtime, so you already know what's the device.
To get the scale factor for your device you can do:
UIScreen.mainScreen().scale
So, for 2x this will return 2 and for 3x it will return 3.
From this, you can know what's the proper image you need to download from your API instead of downloading them all which would add unneeded overhead.
You can check the document on the UIImageAsset if it helps in your requirement
Also as you say you are newer to iOS development you can check file system document also which helps you in understanding and managing file in better way
File System basics
Edit: as mentioned by sateesh and patchdiaz, it will be better solution to download only single resolution images for the particular device instead of downloading all resolution images for a device
Currently we are only testing LiveCode 7.0.4 to see how it works and if we want to even use it. In our apps we need JSON from our server and have setup the mergJSON library/External in Livecode. So far, this is working very nicely in standalone tests for both MacOS and Windows. Today I started doing some simple tests on iOS and I am having a hard time with it.
I found answers where we need to use the Copy Files section in Standalone Settings, and that we need to copy the *.lcext file for mergJSON. Also watched the youtube how-to video that had mergSettings. There are no .nib files for mergJSON. Only .so, .dylib, and .dll, and the .lcext. I tried to add the .bundle file like the video, but the app will not launch, only black screen. Are other files required for mergJSON? And where do we put them? Do they stay in the same Externals folder structure or in project folder. Also, does an IOS runtime folder need to be created like in Widows/Mac? The app runs, no errors, but no JSON results are returned. I guess I am just a little confused on the Externals setup for iOS.
Just quick notes of our environment. We have Xcode 6.2 and the iOS Sdk 8.2. Live Code is 7.0.4 GPL (just testing and learning this way for now, will purchase commercial once I learn more.) I think the mergJSON I have is 1.0.15, downloaded from mergext.com. (which appears to be offline today) I have only tested on the simulator.
Thanks for any help.
You only need to include the lcext file in the copy files section of standalone settings. No need to setup a runtime folder for iOS etc.
I have really large number of images just in Images folder of my project (just #1x and #2x.png files). It's time to support #3x displays and I've decided to move to assets catalog. Are there any tools/scripts to automate this?
Normally you already have an Asset Catalog because of your AppIcon. If not, choose File:New:File ... and then select iOS Resource:Asset Catalog.
The images you want to import should be named properly: image.png, image#2x.png. If you target both devices: image~iphone.png, image#2x~iphone.png, image~ipad.png, image#2x~ipad.png.
Then select Asset Catalog and press +. Choose the folder with the images you want to import.
Like that it´s very simple to import large numbers of pictures and you can have the same folder structure in your Asset Catalog, as you had before.
You can try iMigrate, that I created recently. So it wasn't properly tested and you can use it own risk.
You can make one of your own using Apple Automator. It is an automating script maker tool provided by Apple with the Mac OS. You can find plenty of online tutorials for it if you Google it up. Here's an example. Click here
We are building a large-scale app with AIR for iOS.
One constraint of an AIR app with the iOS packager is that there are no modules. It is possible to load SWF files, but any embedded actionscript code is ignored.
We are wondering what happens to an AIR app for iPad when the code size gets very large. Are you aware of any technique for dividing code up into logical load groups, or do app developers just rely on virtual memory to swap in only a subset (hopefully) of the entire binary image?
No, AIR does not allow package more than one primary SWF.
We have a quite large project and wanted to use modules as well.
Solution we ended up with was removing all embedded sources. That includes graphics and sounds libraries created by Flash IDE or [Embed] classes.
All resources are loaded at runtime using
Sound.load() for mp3/sounds
Loader.load() with asynchronous image decoding policy for png/jpeg/images
FileStream.openAsync() for other/binary data.
We had 36 MB SWF file, now it is only 1.4 MB plus all the external assets.