{"id":122829,"date":"2021-01-05T17:00:38","date_gmt":"2021-01-05T17:00:38","guid":{"rendered":"https:\/\/developer.apple.com\/news\/?id=qiz0arxc"},"modified":"2021-01-05T17:00:38","modified_gmt":"2021-01-05T17:00:38","slug":"how-to-convert-existing-web-extensions-for-safari","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2021\/01\/05\/how-to-convert-existing-web-extensions-for-safari\/","title":{"rendered":"How to convert existing web extensions for Safari"},"content":{"rendered":"<div class=\"inline-article-image\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2021\/01\/how-to-convert-existing-web-extensions-for-safari.jpg\" data-hires=\"false\"><\/div>\n<p>When you create a Safari Web Extension, you can help people get common online tasks done more quickly and efficiently \u2014&nbsp;all while using the same extension model and APIs found in extensions for Google Chrome, Mozilla Firefox, and Microsoft Edge browsers.<\/p>\n<p>If you have an existing web extension you\u2019d like to prepare for distribution in the Mac App Store, it\u2019s easy to to get started with the converter tool in Xcode 12. Here\u2019s how to go about it.<\/p>\n<section class=\"grid activity\">\n<section class=\"row\">\n<section class=\"column large-4 small-4 no-padding-top no-padding-bottom\"> <a href=\"https:\/\/developer.apple.com\/wwdc20\/10665\" class=\"activity-image-link\"> <img decoding=\"async\" class=\"actiity-image medium-scale\" width=\"250\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2021\/01\/how-to-convert-existing-web-extensions-for-safari-1.jpg\" data-hires=\"false\" alt> <\/a> <\/section>\n<section class=\"column large-8 small-8 padding-left-small padding-top-small padding-bottom-small no-padding-top no-padding-bottom\"> <a href=\"https:\/\/developer.apple.com\/wwdc20\/10665\"> <\/p>\n<h4 class=\"no-margin-bottom activity-title\">Meet Safari Web Extensions<\/h4>\n<p> <\/a> <\/p>\n<p class=\"activity-description\">When you create a Safari Web Extension, you can help people get common online tasks done more quickly and efficiently. We\u2019ll show you how to build a new Safari Web Extension and host it on the App Store, as well as how to use the safari-web-extension-converter tool to migrate existing extensions&#8230;<\/p>\n<\/section>\n<\/section>\n<\/section>\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/safariservices\/safari_app_extensions\" class=\"icon icon-after icon-chevronright\">Learn more about Safari App Extensions<\/a><\/p>\n<h3>Convert an extension<\/h3>\n<p>Before getting started, make sure you\u2019ve installed the latest versions of Xcode 12, Command Line Tools, and Safari 14. When ready, you can then run the following command in the Terminal app:<\/p>\n<pre class=\"code-source\"><code>xcrun safari-web-extension-converter \/path\/to\/my\/extension\/<\/code><\/pre>\n<p>The converter tool will search for your extension\u2019s manifest at <code>.\/path\/to\/my\/extension\/manifest.json<\/code> and generate a default configuration for your Xcode project. If the configuration appears correct, type <code>yes<\/code> at the prompt and press the <strong>Return<\/strong> key. If not, type <code>no<\/code> and you can enter the converter tool\u2019s interactive mode to customize the configuration.<\/p>\n<hr>\n<p><em><strong>Note: Verify your keys<\/strong><\/em><br \/>\n<em>During the conversion process, <code>safari-web-extension-converter<\/code> will look through your manifest for any keys that aren\u2019t supported by your installed version of Safari. If Xcode finds any issues, the app will display a warning message. If you receive this, consider whether the affected keys are critical for your extension to function. You may still be able to leave these keys in place and have everything run smoothly, but be sure to test your extension to confirm.<\/em><\/p>\n<hr>\n<h3>Adjust a converted extension in Xcode<\/h3>\n<p>Safari Web Extensions require a container app so that you can easily distribute your extension on the Mac App Store. As part of the conversion process, Xcode automatically creates and opens a container app project that contains your extension files. From here, you can test your extension, make any necessary code changes, update your extension\u2019s icon, and upload your container app for distribution through the Mac App Store.<\/p>\n<p><strong>Test, test, and test again<\/strong><br \/>\nWhile inside your Xcode project, you can build and run your extension by either pressing <strong>Command-R<\/strong> or the <strong>Play<\/strong> button in the upper left portion of the screen. <\/p>\n<p>Your container app has a button to open Safari Extensions preferences. Select this button to open Safari and enable your extension in the browser.<\/p>\n<p>Note: If this is your first time testing an extension through Xcode, you\u2019ll need to enable support for unsigned extensions in Safari. To do so, follow these steps:<\/p>\n<ol>\n<li>Open <strong>Safari<\/strong>.<\/li>\n<li>Select <strong>Safari &gt; Preferences<\/strong>.<\/li>\n<li>Navigate to the <strong>Advanced<\/strong> tab.<\/li>\n<li>Check the <strong>\u201dShow Develop menu in menu bar\u201d<\/strong> checkbox.<\/li>\n<li>Navigate to the Develop menu and select <strong>\u201dAllow Unsigned Extensions.\u201d<\/strong> You may have to enter your admin password to make changes.<\/li>\n<\/ol>\n<p><strong>Make any code changes<\/strong><br \/>\nBy default, your Xcode project references your extension\u2019s existing content as well as native Swift or Objective-C code to create the container app. After testing, you can make any needed changes to this project; any alterations you make will automatically show up as part of your Safari Web Extension the next time you build your Xcode project.<\/p>\n<p><strong>Update your icon<\/strong><br \/>\nXcode will use any extension icons listed in your manifest as your app icon, which will also display on your Mac App Store listing. Because Safari Web Extension icons are typically smaller, however, you may want to update to a higher-resolution version of this image for the best look. <\/p>\n<div class=\"inline-article-image\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2021\/01\/how-to-convert-existing-web-extensions-for-safari-2.jpg\" data-hires=\"false\"><\/div>\n<p>To change your icons, select the Assets.xcassets folder in the Xcode sidebar, then drag the new icons into the appropriately-sized image wells.<\/p>\n<p><strong>Add any additional files to your Xcode project<\/strong><br \/>\nIf you need to add additional resources or code files to your extension after conversion \u2014&nbsp;for example, images used by your user interface or other dependencies missed during conversion&nbsp;\u2014 you will also need to manually include these files in your Xcode project.<\/p>\n<div class=\"inline-article-image\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2021\/01\/how-to-convert-existing-web-extensions-for-safari-3.jpg\" data-hires=\"false\"><\/div>\n<p>To do so, select any additional files in Finder and drag them into the <strong>Resources<\/strong> folder within your Xcode project, located in the left sidebar. Uncheck <strong>\u2019Copy items if needed\u2019<\/strong> in the file dialog to make sure these files automatically associate with your app.<\/p>\n<h3>Distribute your extension<\/h3>\n<p>When you\u2019re ready to share your extension, sign in with your Apple Developer account to App Store Connect and upload the container app to for distribution. Remember to review the App Store guidelines before submitting to the Mac App Store; Apple reviews all extensions and extension updates to verify they work reliably.<\/p>\n<p><a href=\"https:\/\/developer.apple.com\/app-store\/review\/guidelines\/#extensions\" class=\"icon icon-after icon-chevronright\">Learn more about submitting extensions to the Mac App Store<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you create a Safari Web Extension, you can help people get common online tasks done more quickly and efficiently \u2014&nbsp;all while using the same extension model and APIs found in extensions for Google Chrome, Mozilla Firefox, and Microsoft Edge browsers. If you have an existing web extension you\u2019d like to prepare for distribution in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":122830,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"class_list":["post-122829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apple-developer-news"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/122829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=122829"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/122829\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/122830"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=122829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=122829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=122829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}