Xcode 5 & Asset Catalog: How to reference the LaunchImage?

xcode download
xcode 5 download
xcode 11.5 download
xcode windows
xcode 10
xcode 10 download
xcode versions
xcode@5 azure

I am using Xcode 5's Asset Catalog, and I would like to use my LaunchImage as the background image of my home view (a pretty common practice to make the transition from 'loading' to 'loaded' look smooth).

I would like to use the same entry in the Asset Catalog to save space and not have to replicate the image in two different Image Sets.

However, calling:

UIImage *image = [UIImage imageNamed:@"LaunchImage"]; //returns nil

Swift 5 Release Notes for Xcode 10.2, Overview. Read these notes when you're writing Swift apps in Xcode 10.2. General. Swift 5 Runtime Support for Command-Line Tools Package. Starting with� Xcode 12 is built as a Universal app that runs 100% natively on Intel-based CPUs and Apple Silicon for great performance and a snappy interface.* It also includes a unified macOS SDK that includes all the frameworks, compilers, debuggers, and other tools you need to build apps that run natively on Apple Silicon and the Intel x86_64 CPU.

- (NSString *)splashImageNameForOrientation:(UIInterfaceOrientation)orientation {
    CGSize viewSize = self.view.bounds.size;
    NSString* viewOrientation = @"Portrait";
    if (UIDeviceOrientationIsLandscape(orientation)) {
        viewSize = CGSizeMake(viewSize.height, viewSize.width);
        viewOrientation = @"Landscape";
    }

    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict) {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
            return dict[@"UILaunchImageName"];
    }
    return nil;
}

Xcode on the Mac App Store, Download Xcode for macOS 10.15.2 or later and enjoy it on your Xcode includes everything developers need to create great 3.3 out of 5. Xcode is the most used IDE for iOS development. Apple is doing a great job in updating and adding features to it. Knowing how to take advantage of its capabilities can help you code faster and more efficiently. Check out this Guide for Xcode 5 shortcuts, tips and tricks.

The LaunchImages are special, and aren't actually an asset catalog on the device. If you look using iFunBox/iExplorer/etc (or on the simulator, or in the build directory) you can see the final names, and then write code to use them - eg. for an iOS7-only iPhone-only project, this will set the right launch image:

NSString *launchImage;
if  ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) &&
     ([UIScreen mainScreen].bounds.size.height > 480.0f)) {
    launchImage = @"LaunchImage-700-568h";
} else {
    launchImage = @"LaunchImage-700";
}

[self.launchImageView setImage:[UIImage imageNamed:launchImage]];

I put this into viewDidLoad.

This isn't really ideal, it would be great if Apple would give us a nice API to do this.

Xcode, Xcode 5 is an integrated development environment (IDE) within which you will code, compile, test and debug your iOS applications. The Xcode 5 environment also� Xcode, now in Version 5, consists of a compiler, a linker, a source-code-level debugger, a code analyzer, performance measurement instruments, a simulator, and other utilities, all managed by an

My app currently only supports iOS 7 and later.

This is how I reference the launch image from the asset catalog:

NSDictionary *dict = @{@"320x480" : @"LaunchImage-700",
                       @"320x568" : @"LaunchImage-700-568h",
                       @"375x667" : @"LaunchImage-800-667h",
                       @"414x736" : @"LaunchImage-800-Portrait-736h"};
NSString *key = [NSString stringWithFormat:@"%dx%d",
    (int)[UIScreen mainScreen].bounds.size.width,
    (int)[UIScreen mainScreen].bounds.size.height];
UIImage *launchImage = [UIImage imageNamed:dict[key]];

You can add more key value pairs if you want to support older iOS versions.

Installing Xcode 5 and the iOS 7 SDK, The improvements in the Xcode 5 release should allow you to write better applications for iOS and OS X that are faster and have fewer bugs. Xcode is a trusted app development program for macOS that makes it easy for people to develop iOS, macOS, tvOS, and watchOS programs alike. Xcode has been available as a freeware program with open-source elements since 2003 and is working on version 10.1 as of January 2019. The Apple Developer website offers downloads of prior versions too.

Here a category on UIImage based on the solution provided by Cherpak Evgeny above.

UIImage+SplashImage.h:

#import <UIKit/UIKit.h>

/**
 * Category on `UIImage` to access the splash image.
 **/
@interface UIImage (SplashImage)

/**
 * Return the name of the splash image for a given orientation.
 * @param orientation The interface orientation.
 * @return The name of the splash image.
 **/
+ (NSString *)si_splashImageNameForOrientation:(UIInterfaceOrientation)orientation;

/**
 * Returns the splash image for a given orientation.
 * @param orientation The interface orientation.
 * @return The splash image.
 **/
+ (UIImage*)si_splashImageForOrientation:(UIInterfaceOrientation)orientation;

@end

UIImage+SplashImage.m:

#import "UIImage+SplashImage.h"

@implementation UIImage (SplashImage)

+ (NSString *)si_splashImageNameForOrientation:(UIInterfaceOrientation)orientation
{
    CGSize viewSize = [UIScreen mainScreen].bounds.size;

    NSString *viewOrientation = @"Portrait";

    if (UIDeviceOrientationIsLandscape(orientation))
    {
        viewSize = CGSizeMake(viewSize.height, viewSize.width);
        viewOrientation = @"Landscape";
    }

    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];

    for (NSDictionary *dict in imagesDict)
    {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
            return dict[@"UILaunchImageName"];
    }
    return nil;
}

+ (UIImage*)si_splashImageForOrientation:(UIInterfaceOrientation)orientation
{
    NSString *imageName = [self si_splashImageNameForOrientation:orientation];
    UIImage *image = [UIImage imageNamed:imageName];
    return image;
}

@end

Review: Xcode 5 makes better, faster, stronger iOS and OS X apps , The 5 main parts of the Xcode development environment and how to navigate around; How to code and build your user interface with Xcode� 5. ⌃A, ⌃E, ⌃K That’s three separate shortcuts not one! In any text field, Control-A moves the cursor to the beginning of the line; Control-E moves it to the end, while ⌃K deletes everything from the cursor to the end of the line.

Xcode Tutorial for Beginners (Just updated for Xcode 11), You don't need to 'configure iTunes' to download software or use the Mac App Store, but those are the official download channels. If you really� Xcode is an IDE – an integrated development environment – created by Apple for developing software for macOS, iOS, watchOS, and tvOS.It is the only officially-supported tool for creating and publishing apps to Apple’s app store and is designed for use by beginners and experienced developers.

From where to download xcode 5?, Xcode # Build, test, or archive an Xcode workspace on macOS. Optionally package an app. - task: Xcode@5 inputs: #actions: 'build'� On September 18, 2013 Xcode 5.0 was released. It shipped with iOS 7 and OS X 10.8 Mountain Lion SDKs. However, support for OS X 10.9 Mavericks was only available in beta versions. Xcode 5.0 also added a version of Clang generating 64-bit ARM code for iOS 7. Apple removed support for building garbage collected Cocoa binaries in Xcode 5.1. 6.x series

Xcode build and release task, Xcode 5 Start to Finish: iOS and OS X Development (Developer's Library) [ Anderson, Fritz] on Amazon.com. *FREE* shipping on qualifying offers. Xcode 5 Start� ‎Xcode includes everything developers need to create great applications for Mac, iPhone, iPad, Apple TV, and Apple Watch. Xcode provides developers a unified workflow for user interface design, coding, testing, and debugging. The Xcode IDE combined with the Swift programming language make developing…

Comments
  • Anybody know the iPad images with no status bar?
  • @Mohamed Hafez: Pichirichi does actually have them included in his list. They are LaunchImage-Portrait~ipad.png, LaunchImage-Portrait@2x~ipad.png, LaunchImage-Landscape~ipad.png, and LaunchImage-Landscape@2x~ipad.png.
  • What do numbers 700 and 800 mean?
  • I catched it: it means iOS 7 & 8
  • It's incredibly annoying that XCode will automatically create a file name for these image assets and make you jump through hoops to figure out how to directly access them...
  • Works great. Clever and elegant approach to search main bundle's info dictionary for available launch images and then picking the one with matching resolution!
  • This is a brilliant idea, better than mine and also future proof, unless Apple change the structure of info.plist.
  • This is a very clever solution. I have multiple targets in my Xcode projects and just using the LaunchImage string does not always return the correct image. Thanks a lot.
  • Brilliant idea though. But does not work for screens with opaque status bar. So needed to change self.view.bounds.size to [UIScreen mainScreen].bounds.size
  • Great Solution. Small edit required: There's an implicit conversion from UIInterfaceOrientation to UIDeviceOrientation. Use UIInterfaceOrientationIsLandscape() instead.
  • This worked for me, but I really wish there was a simpler way of referencing the launch image.