Problem reading .plist file inside app package

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3728
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Problem reading .plist file inside app package

Post by richmond62 » Sun Nov 03, 2019 10:49 pm

Well, I'm sorry if you think I'm being snide. Far from it.

I was extremely impressed and pleasantly surprised that your stack did what you had intended it to do on my Macintosh.

I only wish I could work out why it is not working on your machine.

Err . . . are you running MacOS 10.15 Catalina? If so, I wonder if that has something to do with the matter.
When someone comes to a forum asking for help
When I ask for help on this forum I often get responses that I could interpret as sarcastic, condescending or snide if I chose to:
but I like to think that anyone who responds to any of my cries for help is offering something helpful in good faith; even if in my case,
quite a few of them are probably splitting their pants laughing at some of the extremely goofy mistakes I tend to make.

Relax, friend. :D

coyoteconscious
Posts: 9
Joined: Sun Nov 03, 2019 6:30 pm

Re: Problem reading .plist file inside app package

Post by coyoteconscious » Sun Nov 03, 2019 10:54 pm

I also tried:
put URL("binfile:" & tFile) into tFileContents
put textDecode ( tFileContents , "UTF-8" ) into field "plist"

Did not work. Either the file is not really utf8, or that isn't the right way to do it.

coyoteconscious
Posts: 9
Joined: Sun Nov 03, 2019 6:30 pm

Re: Problem reading .plist file inside app package

Post by coyoteconscious » Sun Nov 03, 2019 11:07 pm

I said you were coming across to me as snide. I have no idea of knowing whether or not you are, but the way you phrased your responses came across that way, even when I tried to read it charitably. I said what I did to either let you know you might unintentionally have come across that way, so you would know, or so that you'd know that if you were attempting to be mean, it isn't acceptable.

I am glad to know you were not trying to be mean, and I apologize if I took it the wrong way when you were trying to help.

And no, I have not yet updated to Catalina - I prefer to wait until everyone is finished crying after a new release before I install it on my work machines. ; )

Telling people to relax when you may have caused them offense is considered rude by most people, by the way. I would refrain, if you are attempting to actually de-escalate a situation. It comes across as disrespectful of someone's emotions. If you don't believe me, go spill a beer on someone in a sports bar, then tell them to relax, and see what comes of it. Even if you spilled it accidentally, if you tell them to relax when they are annoyed, they probably will do the opposite. ; )

But that's not a programming problem (although developers, programmers, and engineers have a stereotype that we lack social skills).

Anyway, yeah, it's a mystery. I'm torn between doggedly attempting to solve it until it's right, in case it helps others, or just grabbing the first icns file I see in {application package}/Contents/Resources and maybe giving a choice if there are multiple ones. ; ) I'm just tinkering really. Got curious how complicated it would be to come up with a limited Dragthing clone in Livecode, since Dragthing won't work from Catalina onward, and the dev does not plan to update any longer.

Most of the features I actually use are pretty straightforward, except getting the ding-dong icons.

Even if one _gets_ the plist file read without gibberish in it, it really only solves the problem for simpler icon implementations anyway, since some apps store the information about their icons in more complex ways, through things like shared bundle entries (MS Office, etc. for instance).

As for reading the icons themselves, I'm pretty sure I've seen examples of how to do that lurking around.
richmond62 wrote:
Sun Nov 03, 2019 10:49 pm
Well, I'm sorry if you think I'm being snide. Far from it.

I was extremely impressed and pleasantly surprised that your stack did what you had intended it to do on my Macintosh.

I only wish I could work out why it is not working on your machine.

Err . . . are you running MacOS 10.15 Catalina? If so, I wonder if that has something to do with the matter.
When someone comes to a forum asking for help
When I ask for help on this forum I often get responses that I could interpret as sarcastic, condescending or snide if I chose to:
but I like to think that anyone who responds to any of my cries for help is offering something helpful in good faith; even if in my case,
quite a few of them are probably splitting their pants laughing at some of the extremely goofy mistakes I tend to make.

Relax, friend. :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3728
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Problem reading .plist file inside app package

Post by richmond62 » Sun Nov 03, 2019 11:11 pm

Err . . . klaus

Klaus
Posts: 11276
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Problem reading .plist file inside app package

Post by Klaus » Mon Nov 04, 2019 12:26 am

Err... Richmond?

@ coyoteconscious
Maybe this might help with the icon files?

Code: Select all

on mouseUp 
  ## I created a new button in your example stack
   put fld "filename" & "/Contents/Resources/" into tFolder
   put files(tFolder) into tFiles
   filter tFiles with "*.icns"
   put tFiles
end mouseUp
Et voila, all ICON files listed nicely, if that is what you are after :D

Best

Klaus

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2166
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Problem reading .plist file inside app package

Post by [-hh] » Mon Nov 04, 2019 12:28 am

@coyoteconscious.
Obviously there are problems with the binary format of the plist.

You could try the following variants (for example for Safari):

Code: Select all

  put "/Applications/Safari.app/Contents/Info.plist" into fn
  -- variant 1
  put url ("binfile:"&fn) into fld 1
  -- variant 2
  put shell("plutil -p '" & fn & "'") into fld 1
Both variants work here (MacOS 10.15.1 and LC 9.0.5/9.5.0).
[plutil can do a lot of fine things, just go to terminal and type "man plutil"]

It's usually the CFBundleIconFile you have to get, here it is "compass".
And here is the script to import the icon as png into your stack (for example for Safari):

Code: Select all

on mouseUp
  lock screen; lock messages
  put "/Applications/Safari.app/Contents/Resources/compass.icns" into fIN
  put the temporary folder & "/temp.png" into fOUT
  put shell ("sips -s format png '"&fIN&"' -o " &fOUT) into fld 1
  put "Safari" into sf
  if there is no img sf then create img sf
  set resizeQuality of img sf to "good"
  set text of img sf to url("binfile:"&fOUT)
  -- resize to width 64 -- for example
  put the formattedWidth of img sf into fw
  put the formattedHeight of img sf into fh
  set width of img sf to 64
  set height of img sf to 64*fh/fw
  -- make size permanent
  set alphaData of img sf to the alphaData of img sf
  set imageData of img sf to the imageData of img sf
end mouseUp
A simple "manual" way to import an application icon (for example of Safari):
  • Open the getInfo box from Finder for Safari (cmd-I or rightClick>Get Info).
  • Click at the topleft icon to select it and copy.
  • Open Preview and type cmd-N.
  • Select one of the displayed icons, copy it and then paste to LC.
shiftLock happens

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3728
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Problem reading .plist file inside app package

Post by richmond62 » Mon Nov 04, 2019 8:32 am

Err... Richmond?
Because I wish to bow to the chap who knows more in this area than I do; and can help without, apparently,
ruffling feathers.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 664
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Problem reading .plist file inside app package

Post by Thierry » Mon Nov 04, 2019 11:31 am

@hermann

It looks like on Mojave,
your sips parameters are not working; at least on my Mac.

So, here is my attempt on this and tested.

As we are using an external app, I let it to resize the image too.

Code: Select all

   -- put "/Applications/Safari.app/Contents/Resources/compass.icns" into fIN
   put "/Applications/TextEdit.app/Contents/Resources/rtf.icns" into fIN
   put "/Users/..../Desktop/tmp.png" into fOUT
   get format( "sips -s format png -z %d %d '%s' --out '%s'", 64, 64,fIN,fOUT)
   put shell( IT) &cr after fld 1
   set resizeQuality of img "LCimage" to "good"
   set text of img "LCimage" to url("binfile:" & fOUT)

Enjoy,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Post Reply

Return to “Mac OS”