{"id":3707,"date":"2019-02-24T15:05:08","date_gmt":"2019-02-24T21:05:08","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=3707"},"modified":"2019-02-24T15:05:08","modified_gmt":"2019-02-24T21:05:08","slug":"fixing-a-module-compiled-cannot-be-imported-errors","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/fixing-a-module-compiled-cannot-be-imported-errors\/","title":{"rendered":"Fixing A Module Compiled Cannot Be Imported Errors"},"content":{"rendered":"<p>This was an annoying error message the first time I ran into it.  I had just downloaded Xcode 10.2 beta 2 and opened a project I had been working on in Xcode 10.1 and was greeted by <code>Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler.<\/code>  After a bit of searching I realized that I needed to rebuild my <a href=\"https:\/\/github.com\/Carthage\/Carthage\">Carthage<\/a> modules, and had forgotten that <code>xcode-select<\/code> needed to be employed as well.<\/p>\n<p>So if you run into this like I did, the fix is simple.  Choose which Xcode you need to work with and then use <code>xcode-select<\/code> to choose it for commandline builds and run <code>carthage update<\/code>.<\/p>\n<p>For example, if I need to switch to the beta version of Xcode:<\/p>\n<p>[code lang=text]<br \/>\nsudo xcode-select -s \/Applications\/Xcode.app<br \/>\ncarthage update<br \/>\n[\/code]<\/p>\n<p>I include a nice <code>Makefile<\/code> in my projects that streamlines switching back and forth:<\/p>\n<pre class=\"theme:classic toolbar-overlay:false striped:false marking:false nums:false lang:default decode:true \" >PHONY: xcode xcode-beta\n\nxcode:\n        sudo xcode-select -s \/Applications\/Xcode.app\n        carthage update --platform ios\n\nxcode-beta:\n        sudo xcode-select -s \/Applications\/Xcode-beta.app\n        carthage update --platform ios<\/pre>\n<p>If I need to switch to using Xcode-beta (which I frequently do since my phone is usually running a beta build), I can just type <code>make xcode-beta<\/code>.<\/p>\n<p>Now, of course, when I open my project back up in <code>Xcode<\/code> I get <code>Module compiled with Swift 5.0 cannot be imported by the Swift 4.2.1 compiler.<\/code>, but that&#8217;s okay, a simple <code>make xcode<\/code> will get me going!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This was an annoying error message the first time I ran into it. I had just downloaded Xcode 10.2 beta 2 and opened a project I had been working on in Xcode 10.1 and was greeted by Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler. After a bit of searching [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[86],"class_list":["post-3707","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xcodetips","tag-swift-module-compiled-imported-error"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3707"}],"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=3707"}],"version-history":[{"count":6,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3707\/revisions"}],"predecessor-version":[{"id":3716,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3707\/revisions\/3716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media\/3108"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=3707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=3707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=3707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}