Last active
October 13, 2022 06:16
-
-
Save JamalK/c104cb38f52813c0fddd to your computer and use it in GitHub Desktop.
FaceTime from command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
//swiftc facetime_cli.swift -o facetime_cli | |
// sudo cp facetime_cli /usr/bin | |
// Enjoy! usage: facetime_cli $PHONE_NUMBER or $APPLE_ID | |
import Foundation | |
import Cocoa | |
extension Array { | |
func safeObjectAt(index: Int) -> Element? { | |
if index < self.count { | |
return self[index] | |
} | |
else { | |
return nil | |
} | |
} | |
} | |
if let address = Process.arguments.safeObjectAt(1) where address.characters.count > 0 { | |
let url: String = "tel://\(address)" | |
print("Calling \(address)...") | |
NSWorkspace.sharedWorkspace().openURL(NSURL(string: url)!) | |
} else { | |
print("Please supply an address to call") | |
} | |
Successfully built it with xcrun -sdk macosx swiftc facetime_cli.swift -o facetime_cli
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this as a raw file and did the commands you suggested. How do I import Cocoa if it doesn't exist? Sorry, I'm new to Swift and I'm just trying to facetime call from command line.