Skip to content

Instantly share code, notes, and snippets.

@itjustcrashed
Created August 9, 2024 23:11
Show Gist options
  • Save itjustcrashed/587dec599ad16a1149bc6800c0486e5c to your computer and use it in GitHub Desktop.
Save itjustcrashed/587dec599ad16a1149bc6800c0486e5c to your computer and use it in GitHub Desktop.
Open in Apple Maps Xcode Snippet
<!--- Paste into ~/Library/Developer/Xcode/UserData/CodeSnippets --->
<!--- Created by @wannafedor4 aka @itjustcrashed --->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>maps_url</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>CodeBlock</string>
</array>
<key>IDECodeSnippetContents</key>
<string>let mapsURL = URL(string: "maps://?saddr=&amp;daddr=&lt;#latitude#&gt;,&lt;#longitude#&gt;")
if UIApplication.shared.canOpenURL(mapsURL!) {
UIApplication.shared.open(mapsURL!)
} else {
&lt;#Handle nonexistant Maps#&gt;
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>353EE9E1-EB3B-431E-B706-F5E71C9BF9B3</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>Check if Apple Maps is installed, and launch it with specified coordinates.</string>
<key>IDECodeSnippetTitle</key>
<string>Open in Maps</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment