Scripting 通过apple脚本为info.plist中的URLTypes设置值

Scripting 通过apple脚本为info.plist中的URLTypes设置值,scripting,applescript,Scripting,Applescript,我想在info.plist文件中为如下URL类型设置值 <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.test.testLaunch</string> </dict> <dict> <key>CFBundleURLSchemes</key>

我想在info.plist文件中为如下URL类型设置值

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.test.testLaunch</string>
</dict>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>LaunchApp1</string>
<string>LaunchApp2</string>
</array>
</dict>
</array>

我应该如何设置CbundleUrlTypes键的所有值,并设置dictionary和array的嵌套值。

applescript等价物是array=list和dictionary=record,所以只需创建一个记录列表。一条记录的值为字符串,另一条记录的值为字符串数组。注意:我还没有测试过这个,但值得一试

set myArray to {{CFBundleURLName:"com.test.testLaunch"}, {CFBundleURLSchemes:{"LaunchApp1", "LaunchApp2"}}}
tell application "System Events"
    set plistFile to property list file "some:path"
    tell plistFile
        tell contents
            set value of property list item "CFBundleURLTypes" to myArray
        end tell
    end tell
end tell
set myArray to {{CFBundleURLName:"com.test.testLaunch"}, {CFBundleURLSchemes:{"LaunchApp1", "LaunchApp2"}}}
tell application "System Events"
    set plistFile to property list file "some:path"
    tell plistFile
        tell contents
            set value of property list item "CFBundleURLTypes" to myArray
        end tell
    end tell
end tell