Post

Replies

Boosts

Views

Activity

Displaying HDR image, isn't showing dynamic range
I'm playing around with HDR images in iOS. I'm able to load an HDR image, but it isn't displaying with the expected "pop" I see of the same image in the Photos app. I exported the photo from Photos (on the Mac) using Export Unmodified. I reimported to confirm Photos shows the "pop." I'm trying both UIImage and CIImage, with the same results. The below is tested on my iPhone 14 Pro (not Simulator). The Storyboard for the code below has three UIImageViews (top, middle, and bottom). let fileURL = Bundle.main.url(forResource: "IMG_6972", withExtension:"HEIC")! var config = UIImageReader.Configuration() config.prefersHighDynamicRange = true let imageReader = UIImageReader(configuration: config) let topImage = imageReader.image(contentsOf: fileURL)! topImageView.preferredImageDynamicRange = .high topImageView.image = topImage // The image appears, looks SDR print("topImage.isHighDynamicRange: \(topImage.isHighDynamicRange)") // true let ciimage = CIImage(contentsOf: fileURL)! bottomImageView.image = UIImage(ciImage: ciimage) // The image appears, looks SDR - identical to topImage print("color space: \(ciimage.colorSpace!)") // (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Display P3) let gainMap = CIImage(contentsOf: fileURL, options: [.auxiliaryHDRGainMap: true])! middleImageView.image = UIImage(ciImage: gainMap) // The gain map image appears as expected Additionally, for comparison, I tried: let sdrImage = UIImage(named: "IMG_6972.HEIC")! // UIImage.named doesn't support HDR print("sdrImage.isHighDynamicRange: \(sdrImage.isHighDynamicRange)")``` // false, as expected bottomImageView.image = sdrImage and the image matches the other two, further confirming the HDR version of the image isn't displaying in either UIImageReader or CIImage versions above. I also track the UIScreen's use of EDR with: print("currentEDR: \(UIScreen.main.currentEDRHeadroom)") print("maxEDR: \(UIScreen.main.potentialEDRHeadroom)") maxEDR is 8.0. currentEDR is 1.0 at launch, 1.3 after a 1.0 second delay. Which makes me think it might be showing a little HDR, but not enough to be noticeable. Is there something special I need to do to set the UIViewController, UIScreen, or UIApplication (etc) to be an an "HDR Mode" or similar?
1
0
529
Jun ’24
XCUITest Screenshots not saving
I have some (very old ObjC) XCUITests, in Xcode 15.2. I recently noticed programmatic screenshots are not saving. The screenshots generated automatically by XCUITest are saving fine. This is code that used to work as expected; I do not know when it broke as I haven't had need to run this in a while. -(void)takeScreenshotWithName:(NSString *)name { XCUIScreenshot *screenshot = XCUIScreen.mainScreen.screenshot; XCTAttachment *attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; attachment.lifetime = XCTAttachmentLifetimeKeepAlways; attachment.name = name; [self addAttachment:attachment]; UIImage *image = screenshot.image; UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); } During testing I added the UIImageWriteToSavedPhotosAlbum call, to verify the code is running and the image is available - and it does. But I really don't want these images cluttering up my library. The results are the same whether I run my tests from within Xcode, or via the command line. I need these screenshots so I have a set in PNG format, with standardized naming, for archiving, searching, and comparisons. The automatic screenshots are in Xcode's format - useful when reviewing a single test, which isn't my use case here.
2
1
390
Jun ’24
I hosed Xcode's Platforms list, what now?
In a feat of unmitigated disk cleaning, I removed who-knows-what, likely from ~/Library/Developer. Now I can't build apps that rely on watchOS (or likely tvOS/visionOS from the look of things). Run a try to build, Xcode tells me I should download watchOS, immediately shows me that it has, then does nothing. My Platforms window looks like this. If I tap Get next to watchOS 10.2 it looks like it succeeds immediately, but doesn't work (notice that 10.2 is already in the list). If I try to delete 10.2 from this list, it gives me an error that it can't find it on disk to delete it. I'm guessing there's a mismatch between some preference file and reality. Totally my fault I'm certain. Best way to recover?
4
0
490
May ’24
Xcode 14: [Assert] UINavigationBar decoded as unlocked for UINavigationController
In Xcode 14 RC, I'm seeing this in the Console: [Assert] UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems. navigationController=<MasterNavigationController: 0x135016200>, navigationBar=<UINavigationBar: 0x134f0aec0; frame = (0 20; 0 50); opaque = NO; autoresize = W; layer = <CALayer: 0x600000380be0>> delegate=0x135016200 The above message displays exactly four times immediately at app launch (top of the console) then does not repeat. MasterNavigationController is the internal class for the app's navigation controller. It is in a Storyboard, with very minimal ObjC code. I am not setting any specific size for the nav bar. I don't remember seeing this in earlier builds of Xcode, but I can't swear to it that this is new. No assertion actually fires.
41
23
29k
Sep ’22
ClassKit - how to confirm device can save contexts?
I'm updating an app that already has ClassKit compatibility. The app makes a call at launch to get JSON from a server, then creates contexts from that JSON. That works fine. The downside is the app makes a the network call even if the iPad isn't on Apple School Manager - thus would never be able to save the contexts. We'd like to prevent making the network call unless we know the device has the capability to save contexts. What's the best way to do that?
1
0
950
Apr ’22
WidgetKit Options Provider not called
I'm adding a Widget to an existing iOS app. The Widget's intent definition allows the user to choose the preferred item in configuration. The provideItemOptionsCollection function in IntentsHandler.swift is not called, and I can't figure out why. I developed the extension inside a dummy app. It works as expected there. I copied the code and intents handler info to the real app. All looks good, other than the user cannot configure the widget. The user gets the No options were provided for this parameter alert when attempting to choose the item. I've confirmed I'm using the correct function signature, by copying it from Xcode's generated SelectionIntent.swift file. I added an os_log call as the first line in the function, and confirmed it does not appear in the console. I also added an os_log call to the same class's default (unchanged) handler, which does appear in console as expected. I'm experiencing the same issue on both the Simulator and a physical device. Xcode 12.4, iOS 14.4.
1
0
963
Apr ’21
WidgetKit configuration, one parameter based on selection of another parameter
I'm working on a WidgetKit widget with two dynamic parameters. One of those parameters is limited to options allowed by the first. Let's say the first is the Captain, and the second is the Captain's Ship. Allowable configurations might be (ignoring canon): Captains: [Kirk, Picard, Crunch] Captain: Kirk, Ship: [Enterprise, Galileo] Captain: Picard, Ship: [Enterprise, Voyager, Cube] Captain: Crunch, Ship: [Sugar, Berry, Chocula] I have the logic working. For example, if the user selects Picard, then taps the Ship button, only Enterprise, Voyager, and Cube are available options. The user can then choose one of those ships (say, Cube) and all is good. However the Ship option doesn't change or reset when the Captain is changed. Let's say after the above setting, the user changes the Captain to Kirk. The Ship remains set to Cube. The user can exit the widget's configuration as if all is good, but that's an invalid configuration. What I'd like to happen: When the user changes the Captain, the Ship changes to the first of the available Ship options for that selected Captain. I'm also fine if the Ship blanks out (requiring a choice), or the UI forces a prompt of a Ship (confined by available options), or almost anything else that prevents an invalid combination. Is there a way to trigger a programmatic change to the second parameter based on the selection of the first? I do not want to present an "Invalid Combination" message in the runtime Widget. I suppose my backup is to choose a ship for the user if they've made an invalid selection, but that's not ideal. If it matters, the first parameter in the real Widget (the Captain in my example above) is truly dynamic (an array of strings provided via API). The second parameter (the Ship above) is a fixed set of three options, where any one, two, or all three could apply to any of the first parameter's selection. It is anticipated the user may create multiple Widgets with different configurations.
0
0
657
Dec ’20
Download On-Demand Resources via MDM?
We have an iOS app with a large resouce size, not currently using On-Demand Resources. I'm investigating shrinking the app's initial bundle, and using On-Demand Resources to reduce the on-disk size of the app to what the user actually needs, which can usually be determined at time of the install. The app is used in an environment where the user would not have time to launch the app then wait for a lengthy resource download before using the app.The app is most frequently installed via MDM. Does anyone know if it's possible to push an instruction over MDM to download specific assets to the app, so the assets appropriate for the user are available at first launch?
1
0
632
Apr ’20