<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I am unsure where to post this…but iOS 10 is introducing a new API for activity tracing and logging.<div class=""><br class=""></div><div class="">The API has been “Swift-ified” a little, but it still is a little awkward to use:</div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class=""><br class=""></span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">os_log</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Sender: %{public}@"</span><span style="font-variant-ligatures: no-common-ligatures" class="">, log: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ViewController</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ui_log</span><span style="font-variant-ligatures: no-common-ligatures" class="">, type: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">debug</span><span style="font-variant-ligatures: no-common-ligatures" class="">, sender)</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(This is taken from: <a href="https://developer.apple.com/library/prerelease/content/samplecode/Logging/Introduction/Intro.html#//apple_ref/doc/uid/TP40017510" class="">https://developer.apple.com/library/prerelease/content/samplecode/Logging/Introduction/Intro.html#//apple_ref/doc/uid/TP40017510</a>)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">Note: the {public} modifier above does not work in swift but does in Objective-C. I have filed a radar for this.</b></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">A few things:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">• This looks like how the Dispatch APIs use to look: very C-like which was made to be much better in The Great Renaming</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">• Cannot use Swift’s string interpolation, resulting in the arguments being passed in at the end</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">For reference, this is what it looks like in Objective-C, showing that SOME renaming has occurred: </span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">os_log_debug</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ui_log</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">"Sender: %{public}@"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, sender);</span></div><div class=""><br class=""></div></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">This might look more Swift-like:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 12px;" class="">uiLog.</span></span><span style="color: rgb(62, 30, 129); font-family: Menlo; font-size: 12px;" class="">log(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 12px;" class="">"Sender: %{public}</span><span style="font-family: Menlo; font-size: 12px;" class="">\(sender)</span><font color="#d12f1b" face="Menlo" class=""><span style="font-size: 12px;" class="">”, </span></font><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" class="">type: .</span><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">debug)</span></div><div class="">* Makes “log” a method on an OSLog object </div><div class="">• Uses string interpolation</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><br class=""></div></div><div class="">I hope this isn’t too late AND maybe we will see something more complete when the GM is released, but this seems important to correct and get right BEFORE it is released.</div><div class=""><br class=""></div><div class="">The OS framework is also suppose to have new activity tracing API but it is not yet exposed in Swift. This is worrisome as the GM is allegedly dropping next week.</div><div class=""><br class=""></div><div class="">If this is pushed aside: what happens when it is released as it is? Are we stuck with this API? Can it be corrected in Swift 4 (breaking changes etc…)?</div><div class=""><br class=""></div><div class="">Brandon</div></body></html>