Loading NSImage with imageNamed from xcassets crash in older osx versions - xcode

So, I have an xcassets that is shared amongst quite a few apps. I'm developing with Xcode8 in a Mac Mini with MacOs Sierra installed in it. If I compile and run in the development machine, there's no issue at all. However, when I try to run it in a device with OSX Mavericks I get a crash. Here's the trace in the report
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff887dc866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff87a3935c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff88614bba abort + 125
3 libsystem_c.dylib 0x00007fff885dea5f __assert_rtn + 321
4 com.apple.coreui 0x00007fff875aa1a7 CUIRenditionKeySetValueForAttribute + 307
5 com.apple.coreui 0x00007fff875a9004 -[CUIStructuredThemeStore _canGetRenditionWithKey:isFPO:lookForSubstitutions:] + 200
6 com.apple.coreui 0x00007fff875a8f1b -[CUIStructuredThemeStore canGetRenditionWithKey:] + 22
7 com.apple.coreui 0x00007fff875c4eab -[CUICatalog _resolvedRenditionKeyForName:scaleFactor:deviceIdiom:deviceSubtype:] + 291
8 com.apple.coreui 0x00007fff875c4c53 -[CUICatalog imageWithName:scaleFactor:deviceIdiom:deviceSubtype:] + 29
9 com.apple.AppKit 0x00007fff88820b1b +[NSImage _catalogImageWithName:bundle:] + 132
10 com.apple.AppKit 0x00007fff8881aefd +[NSImage imageNamed:] + 261
If I remove the image from the xcassets and include it "individually" in the app's bundle -by dropping it to the app's project navigator- it loads just fine. But I'd like to avoid this if possible, as it's cleaner to have shared images in just one xcassets.
Any thoughts or ideas? Thanks in advance.

I could bypass this error by following this workaround provided by Apple for iOS 7 devices:
To work around this issue, update the deployment target to iOS 8.0 or
higher, or add a single image to the asset catalog that has at least
five attributes specified across the image set, such as: scale (1x,
2x, 3x) idiom (add iPad,iPhone, and a universal asset) direction (left
to right, right to left) width/height class (any & compact, and so
forth) memory (add a 1 GB asset) graphics (add a Metal 1v2 asset) It
is not necessary to use the image in your code or to add all of these
attributes. (27852391)
Here's how this dummy imageset looks like:

Related

Qt DevicePixelRatio not set under macOS

I'm working on a cross platform application for Linux, Windows and macOS and there is part where I need to scale something based on the screen scaling. So far I have been using QApplication::desktop()->devicePixelRatioF() under Linux and Windows to get the scale factor and that works fine but now one of my users run into an issue with macOS where there is obviously screen scaling going on but the devicePixelRatio is always set to 1.
This is how scaling variables look like on his machine:
devicePixelRatio: 1
devicePixelRatioF: 1
logicalDpiX: 72
logicalDpiY: 72
physicalDpiX: 114
physicalDpiy: 114
I have also tried reading out the values from QApplication::primaryScreen()but they look the same.
QScreen devicePixelRatio: 1
QScreen logicalDotsPerInch: 72
QScreen logicalDotsPerInchX: 72
QScreen logicalDotsPerInchY: 72
QScreen physicalDotsPerInch: 113.5
QScreen physicalDotsPerInchX: 113.5
QScreen physicalDotsPerInchY: 113.5
According to my user he should have 227 dpi:
"13-inch MacBook Pro models introduced in late 2012 or later. Native resolution: 2560 x 1600 at 227 pixels per inch. Support for millions of colors."
Any idea whats going on here or how we could detect the scale factor?

Setting the app icon of a Mac osx app in Xcode 2.5

This has been bugging me for a while. Xcode 2.5 handles icons differently from later versions of Xcode so there is no Xassets file. Does anyone know how to set the app icon?
You need to add high resolution icon. Now, if you want to target only iOS 7, you just need 76 x 76, 120 x 120 and 152 x 152 icon sizes. If you also want to target iOS 6, you’ll need 57 x 57, 72 x 72, 76 x 76, 114 x 114, 120 x 120, 144 x 144 and 152 x 152 icon sizes. Below is the detailed description how to add the same.
Then add all of them as
Below is the list of icon dimensions.
Hope this helps.

Is it possible to distribute Image Units with my application?

Mac OS X Mavericks
I was told that the issue was fixed in Mac OS X 10.9
Original
I read the documentation and didn't find the answer. It suggests to create Image Units, it requires to put this unit inside either ~/Library/Graphics/Image Units or /Library/Graphics/Image Units (putting the image unit inside Your.app/Contents/Library/Graphics/Image Units has no effect).
There is other, non-recommeneded way, to create Image Unit, which allows you to distribute cikernels and access the filter from your code. But it prevent you from creating non executable filters which is a big lack of performance.
I looked through the contents of bundles of applications like Pixelmator or Acorn and found that they don't use Image Units as well. I hope this is a mistake and there is a way to distribute Image Units within an application bundle.
I'm looking for a solution that will be accepted by Mac App Store validation.
Solution which doesn't allow you to use non executable filters
From the CIPlugIn header:
/** Loads a plug-in specified by its URL. */
+ (void)loadPlugIn:(NSURL *)url allowNonExecutable:(BOOL)allowNonExecutable
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7;
/** Loads a plug-in specified by its URL.
If allowExecutableCode is NO, filters containing executable code will not be loaded. If YES, any kind of filter will be loaded. */
+ (void)loadPlugIn:(NSURL *)url allowExecutableCode:(BOOL)allowExecutableCode
AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER;
New method isn't listed in official docs. So, to load bundle you simply do:
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_6)
{
[CIPlugIn loadPlugIn:[[NSBundle mainBundle] URLForResource:#"YourPlugin" withExtension:#"plugin"]
allowNonExecutable:YES];
}
else
{
[CIPlugIn loadPlugIn:[[NSBundle mainBundle] URLForResource:#"YourPlugin" withExtension:#"plugin"]
allowExecutableCode:YES];
}
Unfortunately if you try to use CIFilter with QuartzCore framework (e.g. with CALayer) app will crash because of stack overflow.
frame #0: 0x00007fff8b6a5d36 CoreImage`-[CIFilter copyWithZone:] + 12
frame #1: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #2: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47
frame #3: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #4: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47
frame #5: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #6: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47
As well as the Library paths you mention, Mac OS X will also look in YourApp.app/Contents/Library.
I think everything should work if you put your Image Unit in YourApp.app/Contents/Library/Graphics/Image Units/.

Marketplace App Icon Usage

When submitting a Windows Phone 7 app, you need to include the following icons:
Large Mobile
Small Mobile
Large PC
Once listed on the market, the Large PC icon is displayed in the Marketplace on both the phone and PC - different style icons were used for each. What are these other icons used for?
Here is an image to clarify what we are seeing:
There are 6 images to be concerned about, but given pixel dimensions of two of them being the same, you could use just 5 images.
# Image Where Used? Size (Pixels) File Type Require/Option
1. Small mobile Phone Marketplace catalog 99 x 99 PNG Required
2. Large mobile Phone Marketplace catalog 173 x 173 PNG Required
3. Large PC PC Marketplace catalog (Zune) 200 x 200 PNG Required
4. Background Background panorama 1000 x 800 PNG Optional
5. App Icon In the app list on the phone 62 x 62 PNG Required
6. App Tile In the start page on the phone173 x 173 PNG Required
Notes:
1-4 are for selling/marketing your
app. 1-2 are shown in the
Marketplace on the phone and 3 is
shown in Zune. #4 - I believe it is
shown on both phone/Zune.
5-6 are used once the app is
installed. These are to be listed your WMAppManifest.xml as <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath> and <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI> respectively.
2 and 6 are the same pixel size, so they
can be the same, if that's what you want. I've done that.
You can use transparency on #6,
but don't use it on any other image.
If you browse the marketplace in the Zune software on the PC you'll see the 2 different size icons being used. The larger size is used in the list at the top of the page and the smaller size in the "we recommend" and "new apps" sections.

Why do my MSI images look corrupted when using WiX?

I'm setting a custom banner and dialog image for my WiX generated MSI.
<WixVariable Id="WixUIBannerBmp" Value="./build/msi/InstallerBanner.jpg" />
<WixVariable Id="WixUIDialogBmp" Value="./build/msi/InstallerDialog.jpg" />
For some reason, the image becomes corrupted when built into the MSI. I've added the two images to my question for easy comparison. I've tried BMP and JPEG with a whole range of compression types - and they all look exactly the same. I can verify that I'm using exactly the correct image dimensions (500 by 63 pixels).
Here's the original image:
Original image http://img193.imageshack.us/img193/7016/installerbanner.jpg
And here's what it looks like in the MSI:
Image in use - 1 http://img26.imageshack.us/img26/2996/bannerinuse.jpg
Update:
Thanks for your answers, I got the wrong dimensions from a tutorial, that's actually very out dated and (apparently) very inaccurate. Never the less, it's a good hacking resource. I'll stick to the manual in future!
Your image is too big dimension-wise. Banner Images must be 493 × 58 and your image is 500 × 63, causing it to be resized.
See Customizing Built-in WixUI Dialog Sets
By the way: nice to see Synergy2 is finally getting an update!
Andrew's right. It's covered in wix.chm.
Those are the wrong dimensions. From the relevant wix documentation topic:
Replacing the default bitmaps
The WixUI dialog library includes
default bitmaps for the background of
the welcome and completion dialogs and
the top banner of the other dialogs.
You can replace those bitmaps with
your own for product branding
purposes. To replace default bitmaps,
specify WiX variable values with the
file names of your bitmaps, just like
when replacing the default license
text.
Variable name / Description / Dimensions:
WixUIBannerBmp / Top banner / 493 × 58
WixUIDialogBmp / Background bitmap used on the welcome and completion dialogs / 493 × 312
WixUIExclamationIco / Exclamation icon on the WaitForCostingDlg / 32 × 32
WixUIInfoIco / Information icon on the cancel and error dialogs / 32 × 32
WixUINewIco / Button glyph on the / BrowseDlg 16 × 16
WixUIUpIco / Button glyph on the BrowseDlg / 16 × 16
Using WiX ver. 3.7.1224.0 (Dec'12), I have to create an image 616 × 390 to fill the dialog and avoid stretching. The clear zone to the left of the dialog text is 234 pixels wide.
The banner is still 493 × 58.
I found that to customize the WixUIDialogBmp for WiX 3.5, the dimensions must be 493x312 pixels. So, to make the banner only appear in the left 164 pixels of the dialog box, fill the right 329 pixels with white pixels. Then it should display correctly.
Try using .bmp images with specified dimensions as shown below
For more info : https://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html

Resources