1 Reply
      Latest reply on Nov 21, 2019 1:38 AM by eskimo
      gate61 Level 1 Level 1 (0 points)

        I have an main app (macOS) with bundle id com.mycompany.myapp which stores information in 'Application Data/com.mycompany.myapp'.

        I have a screen saver, with the same bundle id com.mycompany.myapp, which load an html file from 'Application Data/com.mycompany.myapp'.

         

        This works fine in Mojave, not anymore in Catalina.

         

        Is there a way to share files between the main macOS app and the screensaver ?

         

        Any help would be appreciated.

        • Re: screen saver shared application data
          eskimo Apple Staff Apple Staff (12,455 points)

          First up, don’t ship an app and a screen saver with the same bundle ID.  The bundle ID is meant to uniquely identify your code [1], and using it for two different things is generally a bad idea.

          Second, you wrote:

          I have a screen saver … which load an html file from Application Data/com.mycompany.myapp.

          How does it load that HTML file?  In a web view?  If so, I recommend that you start this investigation by cutting the web view out of the equation.  Web views, and especially the modern WKWebView, are a tricky prospect with regards file system access.

          Instead, use a normal file system API (for example, dataWithContentsOfURL:options:error:) and see if that’s able to access this shared file.  When doing that, consider the following;

          • Make sure the URL is the same in both cases.  It’s possible that you might be getting different URLs in different contexts.

          • If it fails, it should return an error.  What is that error?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

          [1] Indeed, the bundle ID becomes your code signing identifier (unless you explicitly override that) and that value, along with your Team ID, is what the OS uses to actually identify your code.