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 :-)
Post
Replies
Boosts
Views
Activity
Same Behaviour here π
Ok so the crash comes indeed from the phaseAnimator still running even if the view is dismissed, like if there was some kind of retain cycle.
Any idea how to fix that ?
Thanks
Now that iOS17 is out, it's not beta anymore <3 Any help would be appreciated! Thanks
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):
@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
FYI, here are the imported framework. You can see that they are imported as local frameworks inside the workspace
Unfortunately @eskimo it is not. I printed the memory addresses of the static instance iVar, and I get 2 different addresses, one for each time I enter the dispatch_once (called from framework #1 then #2). After that, I never enter the dispatch_once again :-/
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
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 :-/
Don't bother, I'm an *****, it's just URLSession instead of URLSession.shared :D
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 :-/