On 11/12/2020 8:32 PM, matthias rebbe via use-livecode wrote:
Are you using the xml library for that?
Anyway, would you like to share your handler?

Yes, and yes (below). tDocTypes contains a cr delimited list of addition document types to add to the pList file. Also, the old use of uniEncode/uniDecode should be replaced with textEncode. This is code is working with LC9.6.1

    -- updating the generated plist file
    put tMac64BuildFolder&tAppName&".app/Contents/Info.plist" into tSrcFile -- overwrite original
    --
    if there is a file tSrcFile then
      put revXMLCreateTreeFromFile(tSrcFile,true,true,false) into tTreeID
      if tTreeID begins with "xmlerr" then
        answer error "<p>Error reading XML plist file for updating document types during build.</p><p>"&tTreeID&"</p>"
      else
        -- list of document types <name>,<icon file><extension>,<type code><cr>         put "HyperTRANSCRIBE Files,StandaloneDoc.icns,ht2,HTh2"&cr into tDocTypes
        -- XML template
        put "<dict>"&cr&"<key>CFBundleTypeExtensions</key>"&cr&"<array>"&cr&"<string>[[tExtension]]</string>"&cr&"</array>"&cr into tXMLTemplate         put "<key>CFBundleTypeIconFile</key>"&cr&"<string>[[tIconFile]]</string>"&cr&"<key>CFBundleTypeName</key>"&cr after tXMLTemplate         put "<string>[[tDocName]]</string>"&cr&"<key>CFBundleTypeOSTypes</key>"&cr&"<array>"&cr&"<string>[[tTypeCode]]</string>"&cr after tXMLTemplate         put "</array>"&cr&"<key>CFBundleTypeRole</key>"&cr&"<string>Editor</string>"&cr&"</dict>"&cr after tXMLTemplate
        -- add document types under parent <plist><dict><array> at end
        repeat for each line tDocType in tDocTypes
          put item 1 of tDocType into tDocName
          put item 2 of tDocType into tIconFile
          put item 3 of tDocType into tExtension
          put item 4 of tDocType into tTypeCode
          put merge(tXMLTemplate) into tNodeContents
          revXMLAppend tTreeID, "/plist/dict/array",tNodeContents
        end repeat
        -- output updated plist
        get empty -- clear 'it' for any possible error from revXMLText that places the error in 'it'
        put revXMLText(tTreeID,,true) into tXMLText
        if it is not empty then
          answer error "<p>Error writing updated XML plist file.</p><p>"&it&"</p>"
        end if
        put uniDecode(uniEncode(tXMLText),"UTF8") into URL ("file:"&tSrcFile)
      end if
    end if


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to