What does MacOS actually do when open a file? Background of this question:

I built an application by LabVIEW to open .tdms file, and I know it can receive arguments that pass to it because following code works just fine:

open -a /Application/My.app --args /path/to/file.tdms


Since command line works, I decided to associate .tdms to my application so that I can double click the file to open it, and I succeed by modifying My.app/Contents/info.plist. 

And things get interesting, when I try to open file either by double-click or choose app in "Open With..." list, a pop-up window shows 


  "My.app" is damaged and can’t be opened. You should move it to the Trash.


Some suggested xattr -cr /Application/My.app would solve the problem, but it doesn't work for me.

That's why I want to know what does macOS actually do in the background when open file? How does the arguments pass to application?



Additional info:


I use "Open Application Reference" and Property Node in LabVIEW to receive arguments that pass to my application.
I added following code into info.plist to associate filetype to my app:


    &lt;key&gt;CFBundleDocumentTypes&lt;/key&gt;
    &lt;array&gt;
        &lt;dict&gt;
            &lt;key&gt;CFBundleTypeExtensions&lt;/key&gt;
            &lt;array&gt;
                &lt;string&gt;tdms&lt;/string&gt;
            &lt;/array&gt;
            &lt;key&gt;CFBundleTypeRole&lt;/key&gt;
            &lt;string&gt;Viewer&lt;/string&gt;
            &lt;key&gt;CFBundleTypeName&lt;/key&gt;
            &lt;string&gt;National Instruments TDMS File&lt;/string&gt;
            &lt;key&gt;CFBundleTypeIconFile&lt;/key&gt;
            &lt;string&gt;icon.icns&lt;/string&gt;
        &lt;/dict&gt;
    &lt;/array&gt;
LaunchServices

macOS includes Launch Services. This code is responsible for launching applications and providing those applications with the details of files to open or print:


  Launch Services is an API that enables a running application to open other applications or their document files or URLs (uniform resource locators) in a way similar to the Finder or the Dock. Using Launch Services, an application can perform such tasks as:
  
  
  Open (launch or activate) another application
  Open a document or a URL in another application
  Identify the preferred application for opening a given document or URL
  Register information about the kinds of document files and URLs an application is capable of opening
  Obtain appropriate information for displaying a file or URL on the screen, such as its icon, display name, and kind string
  Maintain and update the contents of the Recent Items menu
  


AEOpenDocuments

To open files, graphical applications on macOS are sent AppleEvents of type odoc:


  Event that provides an application with a list of documents to open. Sent, for example, when a selects one or more documents for your application in the Finder and double-clicks them.


The launched application's arguments do not include the paths of the files to open.