0

Currently I'm working on safari app extension for iphones, and I want to get the maximum data from the safari app active page. I went through many posts but I couldn't find how to do? Could someone help please? [Extension folder][1] [1]: https://i.stack.imgur.com/MkjPf.png

And why SFSafariApplication is not found by the SafariWebExtensionHandler?

  • https://i.stack.imgur.com/MkjPf.png Folder structure – Damon Wagner Sep 14 '22 at 10:02
  • What is **the maximum data**? From the image you linked, you are building a Safari Web Extension. This means you can utilize the [Web Extensions API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions) which gives you lots of possibilities for getting information about the active tab - take a look through the API. Also, [here's a good tutorial to get you started](https://developer.apple.com/documentation/safariservices/safari_web_extensions/creating_a_safari_web_extension). – justinw Sep 15 '22 at 01:09
  • @justinw actually I'm trying to build a safari app extension which should be integrated in the app, the folder structure you are seeing is when I add a target as safari extension. Focus is app not web. – Damon Wagner Sep 15 '22 at 06:08
  • If you are trying to build an app extension, you have the wrong boilerplate. When making the new target you should have selected `Safari App Extension` not `Safari Web Extension` (which is the default choice). If you did that, your folder structure would be different, for example you'd have `SafariExtensionHandler.swift` and `SafariExtensionViewController.swift` at the top level rather than `SafariWebExtensionHandler.swift`. You probably want to replace that target you just added. – justinw Sep 15 '22 at 12:32
  • I did not add web extension my friend, after selecting an option to add a target I selected safari app extension, there was no option for web extension, that is the confusion why I'm getting web extension handler :( – Damon Wagner Sep 16 '22 at 04:45
  • Sounds like a possible bug. When I add a new target I can choose between the two options. Maybe Xcode needs update? – justinw Sep 16 '22 at 18:24
  • I'm using xcode 13.2.1, are you able to get the folder structure which you are telling? If so can you please tell me the flow? – Damon Wagner Sep 19 '22 at 05:32
  • I have an existing macOS app. In Xcode I select `File > New > Target`, then a window appears to select the target. I select `macOS > Safari Extension`. After selecting that I am able to select the `Type` option which has two values, `Safari Web Extension` and `Safari App Extension`. For your case, I would select `Safari App Extension`. Could it be that you selected `Multiplatform > Safari Extension App`? That would set you up with a `Web Extension` since `Safari App Extensions` are **not** multiplatform. – justinw Sep 19 '22 at 12:58

0 Answers0