Xcode6 image view + Asset Catalog. Image not showing - ios

iOS Newbie here. After the announcement of Xcode 6 and SWIFT, I decided to give it a try.
Now I am three days into iOS development and found a very strange problem.
Problem: On a empty project with only 1 ImageView control, I can't figure out how to display a PNG image.
Here is what I did:
1) Create a single view project.
2) Create a Asset Catalog, add image set, add PNG image.
3) In storyboard, drag Image View Control into the board.
4) Assign image & background color to Image View
Now hit run and simulator shows only the image background but not the image.
Xcode 6, target iOS7.0, ipad 2 simulator(7.1).
Tested the same procedure in Xcode 5 and the image shows correctly. However, I wish to learn SWIFT + Xcode 6. Using Xcode 5 isn't really a solution.
Here is the project package if you care to test it.

I've had a similar problem, but for an Objective-C project. I found this "problem" listed in the release notes:
"Images from asset catalogs in projects with a minimum deployment target of iOS 7 or OS X 10.9 will be available when running on iOS 8 and OS X 10.10, but not iOS 7 and OS X 10.9."
Which I took to mean that you will not see the images if the target device/simulator is not running iOS 8. I've partially confirmed this by deleting the images from the Images.xcassets and copying them into the project as files, then they get loaded and displayed correctly.
So, I take this mean that I should avoid using the Images asset catalog for iOS 7 targets for this release and just copy the images in as files.

Related

Xcode 9 not finding assets after using xcode 10

I downloaded Xcode 10 to test some new features on a project, Now when I reopen the same project on Xcode 9. It seems that Xcode can't find any assets ( images)
This would work fine on Xcode 10 :
let image = UIImage(named: "AsunnyDay")
// this would find the correct image
However, on Xcode 9
let image = UIImage(named: "AsunnyDay")
//image would be nil
I guess it's something related to XCode 10 categorizing the assets as either for dark appearance or light. but I don't understand why would Xcode 9 not find them.
Guys this is how I fixed it.
Open project in Xcode 10 beta
Go to the assets
Select all the images you have
In the inspector, you will have an option to choose the appearance type. Choose Any, Light,Dark
This will create extra placeholders for other images:
Open Project in Xcode 9. the assets will look something like this
Reorder the 1x , 2x , 3x into place.
Delete the extra unassigned placeholders
Done
For me i just reran the project using Xcode 10 and then reverted back to Xcode 9 and it worked for me.
Change your command line tool and clear your derived data first.
Clear your project.
After that force quit Xcode and reopen it.
It solved my assets warning problem.
Hope it will help you.

Reliable iOS image flipping for RTL languages

I'm trying to get image flipping to work reliably, but i'm seeing some issues. I manage my images in an Xcode asset catalog, and the ones that need to be flipped in RTL languages have been configured with the 'Direction' property set to 'Left to right, Mirrors'.
In some cases I have 2 separate assets, since flipping was not enough. Those are configured with the 'Direction' property set to 'Both' and two separate image assets are provided.
All images are PDF assets with 'Preserve vector data' enabled.
This all worked great as long as I test with iOS 11 and Xcode 9.2.
The problems start when I test on iOS 9. Images that are configured for RTL don't show up when I launch the app, even when I'm not running in a RTL language.
Since Xcode 9.3, I seem to have a new problem. The asset catalogs get updated automatically; the RTL images are reconfigured to direction 'Both' and changes are made to the json files in the catalog. Selecting 'Left to right, Mirrors' does not work anymore.
Is there anyone who has figured out how to get this to work reliably? Or am I just looking at the latest bugs in Xcode and some old issues with iOS9?
[edit]
After further analysis of the IPA file that is generated, it seems that the Assets.car file does not contain .png files for the RTL images. It seems that they are not generated (since the source files are PDF), so that would explain the missing images in iOS 9 (which does not use PDF images).
I fixed it, but it took someone at the Apple Developer Forum to point out that the asset catalog 'direction' property was not introduced until Xcode 8 / iOS 10.
This means it just doesn't work in iOS 9, and it is probably an Xcode bug that you can even select it when the deployment target is set below iOS 10.
So, don't try to use this feature when you want to be compatible with older iOS devices! You can still get it to work programatically.
If you have an image in for example a UIBarButtonItem, you can make an outlet to this button and run the following in the viewDidLoad:
self.someButton.image = [self.someButton.image imageFlippedForRightToLeftLayoutDirection];
This works because imageFlippedForRightToLeftLayoutDirection is supported by iOS 9. It only flips the image when your app is in RTL mode.
If you need to load a completely different image, you can do that as follows:
if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
self.someButton.image = [UIImage imageNamed:#"someRTLImage"];
}

xcode 6,launch image, iOS7, iPhon5s iPhone4s

The only consolation I take from this is that apparently I am not the only one having difficulty, specifically generating a launch image. I have googled the issue hundreds of times, consulted the iOS Dev Centre and searched through my rather extensive library of texts on the matter.
How are launch images created in Xcode 6 on an iPhone 5s(iPhone4 s) running iOS 7?
set Launch Images in project setting pageļ¼>general->launch image source
I had this issue because I'm using Xcode 6.1 and my app deployment target is 7.0.
I tried using the asset catalog with my existing images. Doing that gave me this error:
/ObfuscatedProjectPath/Images.xcassets: The launch image set named "LaunchImage" did not have any applicable content.
My solution was to turn off the asset catalog and use the default names for the images:
Default#2x.png (iPhone 4/s size is still supported in iOS7)
Default-568h#2x.png (works for iPhone 5/6/6Plus sizes)

Launch Images in iOS 7 with Xcode 5

I've been setting my own names on launch images for my apps in the Info.plist like
with the following images in bundle (with correct dimensions, 320x480 px for default.png and 640x960 px for default#2x.png etc.)
this have been working great prior to iOS 7 and Xcode 5. Now when I look in the General tab for the corresponding target in Xcode 5 my launch image files get mixed up from other targets in my project, which worries me, even though I haven't seen wrong launch image files when actually running the target. Should I be worried? The chosen images isn't in the build target so I should be fine there, but is there a risk of getting a blank image instead?
My main question is, can I use my default setup in Info.plist (that help auto detected respective launch images) for iOS 7, and if so, what should I name the corresponding launch images (now that there's the "iOS 6.1 and Prior" options as well with different dimensions)? This especially applies for the iPad Portrait Retina (iOS 7) that has new dimensions. The auto detection on iPad Portrait Non-Retina (iOS 7) refers to an image, not in the build target, that has the right dimensions. Again, when running a simulator with iPad Retina and iOS 7.0 the correct launch image shows.
Anden, I ran into the same problem today while adding a new target to the half dozen I already had that were set up in the same way that you set up yours.
I decided to use that "Use Asset Catalog" button, which took some work to set up, but has simplified things greatly in the end:
1- (optional) Delete (remove references only) the icon and launch image files from your project. I don't think you need the files to be in the project navigator anymore.
2- Choose your primary target, go to "General" and "App Icons" (as you showed above).
3- Press the "Use Asset Catalog" button, with the "Migrate Launch Images" checked as well.
4- This creates a file called "Images.xcassets" in your project navigator. Go there, and find the App Icon and Launch Image catalogs corresponding with the particular target. You can drag and drop image files from the finder into the slots in the catalog, and rename the icon/default groups from the list on the left.
5- Once you've got the image slots filled up, go back to the "General" for each target, and press the "Use Asset Catalog" button again for each target. Instead of creating a new xcassets file for each, you can store all the launch images and icon files in the same xcassets file.
I think it is a bug in xcode 5. I filed a bug, perhaps you should too (bugreport.apple.com). Make Apple aware things like this are not working well, and are taking our time and nerves.

App icon size for new iOS

I realize that iOS 7 is not out yet and should not be discussed but I could not find the answer to this question anywhere and iOS 7 comes out in a few days.
I submitted my app for iOS 7 and I got a warning saying I am missing the icon size 120 X 120 which apparently is the new standard size for icons in iOS 7. What I don't understand is what I should name this icon because my app supports both iOS 6 (Default app icon size is 114 X 114) and iOS 7.
Does anyone know how I should name this 120 X 120 icon for iOS 7 and my old iOS 6 icon that was 114 X 114?
Thanks!
It doesn't matter what you name the file as long as you hook it up correctly in Targets General Tab. You just click the Folder icon and select the file you want to use. The naming convention only really mattered because that was what was in the info.plist by default for a new project.
And the Targets General Tab realy just sets values in the app's info.plist
Note: I have a build setting ICON_SUFFIX = "Beta" so my beta release via TestFlight has a different bundle ID and Icon so it sits along side my app store version and doesn't over write it.
You can also use one asset catalog to organise your icon images, it's quite easy.If there is one image asset catalog, you use that one, otherwise you can new one. then select Use Asset Catalog in the App Icons part of General tab, you need to prepare the following image size and just drag the images to the corresponding location.
The icon sizes for iPhone and iPad for iOS 5~7 screenshot is as below:
or download it here
Here is online tool, Icons Master, which will create about AppIcon.appiconset folde, take care how icons should be big naming convection as well.
I just came across the solution here. Anyone with this problem refer to this following post!
iOS 7 App Icons, Launch images And Naming Convention While Keeping iOS 6 Icons

Resources