How to check for errors in a `.plist` file
Asked Answered
Y

1

7

I haven't been able to figue out why launchctl is saying this .plist is invalid.

I'm trying to run a Python script once a day at 8AM. the first program argument is the path to the pyenv virtualenv binary, the second is to my Python script.

Is there a method of verifying what I have gotten right or wrong in this .plist file? launchctl is not obvious with the errors it returns, it's just:

Invalid Property List.

I'm aware there are tools out there that can create and manage these jobs, but I wanted to better understand what's going on under the hood.

This is my .plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.conall.autowallpaper</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/conall/.pyenv/versions/3.6.2/envs/auto_wallpaper-3.6.2/bin/python</string>
        <string>/Users/conall/python/projects/auto_wallpaper/auto_wallpaper.py</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <Key>Minute</Key>
        <integer>0</integer>
        <key>Hour</key>
        <integer>8</integer>
    </dict>
</dict>
</plist>
Yingyingkow answered 5/11, 2017 at 17:13 Comment(0)
E
19

Yes, you can use the plutil command to check the syntax of property list files.

In your case:

$ plutil test.plist 
test.plist: Encountered unknown tag Key on line 14

That means your Key tag should be lowercase, so it should be key.

Estivate answered 11/1, 2018 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.