我想以编程方式确定iOS应用程序是否直接从XCode运行(在模拟器中或在系留设备上).我已经尝试了这里描述的-D DEBUG解决方案,但是当我从Xcode断开并重新运行应用程序时,它仍然认为它处于调试模式.我认为我正在寻找的是这个函数的Swift版本
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static bool AmIBeingDebugged(void)
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
{
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info.kp_proc.p_flag = 0;
// Initialize mib, which tells sysctl …Run Code Online (Sandbox Code Playgroud) 我正在实施新的iOS10扩展以使用丰富的通知.我试图在推送通知上测试它但不工作,我只是收到一个简单的通知,而不是通过扩展.
我做了官方网站和其他一些地方指定的所有内容:
正如我所说,我收到通知但从未通过扩展.我看到操作系统如何尝试加载扩展但随后抛出一个没有相关描述的错误来识别问题:
Dec 31 21:00:00 iPhone SpringBoard(libextension.dylib)[51] <Notice>: calling plugIn beginUsing:
Dec 31 21:00:57 iPhone pkd[86] <Notice>: assigning plug-in com.test.app.NotificationWithAttachmentExtension(1.0) to plugin sandbox
Dec 31 21:03:57 iPhone pkd[86] <Notice>: enabling pid=51 for plug-in com.test.app.NotificationWithAttachmentExtension(1.0) 38BB5FF1-2597-42E0-B950-169DBFA80573 /private/var/containers/Bundle/Application/A8C47706-C0EC-4FB1-ABA7-0118372F6900/testapp.app/PlugIns/NotificationWithAttachmentExtension.appex
Dec 31 21:00:53 iPhone SpringBoard(PlugInKit)[51] <Notice>: plugin com.test.app.NotificationWithAttachmentExtension interrupted
Dec 31 21:03:56 iPhone SpringBoard(PlugInKit)[51] <Notice>: Hub connection error Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.test.app.NotificationWithAttachmentExtension" UserInfo={NSDebugDescription=connection to service named com.test.app.NotificationWithAttachmentExtension}
Jun 29 13:33:36 iPhone SpringBoard(libextension.dylib)[51] <Notice>: PlugInKit …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中启用了 NotificationServiceExtension。并做了以下
以下是我的 NotificationService 的didReceiveNotificationRequest方法
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.bestAttemptContent = [request.content mutableCopy];
self.bestAttemptContent.badge = @20;
self.contentHandler(self.bestAttemptContent);
Run Code Online (Sandbox Code Playgroud)
}
不知道我在这里缺少什么。搜索并关注了这么多文件。似乎没有任何工作。
我正在使用 XCode 11.2.1 和带有 ios 版本 13 的真实设备。
如何从扩展中打印Xcode的lldb 调试器中的日志?