Reading key values in info.plist file iOS or Mac using XML library?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
Hi,

does anyone know if it is possible to use the xml library to read values from an info.plist file?


Regards,

Matthias


-
Matthias Rebbe
Life Is Too Short For Boring Code


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
It is certainly possible! But depending on the complexity of the xml document it may not be easy. I’ve posted before that I attempted to work with an exported XML document from a Toshiba Copier’s Templates (scan presets), but the document was mindbogglingly complex. One issue I ran into is keys which have the same name, so trying to convert the xml to an array failed just on that score. Without knowing what the structure of the XML is supposed to be, a data dictionary for the XML document as it were, I may as well be reading the output of Data’s positronic interface.

Bob S


> On Nov 12, 2020, at 4:30 PM, matthias rebbe via use-livecode <[hidden email]> wrote:
>
> Hi,
>
> does anyone know if it is possible to use the xml library to read values from an info.plist file?
>
>
> Regards,
>
> Matthias
>
>
> -
> Matthias Rebbe
> Life Is Too Short For Boring Code
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 13.11.2020 um 01:43 schrieb Bob Sneidar via use-livecode <[hidden email]>:
>
> It is certainly possible! But depending on the complexity of the xml document it may not be easy. I’ve posted before that I attempted to work with an exported XML document from a Toshiba Copier’s Templates (scan presets), but the document was mindbogglingly complex. One issue I ran into is keys which have the same name, so trying to convert the xml to an array failed just on that score. Without knowing what the structure of the XML is supposed to be, a data dictionary for the XML document as it were, I may as well be reading the output of Data’s positronic interface.
>

the .plist file contains several entry with same names (string and key)

e.g.
<dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleDisplayName</key>
        <string>mOTP</string>
        <key>CFBundleName</key>
        <string>mOTP</string>


So it seems that is  then not possible to use the xml library. Anyway i will read the values using line offset
put line lineoffset("<key>CFBundleDisplayName</key>",tPlist)+1 into ....

which then "returns" the string value of CFBundleDisplayName one line below. This will work as long as the line with the <string>....</string> value is directly after the line with the <key>.. values.


Thanks.






> Bob S
>
>
>> On Nov 12, 2020, at 4:30 PM, matthias rebbe via use-livecode <[hidden email]> wrote:
>>
>> Hi,
>>
>> does anyone know if it is possible to use the xml library to read values from an info.plist file?
>>
>>
>> Regards,
>>
>> Matthias
>>
>>
>> -
>> Matthias Rebbe
>> Life Is Too Short For Boring Code
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
I have an on standaloneSaved handler that reads and writes an updated
info.plist for my standalone that adds additional document types since
the standalone builder only allows a single document type.

On 11/12/2020 7:30 PM, matthias rebbe via use-livecode wrote:

> Hi,
>
> does anyone know if it is possible to use the xml library to read values from an info.plist file?
>
>
> Regards,
>
> Matthias
>
>
> -
> Matthias Rebbe
> Life Is Too Short For Boring Code
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
Are you using the xml library for that?
Anyway, would you like to share your handler?

Matthias

-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 13.11.2020 um 02:29 schrieb Paul Dupuis via use-livecode <[hidden email]>:
>
> I have an on standaloneSaved handler that reads and writes an updated info.plist for my standalone that adds additional document types since the standalone builder only allows a single document type.
>
> On 11/12/2020 7:30 PM, matthias rebbe via use-livecode wrote:
>> Hi,
>>
>> does anyone know if it is possible to use the xml library to read values from an info.plist file?
>>
>>
>> Regards,
>>
>> Matthias
>>
>>
>> -
>> Matthias Rebbe
>> Life Is Too Short For Boring Code
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Reading key values in info.plist file iOS or Mac using XML library?

J. Landman Gay via use-livecode
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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode