Using Xcode (or Instruments), is there a way to know all the functions/symbols that are touched by a line of code?
struct Test {
private func intro() {
}
func partOne() {
intro()
}
func partTwo() {
partOne()
}
func partThree() {
partTwo()
print(credits)
}
private var credits: String {
""
}
}
let test = Test()
test.partTwo() // partTwo, partOne, intro
test.partThree() // partThree, partTwo, partOne, intro, credits
There’s no built-in functionality that’ll do that. If you’d like to see that change, I encourage you to file an enhancement request describing your requirements.
Please post your bug number, just for the record.
In the meantime, you might be able to work around this using Xcode’s code coverage support. I’ve not explored the Swift side of this, but in C-based languages the code coverage support works by inserting calls to runtime functions at the beginning and end of each routine. If you replace those runtime functions with your own code, you could build this data yourself.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"