How to convert existing web extensions for Safari – Discover

How to convert existing web extensions for Safari – Discover

  • Apple
  • January 5, 2021
  • No Comment
  • 72
  • 7 minutes read


Web extension icon

When you create a Safari web extension, you can help people get their online tasks done faster and more efficiently by using the same extension model and APIs found in extensions for Google Chrome browsers. Mozilla Firefox and Microsoft Edge.

If you have an existing web extension that you want to prepare for distribution in the Mac App Store, it’s easy to get started with the Xcode 12 conversion tool. Here’s how to do it.

Learn about Safari web extensions

Safari web extensions

Convert an extension

Before you begin, make sure you’ve installed the latest versions of Xcode 12, Command Line Tools, and Safari 14. When you’re ready, you can run the following command in the Terminal application:

xcrun safari-web-extension-converter /path/to/my/extension/

The conversion tool will search for the manifest of your extension in ./path/to/my/extension/manifest.json and generate default settings for your Xcode project. If the setting seems correct, type yes on the application and press Come back key. If not, write no and you can enter the conversion tool’s interactive mode to customize your settings.


Note: Please verify your passwords
During the conversion process, safari-web-extension-converter will search your manifest for any key that is not compatible with your installed version of Safari. If Xcode encounters a problem, the app will display a warning message. If you receive it, please note that the affected keys are critical for your extension to work. You may still be able to leave these keys in place and everything will run smoothly, but be sure to test your extension to confirm.


Set an converted Xcode extension

Safari web extensions require a container app so you can easily distribute your extension to the Mac App Store. As part of the conversion process, Xcode automatically creates and opens a container application project that contains the extension files. From here, you can test your extension, make the necessary code changes, update the extension icon, and upload the container app for distribution through the Mac App Store.

Try, try and try again
While in your Xcode project, you can create and run your extension by clicking Command-R or he Play button at the top left of the screen.

Your container app has a button to open Safari extension preferences. Select this button to open Safari and enable your browser extension.

Note: If this is the first time you’ve tried an extension using Xcode, you’ll need to enable unsigned extensions support in Safari. To do this, follow these steps:

  1. Open Safari.
  2. Select Safari> Preferences.
  3. Navigate to Advanced tab.
  4. Check the “Show Development menu in menu bar” checkbox.
  5. Go to the Development menu and select “Allow unsigned extensions”. You may need to enter your administrator password to make changes.

Make any code changes
By default, your Xcode project refers to the existing content of your extension, as well as the native Swift or Objective-C code to create the container application. After the test, you can make the necessary changes to this project; any changes you make will automatically show up as part of your Safari web extension the next time you create your Xcode project.

Update your icon
Xcode will use the extension icons listed in your manifest as the app icon, which will also be displayed in your Mac App Store list. Because the icons in the Safari web extension are usually smaller, you may want to upgrade this image to a higher resolution version for a better look.

upload icon to Xcode screenshot

upload icon to Xcode screenshot

To change the icons, select the Assets.xcassets folder in the Xcode sidebar, and drag the new icons to the image wells of the appropriate size.

Add additional files to your Xcode project
If you need to add additional resources or code files to your extension after conversion, for example, images used by your UI or other dependencies that were lost during the conversion, you’ll also need to manually include these files. in your Xcode project.

Add the file screen to Xcode

To do this, select any additional files in the Finder and drag them into the file Resources folder within your Xcode project, located in the left sidebar. Uncheck “Copy items if needed” in the file dialog to make sure these files are automatically associated with your application.

Distribute your extension

When you’re ready to share your extension, sign in with your Apple Developer account on the App Store Connect and upload the container app to distribute it. Remember to review the App Store guidelines before submitting them to the Mac App Store; Apple reviews all extensions and extension updates to verify that they work reliably.

Learn more about submitting extensions to the Mac App Store



Source link

Related post

Open House: What steps can be taken to check the rising cases of suicides among youths? : The Tribune India

Open House: What steps can be taken to check…

Education institution should set up helplines To begin with, it should be made clear that stress is a physical reaction to…
Here are the top 25 start-ups to work for in India

Here are the top 25 start-ups to work for…

It’s also great to see young professionals embracing India’s startup ecosystem, with 56% of all hires at the top 25 startups…
Micro:bit launches new Python Editor to help more children learn text-based coding languages

Micro:bit launches new Python Editor to help more children learn…

Micro:bit Educational Foundation, the educational nonprofit on a mission to improve children’s digital skills, today announced that it’s even easier for…

Leave a Reply

Your email address will not be published.