{"id":4303,"date":"2020-11-24T08:53:39","date_gmt":"2020-11-24T14:53:39","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=4303"},"modified":"2020-11-24T08:53:39","modified_gmt":"2020-11-24T14:53:39","slug":"detecting-macos-universal-binaries","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/detecting-macos-universal-binaries\/","title":{"rendered":"Detecting macOS Universal Binaries"},"content":{"rendered":"<p>Apple has transitioned from different <a href=\"https:\/\/en.wikipedia.org\/wiki\/Instruction_set_architecture\">instruction set architectures<\/a> several times now throughout its history.  First, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mac_68k_emulator\">from 680&#215;0 to PowerPC<\/a>, then <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mac_transition_to_Intel_processors\">from PowerPC to Intel x86<\/a>.<br \/>\nAnd now, in 2020 from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mac_transition_to_Apple_Silicon\">Intel to ARM<\/a>.<\/p>\n<p>During the first transition 680&#215;0 code ran in an emulator.  In subsequent transitions Apple has utilized the translation application <a href=\"https:\/\/en.wikipedia.org\/wiki\/Rosetta_(software)\">Rosetta<\/a>.  From Apple&#8217;s documentation, &#8220;Rosetta is meant to ease the transition to Apple silicon, giving you time to create a universal binary for your app. It is not a substitute for creating a native version of your app.&#8221;<\/p>\n<p>So, how can you tell if an application is already a &#8220;universal binary&#8221; that provides both x86 and ARM instructions?  Open <a href=\"https:\/\/en.wikipedia.org\/wiki\/Terminal_(macOS)\">Terminal<\/a> and find the application&#8217;s executable code.  For standard macOS applications it is located in <code>\/Applications\/Application.app\/Contents\/MacOS\/<\/code>.  For example, Safari&#8217;s executable is at <code>\/Applications\/Safari.app\/Contents\/MacOS\/Safari<\/code>. Now, we&#8217;re going to use the <a href=\"https:\/\/en.wikipedia.org\/wiki\/File_(command)\">file<\/a> Unix command to give us information as to the contents.<\/p>\n<p>[code lang=text]<br \/>\n% file \/Applications\/Safari.app\/Contents\/MacOS\/Safari<br \/>\nSafari.app\/Contents\/MacOS\/Safari: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]<br \/>\nSafari.app\/Contents\/MacOS\/Safari (for architecture x86_64): Mach-O 64-bit executable x86_64<br \/>\nSafari.app\/Contents\/MacOS\/Safari (for architecture arm64e): Mach-O 64-bit executable arm64e<br \/>\n[\/code]<\/p>\n<p>From this you can see that the <code>Safari<\/code> binary contains executable code for both the <code>x86_64<\/code> (Intel) architecture and <code>arm64e<\/code> (ARM).<\/p>\n<p>As of this writing, November 24, 2020, a few notable applications that are already shipping universal binaries, such as <a href=\"https:\/\/www.google.com\/chrome\/\">Google Chrome<\/a> and <a href=\"https:\/\/iterm2.com\">iTerm2<\/a>.  Of course, Apple&#8217;s flagship applications such as Safari, Xcode, Numbers, etc. all support the new ARM instruction set.<\/p>\n<p>I&#8217;ve written a quick Ruby script to iterate through the executables in <code>\/Applications<\/code>.  To run on your machine:<\/p>\n<p>[code lang=text]<br \/>\n\/usr\/bin\/ruby -e &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/iachievedit\/detectUniversalBinary\/main\/detectUniversalBinary.rb)&quot;<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/detectUniversalBinary.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/detectUniversalBinary.png\" alt=\"\" width=\"583\" height=\"294\" class=\"aligncenter size-full wp-image-4315\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apple has transitioned from different instruction set architectures several times now throughout its history. First, from 680&#215;0 to PowerPC, then from PowerPC to Intel x86. And now, in 2020 from Intel to ARM. During the first transition 680&#215;0 code ran in an emulator. In subsequent transitions Apple has utilized the translation application Rosetta. From Apple&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,99],"tags":[],"class_list":["post-4303","post","type-post","status-publish","format-standard","hentry","category-apple","category-arm"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4303"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=4303"}],"version-history":[{"count":7,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4303\/revisions"}],"predecessor-version":[{"id":4318,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4303\/revisions\/4318"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=4303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=4303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=4303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}