locked
Can't access ProviderIdentifier in NSFileProviderExtension RRS feed

  • Question

  • User35208 posted

    This seems like a bug but wanted to check with folks here before submitting a bug. I saw a bug submitted for something very similar that said it was related to the bindings.

    This fails in the out of the box template BTW.

    In an NSFileProviderExtension you need to create a FileCoordinator. To do that you need the ProviderIdentifer.

    However, the NSFileProviderExtension code does not run on the UI thread.

    I get this error: "UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread."

    stack trace is this: at UIKit.UIApplication.EnsureUIThread () [0x00023] in /Users/builder/data/lanes/3985/35d1ccd0/source/xamarin-macios/src/UIKit/UIApplication.cs:88 at UIKit.NSFileProviderExtension.get_ProviderIdentifier () [0x00000] in /Users/builder/data/lanes/3985/35d1ccd0/source/xamarin-macios/src/build/ios/native/UIKit/NSFileProviderExtension.g.cs:263 at FileProvider.FileProvider.CreateDocumentDirectory () [0x00013] in /ProjectLocation/FileProvider/FileProvider.cs:28 at FileProvider.FileProvider.StartProvidingItemAtUrl (Foundation.NSUrl url, System.Action`1[T] completionHandler) [0x00008] in /ProjectLocation/FileProvider/FileProvider.cs:77

    Friday, March 3, 2017 1:36 PM

All replies

  • User125801 posted

    Hi Ted, could you send me a sample project for this? If you don't want it public, then please PM me. Thanks!

    Friday, March 3, 2017 2:00 PM
  • User35208 posted

    @BytesGuy I would have to create a completely new project as I cannot send you my clients codebase. If you need me to create a new project I guess I can, it will just take a little bit.

    As you know it is a lot of provisioning etc. to create a new project for extensions.

    Friday, March 3, 2017 2:03 PM
  • User35208 posted

    @BytesGuy working on sample now.

    Friday, March 3, 2017 2:07 PM
  • User35208 posted

    @BytesGuy Just sent you a PM with a project attached.

    Let me know if you have any further questions or issues with the project.

    Friday, March 3, 2017 3:04 PM
  • User35208 posted

    @BytesGuy Just wondering whether you have had a chance to check out the project I sent and whether I should enter a bug for this issue?

    Monday, March 6, 2017 1:22 PM
  • User125801 posted

    Just sent you a PM. It does look like a bug, so if you could file one on bugzilla that would be great!

    The workarounds for the moment are to run the offending code on the main thread ( InvokeOnMainThread (() => /* code that must run on main thread */); ) or you can set CheckForIllegalCrossThreadCalls temporarily https://developer.xamarin.com/api/field/UIKit.UIApplication.CheckForIllegalCrossThreadCalls/

    Monday, March 6, 2017 2:19 PM
  • User35208 posted

    @BytesGuy Since the ProviderIdentifier is the same of the file provider bundle id, I am just using that for now. I will file a bug.

    https://bugzilla.xamarin.com/show_bug.cgi?id=53075

    Monday, March 6, 2017 2:22 PM