Nick Lasta
Nick Lasta

Reputation: 131

Issues loading file for iOS Content Blocker

I'm trying to load a file I've save for my iOS Content blocker but I keep getting this log and it won't work. This is my code and log I'm getting, can someone please help me find the issue?

Thanks

Optional(Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.SafariServices.ContentBlockerLoader" UserInfo={NSDebugDescription=connection to service named com.apple.SafariServices.ContentBlockerLoader})

import UIKit
import MobileCoreServices

class ActionRequestHandler: NSObject, NSExtensionRequestHandling {

    func beginRequestWithExtensionContext(context: NSExtensionContext) {
        let attachment = NSItemProvider(contentsOfURL: NSBundle.mainBundle().URLForResource("blockerList", withExtension: "json"))!

        let item = NSExtensionItem()
        item.attachments = [attachment]


        if let urlToFile = BlackListManager.sharedInstance.urlToFile(), userFile = NSItemProvider(contentsOfURL: urlToFile) {
            item.attachments = [userFile]
        }

        print(item.attachments)

        context.completeRequestReturningItems([item], completionHandler: { expired in
            print("%@", expired)
        })
    }
}

Upvotes: 2

Views: 309

Answers (1)

Bhanu Pratap Yadav
Bhanu Pratap Yadav

Reputation: 1

Uncheck code coverage from schemes then work.

Upvotes: 0

Related Questions