Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
沙箱化objective-c应用程序嵌入applescript_Objective C_Applescript_Xcode4.2_Sandbox_Entitlements - Fatal编程技术网

沙箱化objective-c应用程序嵌入applescript

沙箱化objective-c应用程序嵌入applescript,objective-c,applescript,xcode4.2,sandbox,entitlements,Objective C,Applescript,Xcode4.2,Sandbox,Entitlements,我想沙箱一个应用程序,它使用applescript联系safari以获取标签列表。然后我通过NSAppleEventDescriptor在客观c中获取这些数据。 我已经将com.apple.security.temporary-exception.apple-events键与com.apple.safari一起添加到我的权利中。 当我的应用程序没有沙盒时,我没有问题,但当我尝试沙盒它时,我只得到“null”作为数据 applescript列出选项卡并以xml格式返回。 tell applicat

我想沙箱一个应用程序,它使用applescript联系safari以获取标签列表。然后我通过NSAppleEventDescriptor在客观c中获取这些数据。 我已经将com.apple.security.temporary-exception.apple-events键与com.apple.safari一起添加到我的权利中。 当我的应用程序没有沙盒时,我没有问题,但当我尝试沙盒它时,我只得到“null”作为数据

applescript列出选项卡并以xml格式返回。

tell application "Safari"
set listeSite to {{"http://www.deezer.com", "deezer"}}
set resp to "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
repeat with aWindow in windows
repeat with aTab in tabs of aWindow
set URLTab to URL of aTab
repeat with aSite in listeSite          
if URLTab starts with item 1 of aSite then
set oktabURL to URL of aTab
set oktabWindowID to id of aWindow
set resp to resp & "<site><url>" & oktabURL & "</url><windowID>" & oktabWindowID & "</windowID><type>" & item 2 of aSite & "</type></site>"
end if
end repeat
end repeat
end repeat

return resp

end tell
没有沙盒时收到的消息

[Switching to process 6362 thread 0x0]
2011-11-14 13:18:31.127 SongController[6362:407] result == <NSAppleEventDescriptor: 'utxt'("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><site><url>http://www.deezer.com/fr/index.php</url><windowID>4536</windowID><type>deezer</type></site>")>
2011-11-14 13:18:31.128 SongController[6362:407] descriptorType == 'utxt'
2011-11-14 13:18:31.129 SongController[6362:407] value == <?xml version="1.0" encoding="iso-8859-1"?><site><url>http://www.deezer.com/fr/index.php</url><windowID>4536</windowID><type>deezer</type></site>
2011-11-14 13:18:31.130 SongController[6362:407] xml == <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?><site><url>http://www.deezer.com/fr/index.php</url><windowID>4536</windowID><type>deezer</type></site>
权利文件

<?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>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.temporary-exception.apple-events
com.apple.security.temporary-exception.apple-events
</key>
    <array>
        <string>com.apple.systemevents</string>
        <string>com.google.chrome</string>
        <string>com.apple.safari</string>
    </array>
</dict>
</plist>

com.apple.security.app-sandbox
com.apple.security.temporary-exception.apple-events
com.apple.security.temporary-exception.apple-events
com.apple.systemevents
谷歌浏览器
com.apple.safari
我希望我已经提供了你所需要的帮助。
谢谢

据我所知,一旦我修复了您的授权plist中的双倍密钥,您的代码就可以正常工作。

您的密钥com.apple.security.temporary exception.apple events似乎在您的.authorities文件中重复了。或者只是输入错误?Mac应用商店将拒绝com.Apple.systemevents中存在Apple事件例外的应用程序。Chrome和Safari一般都可以,但要视具体情况而定。
[Switching to process 6380 thread 0x0]
2011-11-14 13:20:21.233 SongController[6380:407] result == (null)
2011-11-14 13:20:21.234 SongController[6380:407] descriptorType == ''
2011-11-14 13:20:21.235 SongController[6380:407] value == (null)
2011-11-14 13:20:21.235 SongController[6380:407] *** Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSCell.m:1564
2011-11-14 13:20:21.236 SongController[6380:407] An uncaught exception was raised
2011-11-14 13:20:21.237 SongController[6380:407] Invalid parameter not satisfying: aString != nil
2011-11-14 13:20:21.241 SongController[6380:407] (
    0   CoreFoundation                      0x00007fff8a8bc286 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff9125dd5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8a8bc0ba +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff8b3547d3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
    4   AppKit                              0x00007fff886e1a09 -[NSCell _objectValue:forString:errorDescription:] + 160
    5   AppKit                              0x00007fff886e1963 -[NSCell _objectValue:forString:] + 19
    6   AppKit                              0x00007fff886e18c9 -[NSCell setStringValue:] + 41
    7   AppKit                              0x00007fff887e3084 -[NSControl setStringValue:] + 115
    8   SongController                      0x000000010000142f -[AppController sayHello:] + 495
    9   CoreFoundation                      0x00007fff8a8aba1d -[NSObject performSelector:withObject:] + 61
    10  AppKit                              0x00007fff887ca710 -[NSApplication sendAction:to:from:] + 139
    11  AppKit                              0x00007fff888b7bd7 -[NSMenuItem _corePerformAction] + 399
    12  AppKit                              0x00007fff888b790e -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 125
    13  AppKit                              0x00007fff88b54194 -[NSMenu _internalPerformActionForItemAtIndex:] + 38
    14  AppKit                              0x00007fff889e5ce5 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 138
    15  AppKit                              0x00007fff8883151f NSSLMMenuEventHandler + 339
    16  HIToolbox                           0x00007fff8f4b6308 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1263
    17  HIToolbox                           0x00007fff8f4b5914 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 446
    18  HIToolbox                           0x00007fff8f4cc6c7 SendEventToEventTarget + 76
    19  HIToolbox                           0x00007fff8f5129f5 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 398
    20  HIToolbox                           0x00007fff8f5f9645 SendMenuCommandWithContextAndModifiers + 56
    21  HIToolbox                           0x00007fff8f63fef9 SendMenuItemSelectedEvent + 253
    22  HIToolbox                           0x00007fff8f50bb07 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 101
    23  HIToolbox                           0x00007fff8f638909 _ZL19PopUpMenuSelectCoreP8MenuData5PointdS1_tjPK4RecttjS4_S4_PK10__CFStringPP13OpaqueMenuRefPt + 1660
    24  HIToolbox                           0x00007fff8f638bc8 _HandlePopUpMenuSelection7 + 621
    25  AppKit                              0x00007fff889e89b1 _NSSLMPopUpCarbonMenu3 + 3860
    26  AppKit                              0x00007fff88d911ba _NSPopUpCarbonMenu3 + 39
    27  AppKit                              0x00007fff889e6b16 -[NSCarbonMenuImpl popUpMenu:atLocation:width:forView:withSelectedItem:withFont:withFlags:withOptions:] + 322
    28  AppKit                              0x00007fff88c45b3e +[NSStatusBarButtonCell popupStatusBarMenu:inRect:ofView:withEvent:] + 673
    29  AppKit                              0x00007fff88c45de9 -[NSStatusBarButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 147
    30  AppKit                              0x00007fff887c863a -[NSControl mouseDown:] + 786
    31  AppKit                              0x00007fff887930e0 -[NSWindow sendEvent:] + 6306
    32  AppKit                              0x00007fff88c467fc -[NSStatusBarWindow sendEvent:] + 66
    33  AppKit                              0x00007fff8872b68f -[NSApplication sendEvent:] + 5593
    34  AppKit                              0x00007fff886c1682 -[NSApplication run] + 555
    35  AppKit                              0x00007fff8894080c NSApplicationMain + 867
    36  SongController                      0x0000000100001022 main + 34
    37  SongController                      0x0000000100000ff4 start + 52
)
<?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>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.temporary-exception.apple-events
com.apple.security.temporary-exception.apple-events
</key>
    <array>
        <string>com.apple.systemevents</string>
        <string>com.google.chrome</string>
        <string>com.apple.safari</string>
    </array>
</dict>
</plist>