相关疑难解决方法(0)

检测是否正在从Xcode运行Swift应用程序

我想以编程方式确定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)

xcode ios swift

19
推荐指数
1
解决办法
2971
查看次数

未调用iOS10 UNNotificationServiceExtension

我正在实施新的iOS10扩展以使用丰富的通知.我试图在推送通知上测试它但不工作,我只是收到一个简单的通知,而不是通过扩展.

我做了官方网站和其他一些地方指定的所有内容:

  • 我的应用程序启动并运行推送通知和正确的配置文件
  • 我在我的应用程序中添加了一个新目标,即通知服务扩展
  • 实现了我自己的代码(真的没关系,因为甚至没有进入新类)
  • 此外,我必须为此扩展设置配置文件,我只使用带有通配符的配置文件,我没有看到任何文档指定扩展目标是否必须启用推送通知功能,在这种情况下我需要为此扩展一个特定的配置一,目前我只使用通配符,无论如何它匹配(它必须匹配)我在应用目标中使用的配置文件,并且仅为应用目标启用了推送通知功能.
  • 我添加了UNNotificationExtensionCategory和NSExtensionPointIdentifier.我也将该类别作为推送有效载荷的一部分从服务器发送.

正如我所说,我收到通知但从未通过扩展.我看到操作系统如何尝试加载扩展但随后抛出一个没有相关描述的错误来识别问题:

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)

apple-push-notifications ios ios10

19
推荐指数
9
解决办法
2万
查看次数

iOS NotificationServiceExtension 不起作用

我在我的应用程序中启用了 NotificationServiceExtension。并做了以下

  1. 在框架、库和嵌入式内容下添加了 .apppex
  2. 确认两个部署目标版本都是 12.0
  3. Sending mutable-content": 1 在我的 apns 通知负载中
  4. 以下是我的 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 的真实设备。

objective-c ios unnotificationserviceextension

9
推荐指数
0
解决办法
95
查看次数

如何调试ios共享扩展?

如何从扩展中打印Xcode的lldb 调试器中的日志?

xcode ios lldb swift ios8-share-extension

7
推荐指数
3
解决办法
6049
查看次数