65

I have installed swift pods for the obj c project. I got this error when I was trying to build it.

enter image description here

I have gone through all the solutions like deleting derived data, cleaning the build folder. Swift Compiler_Language also missing in the XCode 10. Added user-defined setting too, even it didn't work.

Kalle Richter
  • 7,146
  • 22
  • 65
  • 152
Kumaraprasad
  • 653
  • 1
  • 5
  • 6
  • 1
    In case you got here after adding a Core Data model to an Objective-C project: https://stackoverflow.com/a/54763481/74118 – nevan king Feb 19 '19 at 10:03

5 Answers5

95

Select your app target then goto build setting, search for swift set the swift language version from the dropdown.

enter image description here

Ratul Sharker
  • 6,821
  • 2
  • 31
  • 41
  • 1
    There is no option of SWIFT COMPILER -LANGUAGE in Xcode 10. That is the issue. Is there any solution to fix? – Kumaraprasad Oct 24 '18 at 05:15
  • i thought you we're right and xcode 10 removed the `Swift Language Version` option, this only available to older version. So i created a new iOS Project but found the `Swift Language Version` in that project. Make sure you select the correct target and goto the `Build settings` tab and search for `swift lan` it will show up. – Ratul Sharker Oct 24 '18 at 05:25
  • It didn't work. I have created a new project and followed the rest of the procedure. Still, no options...:( – Kumaraprasad Oct 24 '18 at 05:48
  • Could you please share a screenshot what you get in `Build Setting` while opening a new project and searched for `swift lan`. Please share the exact xcode 10 version. – Ratul Sharker Oct 24 '18 at 05:53
  • Please check the attached screenshot. – Kumaraprasad Oct 24 '18 at 06:06
  • 2
    Select the mother project's target, not the `Pods` target. By mother project i mean the project which included this pods as dependency – Ratul Sharker Oct 24 '18 at 06:09
  • Yes. Working. Thank you so much.:) – Kumaraprasad Oct 24 '18 at 06:57
  • Strange, in a Flutter iOS project, the swift version is available in Pods target build settings for Xcode 10. – Vijay Kumar Kanta Nov 07 '18 at 02:16
30

In case there is anybody else reading through this thread who has this same problem but was unable to solve it using the above answers, this may help:

If you have a data model, you need to check that when you click on the data model, click on an entity, and bring up the file inspector, the "Code Generation" Language is properly set. In my case my whole app was written Objective-C, but was set here to Swift for some reason. This is another reason that Error will show up in the Issue Navigator.

It's very important to clear the build folder after changing Code Generation Language. This can be done by pressing Command-Shift-K or by clicking Product->Clean Build Folder in the menu at the top of the screen.

Check out this link for a picture of where to find the "Code Generation" option I'm talking about.

Model.xcdatamodeld->File Inspector->Code Generation

Io-oI
  • 2,386
  • 3
  • 17
  • 25
BMPatterson
  • 421
  • 4
  • 6
  • Thank you, @bmpatterson this was the answer for me :) – mgyky Jul 11 '19 at 11:52
  • Perfect, thanks: This happened to me after adding a new model to Objective-C project, before even generating the code for entity objects. Lost hours. Glad I read down this far. – Henry95 Oct 07 '19 at 10:32
  • tyvm! This was the reason that I was having the build error! – sang Dec 31 '19 at 15:50
  • This is a proof Swift ruined Apple development joy and coherency. Swift introduction created tons of Xcode new problems, incoherencies, needed tweaks. Thanks for this one I would never have found this myself! – Altimac May 29 '20 at 12:12
  • Glad to see it's helped a few people! – BMPatterson Jul 07 '20 at 04:47
7

Update for Xcode 10.2

  1. Go to --> Build Setting

  2. Select All + Combined or All + Levels underneath the Build Settings

  3. And Finally on the search bar, on the right hand side search for "Swift Language Version"

as you see in the image worked for me

3

You need to search for every "PRODUCT_NAME =" There needs to be a " SWIFT_VERSION = "4.2"; " after everyone. eg. also PRODUCT_NAME = "$(TARGET_NAME)";enter code here

  • Please read [How to answer](https://stackoverflow.com/help/how-to-answer) and update your answer with guidelines from the guide. – fartem Feb 04 '21 at 04:54
1

Still, after all of that, if you're still at lost, you can add a SWIFT_VERSION directly the project file:

        80B11AAAAAAAAAAAAAAAC3E5D8 /* Debug */ = {
        isa = XCBuildConfiguration;
        baseConfigurationReference = DF5...040;
        buildSettings = {
            ...
            PRODUCT_MODULE_NAME = react-native-some-module;
            ...
            SWIFT_VERSION = "4.2";
        };
        name = Debug;
    };

Repeat for both the Debug and Release targets. That had me hop over this issue.

Patrice Gagnon
  • 1,126
  • 12
  • 14