

{"id":12891,"date":"2021-01-23T17:09:18","date_gmt":"2021-01-23T22:09:18","guid":{"rendered":"https:\/\/rud.is\/b\/?p=12891"},"modified":"2021-01-25T09:04:52","modified_gmt":"2021-01-25T14:04:52","slug":"swiftr-switcheroo-calling-compiled-swift-from-r","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/","title":{"rendered":"SwiftR Switcheroo: Calling [Compiled] Swift from R!"},"content":{"rendered":"<p>I&#8217;ve been on a <a href=\"https:\/\/rud.is\/books\/swiftr\">Swift + R bender<\/a> for a while now, but have been envious of the pure macOS\/iOS (et al) folks who get to use Apple&#8217;s seriously ++good <a href=\"https:\/\/developer.apple.com\/machine-learning\/\">machine learning<\/a> libraries, which are even more robust on the new M1 hardware (it&#8217;s cool having hardware components dedicated to improving the performance of built models).<\/p>\n<p>Sure, it&#8217;s pretty straightforward to make a command-line utility that can take data input, run them through models, then haul the data back into R, but I figured it was about time that Swift got the &#8220;Rust&#8221; and &#8220;Go&#8221; treatment in terms of letting R call compiled Swift code directly. Thankfully, none of this involves using Xcode since it&#8217;s one of the world&#8217;s worst IDEs.<\/p>\n<p>To play along at home you&#8217;ll need macOS and at least the command line tools installed (I don&#8217;t <em>think<\/em> this requires a full Xcode install, but y&#8217;all can let me know if it does in the comments). If you can enter <code>swiftc<\/code> at a terminal prompt and get back <code>&lt;unknown&gt;:0: error: no input files<\/code> then you&#8217;re good-to-go.<\/p>\n<h3>Hello, Swift!<\/h3>\n<p>To keep this post short (since I&#8217;ll be adding this entire concept to the SwiftR tome), we&#8217;ll be super-focused and just build a shared library we can dynamically load into R. That library will have one function which will be to let us say hello to the planet with a customized greeting.<\/p>\n<p>Make a new directory for this effort (I called mine <code>greetings<\/code>) and create a <code>greetings.swift<\/code> file with the following contents:<\/p>\n<p>All this code is also <a href=\"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switchero\u2026led-swift-from-r\/\">in this gist<\/a>.<\/p>\n<pre><code class=\"language-swift\">@_cdecl (\"greetings_from\")\npublic func greetings_from(_ who: SEXP) -&gt; SEXP {\n  print(\"Greetings, ?, it's \\(String(cString: R_CHAR(STRING_ELT(who, 0))))!\")\n  return(R_NilValue)\n}\n<\/code><\/pre>\n<p>Before I explain what&#8217;s going on there, also create a <code>geetings.h<\/code> file with the following contents:<\/p>\n<pre><code class=\"language-clike\">#define USE_RINTERNALS\n\n#include &lt;R.h&gt;\n#include &lt;Rinternals.h&gt;\n\nconst char* R_CHAR(SEXP x);\n<\/code><\/pre>\n<p>In the Swift file, there&#8217;s a single function that takes an R <code>SEXP<\/code> and converts it into a Swift <code>String<\/code> which is then routed to <code>stdout<\/code> (not a &#8220;great&#8221; R idiom, but benign enough for an intro example). Swift functions aren&#8217;t C functions and on their own do not adhere to C calling conventions. Unfortunately R&#8217;s ability to work with dynamic library code requires such a contract to be in place. Thankfully, the Swift Language Overlords provided us with the ability to instruct the compiler to create library code that will force the calling conventions to be C-like (that&#8217;s what the <code>\uff20cdecl<\/code> is for).<\/p>\n<p>We&#8217;re using <code>SEXP<\/code>, some R C-interface functions, and even the C version of <code>NULL<\/code> in the Swift code, but we haven&#8217;t done anything in the Swift file to tell Swift about the existence of these elements. That&#8217;s what the C header file is for (I added the <code>R_CHAR<\/code> declaration since complex C macros don&#8217;t work in Swift).<\/p>\n<p>Now, all we need to do is make sure the compiler knows about the header file (which is a &#8220;bridge&#8221; between C and Swift), where the R framework is, and that we want to generate a library vs a binary executable file as we compile the code. Make sure you&#8217;re in the same directory as both the <code>.swift<\/code> and <code>.h<\/code> file and execute the following at a terminal prompt:<\/p>\n<pre><code class=\"language-bash\">swiftc \\\n  -I \/Library\/Frameworks\/R.framework\/Headers \\ # where the R headers are\n  -F\/Library\/Frameworks \\                      # where the R.framework lives\n  -framework R \\                               # we want to link against the R framework\n  -import-objc-header greetings.h \\            # this is our bridging header which will make R C things available to Swift\n  -emit-library \\                              # we want a library, not an exe\n  greetings.swift                              # our file!\n<\/code><\/pre>\n<p>If all goes well, you should have a <code>libgreetings.dylib<\/code> shared library in that directory.<\/p>\n<p>Now, fire up a R console session in that directory and do:<\/p>\n<pre><code class=\"language-r\">greetings_lib &lt;- dyn.load(\"libgreetings.dylib\")\n<\/code><\/pre>\n<p>If there are no errors, the shared library has been loaded into your R session and we can use the function we just made! Let&#8217;s wrap it in an R function so we&#8217;re not constantly typing <code>.Call(\u2026)<\/code>:<\/p>\n<pre><code class=\"language-r\">greetings_from &lt;- function(who = \"me\") {\n  invisible(.Call(\"greetings_from\", as.character(who[1])))\n}\n<\/code><\/pre>\n<p>I also took the opportunity to make sure we are sending a length-1 character vector to the C\/Swift function.<\/p>\n<p>Now, say hello!<\/p>\n<pre><code class=\"language-r\">greetings_from(\"hrbrmstr\")\n<\/code><\/pre>\n<p>And you should see:<\/p>\n<pre><code class=\"language-bash\">Greetings, ?, it's hrbrmstr!\n<\/code><\/pre>\n<h3>FIN<\/h3>\n<p>We&#8217;ll stop there for now, but hopefully this small introduction has shown how straightforward it can be to bridge Swift &amp; R in the other direction.<\/p>\n<p>I&#8217;ll have another post that shows how to extend this toy example to use one of Apple&#8217;s natural language processing libraries, and may even do one more on how to put all this into a package before I shunt all the individual posts into a few book chapters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been on a Swift + R bender for a while now, but have been envious of the pure macOS\/iOS (et al) folks who get to use Apple&#8217;s seriously ++good machine learning libraries, which are even more robust on the new M1 hardware (it&#8217;s cool having hardware components dedicated to improving the performance of built [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[780,91,830],"tags":[],"class_list":["post-12891","post","type-post","status-publish","format-standard","hentry","category-macos","category-r","category-swift"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is\" \/>\n<meta property=\"og:description\" content=\"I&#8217;ve been on a Swift + R bender for a while now, but have been envious of the pure macOS\/iOS (et al) folks who get to use Apple&#8217;s seriously ++good machine learning libraries, which are even more robust on the new M1 hardware (it&#8217;s cool having hardware components dedicated to improving the performance of built [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-23T22:09:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-25T14:04:52+00:00\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"SwiftR Switcheroo: Calling [Compiled] Swift from R!\",\"datePublished\":\"2021-01-23T22:09:18+00:00\",\"dateModified\":\"2021-01-25T14:04:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/\"},\"wordCount\":685,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"articleSection\":[\"macOS\",\"R\",\"Swift\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/\",\"name\":\"SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"datePublished\":\"2021-01-23T22:09:18+00:00\",\"dateModified\":\"2021-01-25T14:04:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/01\\\/23\\\/swiftr-switcheroo-calling-compiled-swift-from-r\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SwiftR Switcheroo: Calling [Compiled] Swift from R!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/","og_locale":"en_US","og_type":"article","og_title":"SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is","og_description":"I&#8217;ve been on a Swift + R bender for a while now, but have been envious of the pure macOS\/iOS (et al) folks who get to use Apple&#8217;s seriously ++good machine learning libraries, which are even more robust on the new M1 hardware (it&#8217;s cool having hardware components dedicated to improving the performance of built [&hellip;]","og_url":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/","og_site_name":"rud.is","article_published_time":"2021-01-23T22:09:18+00:00","article_modified_time":"2021-01-25T14:04:52+00:00","author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"SwiftR Switcheroo: Calling [Compiled] Swift from R!","datePublished":"2021-01-23T22:09:18+00:00","dateModified":"2021-01-25T14:04:52+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/"},"wordCount":685,"commentCount":5,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"articleSection":["macOS","R","Swift"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/","url":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/","name":"SwiftR Switcheroo: Calling [Compiled] Swift from R! - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"datePublished":"2021-01-23T22:09:18+00:00","dateModified":"2021-01-25T14:04:52+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2021\/01\/23\/swiftr-switcheroo-calling-compiled-swift-from-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"SwiftR Switcheroo: Calling [Compiled] Swift from R!"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p23idr-3lV","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":12866,"url":"https:\/\/rud.is\/b\/2021\/01\/04\/bringing-r-to-swift-on-macos\/","url_meta":{"origin":12891,"position":0},"title":"Bringing R to Swift on macOS","author":"hrbrmstr","date":"2021-01-04","format":false,"excerpt":"Over Christmas break I teased some screencaps: A more refined #rstats #swift \"SwiftR\" example. Simple Image view + some text views, a color picker and a button that runs R-in-Swift code (like {reticulate} does for Python in R)Note no ssd\/hd storage round-trip for the plot.Code snippet: https:\/\/t.co\/fWaHnztUgd pic.twitter.com\/y5m1I16tCB\u2014 Caliban's War\u2026","rel":"","context":"In &quot;Apple&quot;","block_context":{"text":"Apple","link":"https:\/\/rud.is\/b\/category\/apple\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12878,"url":"https:\/\/rud.is\/b\/2021\/01\/16\/new-swiftr-chapter-up-building-an-r-backed-swiftui-macos-app\/","url_meta":{"origin":12891,"position":1},"title":"New SwiftR Chapter Up: Building an R-backed SwiftUI macOS App","author":"hrbrmstr","date":"2021-01-16","format":false,"excerpt":"Last week I introduced a new bookdown series on how to embed R into a macOS Swift application. The initial chapters focused on core concepts and showed how to build a macOS compiled, binary command line application that uses embedded R for some functionality. This week, a new chapter is\u2026","rel":"","context":"In &quot;Apple&quot;","block_context":{"text":"Apple","link":"https:\/\/rud.is\/b\/category\/apple\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12645,"url":"https:\/\/rud.is\/b\/2020\/02\/06\/prying-r-script-files-away-from-xcode-et-al-on-macos\/","url_meta":{"origin":12891,"position":2},"title":"Prying &#8220;.R&#8221; Script Files Away from Xcode (et al) on macOS","author":"hrbrmstr","date":"2020-02-06","format":false,"excerpt":"As the maintainer of RSwitch --- and developer of my own (for personal use) macOS, iOS, watchOS, iPadOS and tvOS apps --- I need the full Apple Xcode install around (more R-focused macOS folk can get away with just the command-line tools being installed). As an Apple Developer who insanely\u2026","rel":"","context":"In &quot;macOS&quot;","block_context":{"text":"macOS","link":"https:\/\/rud.is\/b\/category\/macos\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12763,"url":"https:\/\/rud.is\/b\/2020\/05\/25\/rswitch-1-7-0-has-been-released\/","url_meta":{"origin":12891,"position":3},"title":"RSwitch 1.7.0 Has Been Released","author":"hrbrmstr","date":"2020-05-25","format":false,"excerpt":"I (and, apparently, Gandalf O_o) are pleased to announce that RSwitch version 1.7.0 has been released. (Direct Download) RSwitch is a macOS menubar utility that: makes it dead simple to manage multiple macOS R versions use the latest RStudio daily builds access remote RStudio Server sessions using in a purpose-built\u2026","rel":"","context":"In &quot;Apple&quot;","block_context":{"text":"Apple","link":"https:\/\/rud.is\/b\/category\/apple\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/05\/gandalf-rswitch.png?fit=480%2C280&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":12917,"url":"https:\/\/rud.is\/b\/2021\/01\/26\/making-it-easier-to-experiment-with-compiled-swift-code-in-r\/","url_meta":{"origin":12891,"position":4},"title":"Making It Easier To Experiment With Compiled Swift Code In R","author":"hrbrmstr","date":"2021-01-26","format":false,"excerpt":"The past two posts have (lightly) introduced how to use compiled Swift code in R, but they've involved a bunch of \"scary\" command line machinations and incantations. One feature of {Rcpp} I've always ? is the cppFunction() (\"r-lib\" zealots have a similar cpp11::cpp_function()) which lets one experiment with C[++] code\u2026","rel":"","context":"In &quot;macOS&quot;","block_context":{"text":"macOS","link":"https:\/\/rud.is\/b\/category\/macos\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":13039,"url":"https:\/\/rud.is\/b\/2021\/04\/24\/making-macos-universal-apps-with-universal-golang-static-libraries\/","url_meta":{"origin":12891,"position":5},"title":"Making macOS Universal Apps in Swift with Universal Golang Static Libraries","author":"hrbrmstr","date":"2021-04-24","format":false,"excerpt":"There are a plethora of amazingly useful Golang libraries, and it has been possible for quite some time to use Go libraries with Swift. The advent of the release of the new Apple Silicon\/M1\/arm64 architecture for macOS created the need for a new round of \"fat\"\/\"universal\" binaries and libraries to\u2026","rel":"","context":"In &quot;Go&quot;","block_context":{"text":"Go","link":"https:\/\/rud.is\/b\/category\/go\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=12891"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12891\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=12891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=12891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=12891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}