Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: MISV on September 21, 2020, 12:25:06 pm

Title: Suddenly getting errors about parsing entitlements
Post by: MISV on September 21, 2020, 12:25:06 pm
Been away half an year from my Mac and seems things stopped working :)

So in commandline I call this:

Code: Pascal  [Select][+][-]
  1. codesign --force --options runtime --timestamp --entitlements "/Volumes/DiskW/projects-cool/MyProduct/osx/shrents/casc-dlv.plist" --sign "MyCompany" "/Volumes/DiskW/projects-cool/MyProduct/osx/final_myproduct-dist/mac-myproduct-files/MyProduct.app"
  2.  

I then get this error:
Quote
Failed to parse entitlements: AMFIUnserializeXML: syntax error near line 1

I have validated the XML. Here is what the file contains:
Code: Pascal  [Select][+][-]
  1. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  2. <plist version="1.0">
  3. <dict>
  4.     <key>com.apple.security.cs.disable-library-validation</key>
  5.     <true/>
  6. </dict>
  7. </plist>                
  8.  

Any ideas? No changes otherwise in my system beyond having updated tools.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: trev on September 21, 2020, 01:16:54 pm
This is the first line of the entitlements files I validated successfully:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>

which seems to be missing from your example... it's line 1.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: MISV on September 22, 2020, 02:31:33 am
Thank you. I still get the same error though.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: MISV on September 22, 2020, 02:33:34 am
I think it is broken somehow because no matter what I get that error.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: dsiders on September 22, 2020, 04:48:38 am
This is the first line of the entitlements files I validated successfully:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>

which seems to be missing from your example... it's line 1.

Since it references an external public DTD, it should be:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4.   <dict>
  5.     <key>com.apple.security.cs.disable-library-validation</key>
  6.     <true/>
  7.   </dict>
  8. </plist>                
  9.  


Title: Re: Suddenly getting errors about parsing entitlements
Post by: trev on September 22, 2020, 05:13:21 am
Thank you. I still get the same error though.

Does:

Code: Bash  [Select][+][-]
  1. plutil /Volumes/DiskW/projects-cool/MyProduct/osx/shrents/casc-dlv.plist

display anything useful?

Apple has this to say about a line 1 syntax error:

Quote
After code signing — but before notarizing — you can verify your app or command line tool has a properly formed XML entitlement property list:

% codesign -d --entitlements :- <path to signed .app or command-line tool>

If the output of this command contains the text bplist00, the executable has a binary property list, which the notary service will reject with an error message like:

Embedded entitlements are invalid: syntax error near line 1
Title: Re: Suddenly getting errors about parsing entitlements
Post by: trev on September 22, 2020, 05:16:30 am
Since it references an external public DTD, it should be:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. [...]

I based mine on Apple's own apps eg TextEdit:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5.         <key>com.apple.application-identifier</key>
  6.         <string>com.apple.TextEdit</string>
  7. [..]
  8. </dict>
  9. </plist>
Title: Re: Suddenly getting errors about parsing entitlements
Post by: MISV on September 22, 2020, 10:07:03 pm
Sorry for the trouble. I think it was a file encoring issue.

Using TextEdit instead of Lazarus solved it. (Tried copy paste your guys code into the file using both tools. Works when using TextEdit.)
Title: Re: Suddenly getting errors about parsing entitlements
Post by: trev on September 23, 2020, 02:56:11 am
Ahhhh... maybe a line ending issue? I notice Lazarus defaults to "Unix/Linux" on macOS - see pic.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: MISV on September 23, 2020, 12:32:40 pm
I can try check... but puzzling to me Apple is not able to handle such things....
Title: Re: Suddenly getting errors about parsing entitlements
Post by: trev on September 23, 2020, 01:57:52 pm
Oops - macOS uses LF for eols. Classic MacOS used CR.
Title: Re: Suddenly getting errors about parsing entitlements
Post by: lucamar on September 23, 2020, 04:34:38 pm
Oops - macOS uses LF for eols. Classic MacOS used CR.

Of course. After all MacOS X is, very roughly speaking, a BSD Unix distro ;)
TinyPortal © 2005-2018