Post

Replies

Boosts

Views

Activity

Reply to I need a dynamic list of widgets in my WidgetBundle for iPadOS 15
I've tried various possible solutions and none worked out. The WidgetBundleBuilder ResultBuilder lacks some implementation details which prevent the usage of if #available and single if statements, viz: buildOptional buildLimitedAvailability I tried writing an extension for WidgetBundleBuilder with the above two methods but I'm not sure what the implementation would look like. The following makes things work but it may be unreliable. extension WidgetBundleBuilder {        public static func buildOptional<C0>(_ component: C0?) -> some Widget where C0:Widget {         return component ?? SomeWidget() as! C0     }     public static func buildLimitedAvailability<C0>(_ component: C0) -> some Widget where C0:Widget {         return component     } }
Topic: App & System Services SubTopic: General Tags:
Jul ’21
Reply to Can't access objective-c method from Swift.
For anyone still stuck in a similar situation, I was able to reproduce the scenario. objc (instancetype)initWithInitialFilter:(nullable ArticleFilter *)filter channelProvider:(id)channelProvider offlineContentManager:(OfflineContentManager *)offlineContentManager; The OP mentions the following: The objc-c header in question is listed my bridging header (all are listed) In such an instance, all classes viz. ArticleFilter, OfflineContentManager also need to be in the bridging header. Assume that ArticleFilter is implemented in Swift. In such a case, the method would not show up. Importing the "Module-Swift.h" causes a cyclic linking issue so you'd make a class definition in that header using @class ArticleFilter so the method signature continues to make sense. The only way I've gotten it to work without breaking anything is to convert the method to something like: objc (instancetype)initWithInitialFilter:(id)filter channelProvider:(id)channelProvider offlineContentManager:(OfflineContentManager *)offlineContentManager; The method change only needs to happen in the header file. No changes are required in the implementation file. It isn't optimum, makes things confusing sometimes, but it works. I hope we get a better solution in the near future.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21