Dear experts,
I get glyphs from the system font using CTFontGetGlyphsForCharacters, something like this:
UIFont* uifont = [UIFont monospacedDigitSystemFontOfSize: s weight: w];
CTFontRef font = (__bridge CTFontRef)uifont;
CTFontGetGlyphsForCharacters(font, ....);
The characters that I ask for are basically latin-1 plus a few others.
The app is not localised for Chinese. When I change the phone's default language to Chinese, this code gets glyphs for most characters OK but it fails for a few punctuation symbols:
91 = [
93 = ]
183 = middle dot
8220 = left double curly quote
8221 = right double curly quote
Can anyone guess what's going on here? What's special about those characters?
Thanks, Phil.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
In TestFlight crash reports, all I see is the stack trace.
Is there any other information hidden in there, such as the specific signal (etc) that caused the app to terminate?
Thanks.
If I use SubscriptionStoreView.init(groupID), it seems to be able to look up all the Products that have that subscription group ID. But I don't see any public method for doing that myself. Am I missing something, or is SubscriptionStoreView using a private method to do this lookup?
I know that historically it has always been necessary to know the product IDs of all the products you want to sell; you have never been able to ask Store Kit to give you a list. SubscriptionStoreView doesn't seem to have this limitation, which is a bit surprising.
The docs for Transaction.updates say:
Use updates to receive new transactions while the app is running. This sequence receives transactions that occur outside of the app, such as Ask to Buy transactions, subscription offer code redemptions, and purchases that customers make in the App Store. It also emits transactions that customers complete in your app on another device.
Note that after a successful in-app purchase on the same device, StoreKit returns the transaction through Product.PurchaseResult.success(_:).
So Transaction.updates isn't supposed to include transactions for purchases that are made in this instance of the app, right? I have this code to get those transactions:
SubscriptionStoreView(groupID: group_id) {
}
.onInAppPurchaseCompletion() { product, result in
.....
}
But when I make a purchase using this SubscriptionStoreView, I see that both this .onInAppPurchaseCompletion code and my code observing Transaction.updates is called.
Is this expected? Will it work reliably without the .onInAppPurchaseCompletion ?
Thanks.
I am attempting to use UITextSelectionDisplayInteraction. It basically works, but I'm unsure how the selection handles are supposed to work. The documentation is minimal and the WWDC video (2023 session 10058) doesn't say much either.
As the name suggests, it seems that this interaction only displays the cursor, selection background, and handles. As I change the selection, it updates these views.
So if I want the user to be able to drag the selection handles I need to implement that, right? OK, so I add a gesture recognizer to each selection handle. But this doesn't seem to do anything, i.e. the gesture recognizer action never seems to be invoked.
Maybe I'm doing something wrong - but I'd like to understand what is supposed to happen. Is adding a pan gesture recognizer to each selection handle the right approach?
P.S. I wanted to tag this "WWDC2023-10058", but the per-session tags seem to have disappeared. Is this a forum bug, or deliberate?
Dear Experts,
My app is observing UIPasteboardChangeNotification in order to enable/disable its paste button.
I do not seem to be getting any notifications when other apps copy to the clipboard. For example, if I have my app and Safari in split-screen on my iPad and I copy something in Safari, I don't see the notification. Similarly if I switch to Safari, copy something, and switch back to my app, I do not get the notification either when I'm in the background or when I return to the foreground.
The only time that I see UIPasteboardChangedNotification is when the clipboard is modified by my app itself.
Is this supposed to work? Is there some other way to get notified when the clipboard is changed by another app?
Thanks.
I am experimenting with drag-and-drop on iPadOS.
If I drag a JPEG image from a webpage in Safari to my app, I get items of types public.jpeg and public.url.
Typically, the URL is the URL of the image.
If, however, the image is itself a link, then the URL seems to be the target of the link.
Is there some way that I can always get the URL of the image itself? Is there some way that I can determine whether the URL I have received is the URL of the image or of a link?
Dear Experts,
When I use PHImageManager's requestImageDataAndOrientationForAsset method I always seem to get JPEG data, even when the original items in the photo library are PNGs (such as screenshots) or HEICs.
Have I missed a setting somewhere that determines whether or not a "most compatible" format is used in this API?
Thanks.
Dear Experts,
I have an Xcode project that generates two iOS app targets. Most of the code is shared between the two targets. Let's call them "Project", "App1" and "App2".
I have some Swift code that is called from objC++. To make this work, in the objC++ files currently I #include "App1-Swift.h". Clearly this only works when building App1. What's the right way to set this up to work for both targets?
Looking at the build settings, currently the "Generated Header Name" is set to "$(SWIFT_MODULE_NAME)-Swift.h". Presumably, SWIFT_MODULE_NAME expands to the target name.
There are various possible ways to fix this, but which one is "right"? I bet that if I fix it in the wrong way, something else will go wrong later. I could:
Change the objC++ to #include different headers depending on the target being built.
Change the build setting to use the project name (from a variable?) instead of the SWIFT_MODULE_NAME.
Somehow cause SWIFT_MODULE_NAME to equal the project name, rather than the target name.
Any advice?
Thanks.
According to this page: https://developer.apple.com/documentation/xcode/interpreting-the-json-format-of-a-crash-report
the storeInfo element of a JSON crash log may contain a deviceIdentifierForVendor element, but quote "This field is only present for TestFlight builds of an app".
A user has just sent me a crash report which contains this key, but this isn't a testflight build.
The suspicion is of course that the app is "cracked" in some way, but having interacted with the user for some time I think this is unlikely. He has had various issues with the app, affecting multiple devices; I have been wondering if there is something wrong with his Apple account.
The docs also say that this "replaces the CrashReporter Key field", yet this crash report contains both.
So my question for other developers: if you have any .ips crash logs, obtained from non-testflight users of your apps, please could you grep them for deviceIdentifierForVendor and let me know what you find.
If any Apple people have any clues about how this could innocently end up in a crash report, please let me know. Maybe it's a documentation bug?
The WatchOS Control Center has an Edit/Done button at the bottom, and in its edit mode, elements can be moved around and added/removed.
Yet, the SwiftUI List doesn't have an edit mode on WatchOS.
My question is: is the edit functionality in Control Center a custom thing, or is that present in some SwiftUI component that I've missed?
Is remotepairingd part of Xcode? It seems to be stuck using 119% CPU. This may have started when I recently paired my new Apple Watch with Xcode - or maybe that is a coincidence. The console is full of:
error 16:40:26.237601+0000 remotepairingd socket-1: No more data can be received, connection was closed
When my iOS app runs on macOS in "designed for iPad" mode, the system foreground colour RGBA values seem strange.
Looking at [UIColor labelColor], [UIColor secondaryLabelColor] etc. on iOS, I see values like these: (Light Mode)
// R G B A
fg0 = 0 0 0 255
fg1 = 10 10 13 153
fg2 = 10 10 13 76
fg3 = 10 10 13 45
Note in particular that fg0, aka labelColor, is solid black.
When I run it on my Mac, the values I see are:
// R G B A
fg0 = 0 0 0 216
fg1 = 0 0 0 127
fg2 = 0 0 0 66
fg3 = 0 0 0 25
Here, fg0 has alpha = 216.
The result is that it looks like a dark grey, on a white background.
Of course it's reasonable for macOS to have a different colour palette than iOS - but native macOS apps seem to have solid 100% black as their foreground colour.
Do others see this? What should I be doing?
Note that I'm getting colour values using UIColor's getRed: blue: green: alpha: method and then using these colour values for some custom GPU drawing. Previously I was using solid black and white, but at some point I updated it to use UIColor in order to respond to light/dark-mode changes.
I have a simple SwiftUI Text:
Text(t) .font(Font.system(size: 9))
Strangely its ideal height seems to be larger when it is empty.
I initially observed this in a custom Layout container that wasn't working quite right. Eventually I looked at the height returned by v.dimensions(in:), and found that when t is non-empty the height is 11; when empty, it's 14.
Subsequently I observed similar behaviour in a regular VStack container.
Has anyone seen anything similar? Are there any properties that could affect this behaviour?
(This is on a watch - I don't know if that matters.)
How do I draw a single line of text in a SwiftUI Canvas, scaled to fill a given rectangle?
Example:
Canvas { context, size in
let r = CGRect(origin: CGPointZero, size: size); // Whole canvas
let t = Text("Hello World");
context.draw(t, in: r);
}
Outside of Canvas I'd add .minimumScaleFactor(0) .lineLimit(1), and I guess set a large default font size, and I'd get the result I want.
But inside Canvas, .minimumScaleFactor and .lineLimit don't seem to be available; they return some View, not Text, which can't be used in context.draw. (Is there a trick to make that work?)
I have written the following to do this, but I think there must be an easier way to achieve this! Suggestions?
extension GraphicsContext {
mutating func draw_text_in_rect(string: String, rect: CGRect)
{
let text = Text(string) .font(.system(size: 25));
// The font size used here does matter, because e.g. letter spacing
// varies with the font size.
let resolved = resolve(text);
let text_size = resolved.measure(in: CGSize(width: CGFloat.infinity, height: CGFloat.infinity));
let text_aspect = text_size.width / text_size.height;
let fit_size = CGSize(width: min(rect.size.width, rect.size.height*text_aspect),
height: min(rect.size.height, rect.size.width/text_aspect));
let fit_rect = CGRect(x: rect.origin.x + (rect.size.width-fit_size.width)/2,
y: rect.origin.y + (rect.size.height-fit_size.height)/2,
width: fit_size.width,
height: fit_size.height);
let scale = fit_size.width / text_size.width;
// For debug:
// var p = Path();
// p.addRect(fit_rect);
// stroke(p, with: GraphicsContext.Shading.color(.red), lineWidth: 1);
translateBy(x: fit_rect.minX, y: fit_rect.minY);
scaleBy(x:scale, y:scale);
draw(resolved, at: CGPointZero, anchor: UnitPoint.topLeading);
transform = CGAffineTransformIdentity;
}
};