Xcode 命令行工具项目是否允许 CoreLocation 权限?

发布于 2024-12-23 04:06:10 字数 250 浏览 0 评论 0原文

我有一个用 C++ 编写的 Xcode“命令行工具”项目。我最近添加了 CoreLocation 框架和关联代码来查找用户位置。

通常,当我实现 CoreLocation 框架时,OS X 会要求我授予应用程序权限。我的命令行工具不会发生这种情况。是因为没有关联的窗口/菜单吗?

另外,如果我尝试在“安全”>“系统偏好设置”窗格中手动启用权限,每次我运行应用程序时,隐私都会自动被禁用 - 即使我明确允许访问。

任何信息将不胜感激。

I have a Xcode 'Command Line Tool' project written in C++. I recently added the CoreLocation framework and associated code to find the users location.

Usually, when I implement the CoreLocation framework OS X will ask to me grant permission for the application. This doesn't happen with my Command Line Tool. Is it because there is no associated window / menu?

Also, if I try to manually enable permission in the System Preferences pane under Security > Privacy it automatically gets disabled each time I run the application - even though I've explicitly allowed access.

Any information would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一场春暖 2024-12-30 04:06:10

Mac OS 下的某些东西需要连接到窗口服务器。 NSImage 就是一个例子,位置服务可能也需要这样的连接。

但是,我不知道如何在不调用 NSApplicationMain 的情况下建立此类连接。

您可以做的是编写一个不显示在扩展坞中的辅助应用程序(如状态栏应用程序),但调用 NSApplicationMain。然后,该应用程序将执行所有位置服务,并通过标准输出或套接字或类似的东西与调用进程(您的 CLI)进行通信。

Some things under Mac OS need a connection to the window server. An example of that is NSImage, and it might be that the location services also requires such a connection.

However, I do not know how to make such connection without calling NSApplicationMain.

What you could do is write an auxiliary application that does not show up in the dock (like a status bar application) but calls NSApplicationMain. This app would then do all location services and communicate with the calling process (your CLI) through the stdout or sockets or something similar.

合久必婚 2024-12-30 04:06:10

您是否还将 Foundation.h 导入到您的项目中?您应该检查 CoreLocation 具有的所有依赖项,并确保它们将其添加到您的项目中。 CoreLocation 也是用 Objective-C 编写的,因此某些调用可能无法被 C++ 编译器捕获。

Are you also importing Foundation.h into your project? You should check to see all the dependencies that CoreLocation has and make sure they are making it into your project. CoreLocation is also written in Objective-C so some of the calls may not be caught by c++ your compiler.

浅浅 2024-12-30 04:06:10

当CoreLocation请求位置数据时,Mac会提示一个消息框要求用户授予权限,如果您选中“不要再问我”并单击“确定”,那么它就不会再提示该消息,除非您“重置警告”在“安全”首选项窗格中,但如果将命令行应用程序移动到另一个目录,Mac 将再次请求权限。我相信此权限与应用程序的完整路径一起存储。

when CoreLocation ask for location data, the Mac will prompt a message box ask user to give the permission, if you check the Don't ask me again and click the OK, then it will never prompt the message again unless you "Reset Warnings" under Security preference pane, but if you move the command line app to another directory, the Mac will ask for permission again. I believe this permission is stored with full path of the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文