In my project I have multiple asset catalogs, one of which is named images.xcassets.
I am able to access all the images inside said asset catalog using either UIImage(named: "image.png") or #imageLiteral(resourceName: "image.png") (with and without the file extension .png).
Issue
Now, trying to access resource image2.png works just fine with the iOS 11.2 iPad 10.5" simulator. However, the exact same build crashes when using the iOS 11.2 iPad 12.9" (2nd gen.) simulator with the following "message":
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
This issue has just emerged, I was always able to access the image before today. I have not touched a thing...
What I've tried
target membership set to project's target
removed the asset catalog from Copy Bundle Resources in Build Phases
cleaned and rebuilt the project
deleted image2.png from the catalog and added it back
deleted the whole asset catalog and added it back
deleted the app from the 12.9" simulator and re-installed it
quit & re-opened Xcode and the simulator
Any idea why this specific resource can't be accessed anymore?
Notes:
so far, I didn't run into this error using real devices (tested with iPad Air 2 & iPad Pro 1st Gen.)
Has to do with the color space apparently.
I was able to "save for web" in Photoshop and convert the image to sRGB for an image file that doesn't crash in the iPad Pro 12.9" 2nd generation simulator.
Related
In image asset editor we can add launch image but it'll not appear in devices I can say atleast iPhone devices but If you ignore to add LaunchImage in assets xamarin won't let you compile the app.so you have to add the LaunchImage and at the same time you have to have Launch Screen.storyboard Why is this anomaly ? and how to keep on using static images
I have created separate imageset in asset library and added a image view in launch screen and referred that newly added imageset but its not working screen appears empty
It's not a Xamarin problem, but iOS itself.
Launch image required for iOS version lower than 8.0. So if you want to support them, you need to add all images in to assets.
LaunchStoryboard you can use for all iOS version above 8.0 (included). It will stretch out automatically for each device.
You can select most appropriate solution for your project in Info.plist
iPad Pro requires 167x167 App icon and 2732 x 2048 (landscape) launch image. But where should I put them? Xcode 7.1 Asset Catalogs don't provide any place to add iPad Pro specific icons or images.
My launch image is size specific, so using storyboard for this isn't a good option.
Apple commented on this issue: "Latest beta (7.2b3) added 83.5#2x app icon slot to asset catalogs, and Developer relations reported in a radar comment that they no longer support launch images and will not be adding the iPad pro launch image size to asset catalogs."
Taken from here.
Use Launch Screen storyboard.
You can also disable Launch Screen File and Launch Images Source from project General settings and use the old way - define all Launch Images in Info.plist.
Info.plist:
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>DefaultPro-Landscape</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{1366, 1024}</string>
</dict>
...
</array>
More info about UILaunchImages in Info.plist in this post:
How do I create launch images for iPhone 6 / 6 Plus Landscape Only Apps?
You should use Launch Screen Files for iPad Pro instead of Launch Images.
First, from iPad Pro, iOS don't support Launch Images, so you can not find the right sizes for iPad Pro's launch images in Xcode 7.1.
Second, if you don't use Launch Screen File, you app running on iPad Pro will be scaled, which is so called 'Display Zoom'.
It looks like you'll need to use the Launch Screen storyboard or xib file to support launch screens specific for iPad Pro.
Per Apple, you should be able to use both the launch image assets to support pre-iOS8, and the Launch Screen file for iOS8+. From the Apple App Distribution Guide :
"For iOS 7 deployment targets, you can supply both a launch screen file and launch images. In iOS 8, the launch screen file is used, and in iOS 7, the launch images are used."
also these docs state:
"If you also need to support earlier versions of iOS, you can continue to supply static launch images in addition to a launch file."
However, in my case even though I have a LaunchScreen.storyboard file, it isn't getting used when I have launch images in an asset catalog. i.e.: I always see the asset catalog launch images instead of the launch screen. I verified the Launch Screen file is set in the info.plist and that it has the "Use as Launch Screen" flag set. I'm also using size classes and auto layout.
If you don't find the "wells" where to put the icons in asset catalogue, perhaps you changed your App settings from iPhone to iPad at a later point and then the iPad "wells" are not visible. You can turn them on by doing this:
The set will only contain image wells for icons that are relevant depending upon your project's configuration at the time the asset catalog was created. If an image well is missing, expand the settings inspector and check the appropriate boxes under the App Icon pane depending upon your project's deployment target and supported devices.
In Xcode 6.2 and just testing the initial build of a watch app with no buttons, labels, text fields, just insuring that a blank app runs after adding the WatchApp as the target and selecting the watch in simulator hardware I get the following error.
Asset Catalog set AppIcon has an unassinged image and
Ambiguous Content The app icon set "ApplIcon has unassigned image.
The simulator pops up with both the IPhone 6 and Watch images but I get these two errors
This is a known issue, please see Xcode 6.2 Release Notes
i.e.
When creating a new Apple Watch app target, the newly created asset
catalog includes an "Unassigned" slot in the catalog's app icon.
Select the "Unassigned" slot and delete it using the Delete key.
(19978639)
The same is - at this moment- in Xcode 6.3.
I get this issue when building UI in storyboard (or xib) in xcode's interface builder. After I assign the image (with the same name in asset catalog) to an image view in Interface Builder, the xcode loads 3x image file instead of 2x in any non-retinahd devices which is running ios8.
Note that this bug only happens when app's deployment target is set to 6.0 or 6.1.
I'm using asset catalog to manage image resources.
This issue is tested and happens both in Xcode 6.0.1 and 6.1 GM seed 2.
I googled the issue and could rarely find the related topic. So I wonder if any one gets the same issue with me and what is the best workaround for it. Thank you.
The following is the steps to reproduce this issue in case anyone has the interest:
Install Xcode 6
Create an iOS project and set to use objective-c as project language.
Change the app's deployment target to 6.0 or 6.1.
Add 1x, 2x and 3x version of an image to the asset catalog.
In interface builder, add a UIImageView to the default view controller's view of default storyboard.
In interface builder, set the image's name as the same image name added in step 4 in asset catalog.
Select the simulator as iPhone6 (or any simulator runs on iOS 8.0 except iPhone6 Plus).
Clean the project (Product/Clean).
Run the project.
UPDATE:
As #Andrei Mankevich mentioned in the comment, this bug seems to be fixed in iOS 8.1.
And I have confirmed it using the simulator running iOS 8.1 in Xcode 6.1 GM seed 2(sorry I don't have a real device running iOS 8.1 currently).
So as #Andrei Mankevich pointed out, this bug might only exist in iOS 8.0.x.
After some research it looks like this issue is related to iOS indeed and so it isn't likely to be fixed by upcoming Xcode update. That's what documentation says about Asset Catalog:
For projects with a deployment target of at least iOS 7 or OS X 10.9, Xcode compiles your asset catalogs into a runtime binary file format that reduces the download time for your app.
So when we use deployment target 6.0 resources are just stored in different way inside IPA file. While iOS 8.0 is loading compiled resouces correctly, it has the issue with loading non-compiled resources and always loads 3x density images. And this issue was already fixed in iOS 8.1.
As for possible workaround in our app we fixed it by setting exact size of each element in xib and using UIViewContentModeScaleAspectFit value for contentMode flag . We use the same image resources with just different resolution so after scale they also look the same. But of course it should have negative impact on performance.
I have this ObjC code:
[self.myButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:#"%#-button", self.myObject.name]]
forState:UIControlStateNormal];
This works great with these combinations:
XCode 5, iOS 7.1
XCode 6, iOS 7.1
XCode 6, iOS 8
But when I port one single class of the project to Swift -- a class which is unrelated to anything that is happening in this code -- the images do not display in XCode 6 for iOS 7.1. It does work with XCode 6 and iOS 8.
I finished porting the entire project to Swift, so now the code looks like:
self.myButton.setBackgroundImage(
UIImage(named:self.myObject.name + "-button"),
forState: UIControlState.Normal
)
And it's still unhappy on iOS 7.1. Still no images. (The custom icon works, though.) Yes, I know this is just beta software, and it's probably just a bug ... ? But I'm just wondering if anyone has a solution or insight.
I only started using XCode and ObjC about a week ago (surprise! ObjC is now deprecated!), so it could be that I am missing something, but since it works in ObjC, and in Swift+iOS8, it seems like it's probably a bug.
I've managed to overcome this by not using Asset Libraries to store my images.
Add your images to the project using the "old style naming", like Image.png and Image#2x.png, then load them without any extensions in the filename, as such:
let myImage = UIImage(named:"Image")
Fixed in XCode 6 beta 2
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, and now also iOS 7 and OS X
10.9. (17029658)
release xcode 6 beta 2 notes
For me it was because I suddenly add jpg image to Image Assets. Just resaved it as png and all work well
I guess you are testing it on simulator. Make sure the desired image is copied to 7.1 bundle. To do it check copy resources bundle build stage or check manually app bundles for different simulators at ~/Library/Application Support/iPhone Simulator/.
#o KB o points out here that the Xcode6 Beta release notes mention that xcassets bundles aren't supported for iOS7. Additionally, I've found it surprisingly hard to get rid of asset bundles in your project. This can cause naming collisions if your images have the same name as images that were previously in the bundle (you probably want the same names, so you don't have to rename your images everywhere in code / IB).
Here's a workaround:
Copy each image out of your .xcassets image bundle to a new directory (let's call it Images/). See below for a script to make this easier.
Delete your .xcassets bundle. (surprisingly, removing it from the project isn't enough. In my testing, if the .xcassets bundle was anywhere in the same directory as the Xcode project or related sources, it would get copied in. Alternately, you can remove the .xcassets extension)
Add all your image files to your Xcode project
Clean (cmd + shift + k)
Delete the app from the target device or simulator
Install and run
To make step #1 less tedious, I wrote a script to copy images out of the .xcassets bundle and into a directory of your choice: https://github.com/johnboiles/xcasset_exporter
mkdir Images
./xcasset_exporter.py MyProject/Images.xcassets Images
I had a problem where some images in xcassets worked and others didn't (only for iOS 7.1).
I solved it by deleting the problematic image sets and creating new ones with different names.
If you are attempting to use an external bundle with proper PNG images stored in either an "old style" folder or inside xcassets then apps running on iOS 7 will not be able to access these images.
I tried a suggestion from another answer here to add the "old style" folder path of the images in the external bundle but that didn't work for me. My solution, which fit my scenario, was to expose an outlet for the resource in the nib inside the external bundle. This allowed the main app to set with an accessible image to it. Whether this is a bug or simply a constraint in using nibs contained in external bundles with iOS 7 will matter less as it rides on to the usage sunset...
PS: Apps running on iOS 8 where able to access images in the external bundle xcassets just fine so choose your poison for supporting iOS 7.