Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.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
LaunchAgent无法访问macOS“;“受保护”;文件夹_Macos_Permissions_Launch Agent - Fatal编程技术网

LaunchAgent无法访问macOS“;“受保护”;文件夹

LaunchAgent无法访问macOS“;“受保护”;文件夹,macos,permissions,launch-agent,Macos,Permissions,Launch Agent,我有一个shell脚本,它可以执行以下操作: #!/bin/bash ls -la "$HOME/Pictures/Photos Library.photoslibrary" 当我在shell中运行这个脚本时,它工作得很好。如果我定义了执行此脚本的LaunchAgent(在$HOME/Library/LaunchAgent下),我会收到以下错误消息: ls: Photos Library.photoslibrary: Operation not permitted 我

我有一个shell脚本,它可以执行以下操作:

#!/bin/bash

ls -la "$HOME/Pictures/Photos Library.photoslibrary"

当我在shell中运行这个脚本时,它工作得很好。如果我定义了执行此脚本的LaunchAgent(在
$HOME/Library/LaunchAgent
下),我会收到以下错误消息:

ls: Photos Library.photoslibrary: Operation not permitted
我真正的脚本是调用HashBackup(
hb
),这会在所有那些“受保护”的文件夹(图片、通讯簿等)上导致同样的错误。但是我能够用一个简单的
ls
复制

我该怎么做才能解决这个问题

这在macOS 10.14.6上


谢谢

感谢Gordon的评论,我能够按照步骤解决我的问题。实际上对我有效的步骤是

为了获得更完整的解决方案,以下是一个基于CMake的小型解决方案:

  • main.cpp
  • #包括
    int main()
    {
    
    std::你不能做任何答案来解决这个问题吗?谢谢@GordonDavisson,因为你链接到的问题显然就是我要问的。
    cmake_minimum_required(VERSION 3.19)
    
    set(VERSION 1.0.0)
    
    project(HashBackupLaunchAgent VERSION "${VERSION}")
    
    set(CMAKE_CXX_STANDARD 17)
    
    set(MACOSX_BUNDLE_BUNDLE_NAME "HashBackupLaunchAgent")
    set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.pongasoft.HashBackupLaunchAgent")
    set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION}")
    set(MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION}")
    set(MACOSX_BUNDLE_COPYRIGHT "2021 pongasoft")
    
    add_executable(HashBackupLaunchAgent MACOSX_BUNDLE main.cpp backup_argon.sh)
    
    set_target_properties(HashBackupLaunchAgent PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/Info.plist.in")
    
    set_source_files_properties(backup_argon.sh PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)