Post

Replies

Boosts

Views

Activity

Reply to Access file from File app works inside my application, but doesn't work if I launch my app from the File app
Ok, a few things here... First of all, to be able to open directly files from the File app, I had to add to the info.plist UISupportsDocumentBrowser YES. When running from the simulator, all files were passed to my application though func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { ... } but as soon as I added the UISupportsDocumentBrowser YES. now I fell back to the regular way of launching an app from a file which is func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { ... // a file was passed through its url if let url = connectionOptions.urlContexts.first?.url { // do whatever you need to do with this file, but use startAccessingSecurityScopedResource() } } Now it works. I hope it will help others :-)
Jan ’24
Reply to dispatch_once weird behavior
Ok, so as expected @eskimo, I have 2 dispatch_once_t, though I cannot figure out why. The first memory graph (the one from inside the app itself) seems very small IMO, at least compared to the other which have a lot of objects in memory. Maybe it's a lead ? First call (shared inside the app): Second call (shared inside the framework2):
Sep ’23
Reply to dispatch_once weird behavior
@eskimo I just made a small sample project (1 objC framework with dispatch_once, 1 swift framework calling the #1 and an app including both and calling both) : it behaves as expected (dispatch_once is only called once). So it musts come from our project. We use, through a bridging header, some internal objC classes (non public) to do some work. Do you think that using some non public objects can lead to such a behavior (since Xcode would not find the Classes inside the framework, it loads a copy of the development local files, hence loading 2 copies of the framework in memory ? Thanks
Sep ’23
Reply to Dynamic typealiases on enum
Thanks @Polyphonic, but I guess it requires a little bit more of context. I can't say too much for NDA reasons, but I'll try to make an analogy ;-) Let's say I have a Video framework that allows me to create video objects. Theses videos can be of certain type (Local, Youtube, Streamed). Each Video is not related (that's my first issue, but since I have to use this framework, I have no other way to tackle this). Add on top that this framework is an objC one 😬 Now let's say that I'm building a framework that allows me to load the various Video objects, and I want to leverage as much of Swift capabilities. To do so, I started by creating an enum VideoType that "mirrors" the separated objC objects. So I have this enum VideoType { case local, youtube, streamed } Now, I create VideoManager objects that relies on a protocol that allows me to load and show a video. But, I want this objects to handle the underlying objC Video Objects. To do so, I used an associatedType protocol VideoManager { associatedtype Video func load() func show() var video: Video { get set } } Now I create dedicated objects that implement the behind-the-scene logic with the proper Video objects, one for each enum value. Here's one for the sake of it struct YoutubeVideoManager: VideoManager { typealias Video = YoutubeVideo func load() {} func show() {} var video: Video { ... } } Now, here is the part where it fails. I'd like to create a factory like object that would return the actual VideoManager depending on the enum struct VideoFactory { func videoManager(for videoType: VideoType) -> VideoManager {} } But in this example, it returns a VideoManager, not an actual implementation. I'd like that when I call videoManager(for: .youtube), it returns with a typesafe check a YoutubeVideoManager and if I try to call it like let _: LocalVideoManager = factory.videoManager(for: .youtube, then I get an error from compilation. So far, the only thing I managed to do is to add a generic to the enum enum VideoType<T: VideoManager> and check at runtime that T is of type YoutubeVideoManager for the .youtube value, otherwise I throw an error. But it's a runtime check AND I have to declare my variables like this let _: = .factory.videoManager(for: VideoType<YoutubeVideoManager>.youtubewhich is pretty ugly I agree πŸ˜… I hope I gave you enough context. I'm pretty sure it's not actually doable, but maybe I'm so stuck on that "dynamic typealias" that there is another solution more obvious that I don't see! Thanks @Polyphonic
Jul ’23
Reply to SwiftUI and Clean Architecture
Still have to figure out why, but I found a solution. If I wrap my photos in an ObservableObject as a Published var, and use @ObservedObject in my View, then it gets updated. I just don't get why to have to add an additional layer and why the @State if not enough :-/
Mar ’23
Reply to [NSBundle mainBundle] returns same path as [NSBundle bundleForClass: [self class]] in framework
FYI, I also tried to create a bundle inside the framework, the issue is still the same : the bundle is visible in the derived data framework's folder, but the path inside the app is wrong. I also tried a couple of things : If I choose "embeed" (the signing part is not relevant), I can access the framework inside the privateFrameworkPath of the Bundle.main, but it's not a solution per se as we distribute our framework through cocoapod and frameworks are not embeeded I tried to generate a standalone xcframework and use it in a project (to check the workspace guess) : the issue is the same. If I print the [[NSBundle bundleForClass: [self class]] bundlePath], I get the same path as the main bundle's path :-/
Oct ’22