Thank you for the response, Leo! The problem was me being silly. When I thought I had added the com.apple.security.personal-information.photos-library entitlement, I was wrong. I added it to the wrong place. 🤦♂️
Post
Replies
Boosts
Views
Activity
Yes, I have both NSPhotoLibraryAddUsageDescription and NSPhotoLibraryUsageDescription in my Info.plist:
<key>NSPhotoLibraryAddUsageDescription</key>
<string>photo library additions</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photo library usage</string>
I figured out my problem. I had configured the app extension with a different prefix from the main app. The main app has my Team ID as the prefix. Somehow I configured the extension to have some other prefix for its bundle identifier. I fixed it by creating a new App ID for the extension.
Thank you for the reply, Quinn.
John
After I was still seeing the behavior when just creating an App Delegate, Scene Delegate, and View Controller that did just about nothing else, I deleted all other code in the app. I could then see the problem was gone. I then put a breakpoint in every method with a dispatch_once_t call. That led me to where my code was being called that I did not expect.
I hope this is somehow helpful, @SeanMcMains!
John
The crash report said the reason was running out of memory. The app's memory usage would climb by roughly 30MB/second until the app crashed.
I since figured out the source of the problem. I had an Objective-C extension on UIColor that implemented secondaryLabelColor. I do not know why that had the effect it did on share sheets, but removing that extension method fixed it.
Thank you for replying!
John
I tracked my issue down to CSS opacity values that were below 1.0 (but much higher than 0.0. I reported this as FB9652283. It sounds like the issue you are encountering is different, though.
FYI, I got this helpful response to my FB, and it worked for me. I hope it helps you as well:
You can’t use CTFontRegisterGraphicsFont() created from a CGDataProvider for widgets. Instead you can use CTFontManagerRegisterFontsForURL() and it is much simpler than the code you attached: let bundle = Bundle(for: MyFonts.self)
let url = bundle.url(forResource: "miso-light", withExtension: "otf")!
var error: Unmanaged<CFError>?
if !CTFontManagerRegisterFontsForURL(url as CFURL, .process, &error) {
print("unable to register font: \(error!.takeUnretainedValue())")
} else {
print("registered!")
}
I ended up with a static method that reads a JSON file and returns it as a struct. That method caches the previous result in memory, and uses that result again if the JSON file is unchanged.
The JSON file is generated by my app. It contains a small subset of the data from my app's sqlite database, primarily because I wanted to avoid 0xdead10cc crashes.
I am seeing the same. FB8642825.
@Jasonloewy This info helped me a great deal. Thank you.
I am seeing the same problem that Mr. Brightside reports. I did adopt the TimelineProvider changes noted in the other thread. I filed FB8135225 with a sample project and sysdiagnose.
Confirmed - beta 3 fixed this. Thank you!
I am encountering this as well. I filed FB8060728 with a sample project demonstrating the issue. I also attached sysdiagnose info.
It looks to me like this issue makes using custom fonts infeasible, so I hope it can be addressed. Thank you.
John
Thank you. I wonder if you can help me understand what I am doing wrong. I created a small sample project with this code shared between the app and the extension:
class SharedFont {
static let fontName = "Miso-Bold"
static func registerFont() {
guard let url = Bundle.main.url(forResource: "miso-bold", withExtension: "otf") else {
print("could not find font file")
return
}
print("registering font at \(url.absoluteString)")
guard let fontDataProvider = CGDataProvider(url: url as CFURL) else {
print("Could not create font data provider for \(url).")
return
}
guard let font = CGFont(fontDataProvider) else {
print("could not create font")
return
}
var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
print(error!.takeUnretainedValue())
}
}
}
If I call SharedFont.registerFont() in my AppDelegate didFinishLaunchingWithOptions method, the font is available to the app.
The font is in both the app target and in the widget target.
Either that same method does not work in a Widget extension, or perhaps I am putting it in the wrong place. I tried calling this in my TimelineProvider’s snapshot(…) function and in its timeline(…) function. The font does work in the extension or in the SwiftUI previews of the view in the extension. Is there a better place in a Widget extension to put this type of one-time initialization code that might let it work?