Value for SWIFT_VERSION cannot be empty

Viewed 52616

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.

8 Answers

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

enter image description here

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

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

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

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.

If you are using Ionic with Cordova and you got here because of this error do this:

In your config.xml add

<platform name="ios">
        <preference name="UseSwiftLanguageVersion" value="5" />

You may need to remove the resource for ios and re-add it to make it work.

cordova platform remove ios
cordova platform add ios

Cheers!

I use circle ci to run tests and generate app previews on testFlight I was having this issue and was able to fix this issue by setting the SWIFT_VERSION under ios/{your_project_name}.xcodeproj/project.pcxproj.

  1. Search for SWIFT_VERSION under this file and COPY IT
    13B07F941A680F5B00A75B9A /* Debug */ = {
            isa = XCBuildConfiguration;
            baseConfigurationReference = 8F6A6E403A1DCB019B5AB844 /* Pods-heartland_charter_s_34954.debug.xcconfig */;
            buildSettings = {
                ...
                PRODUCT_NAME = heartland_charter_s_34954;
                SWIFT_OPTIMIZATION_LEVEL = "-Onone";
                SWIFT_VERSION = 5.0; // Copy this line
                ...
            };
            name = Debug;
        };
  1. Search for PRODUCT_NAME and paste the SWIFT_VERSION just under each PRODUCT_NAME block, provided that it is not already there
        13B07F951A680F5B00A75B9A /* Release */ = {
            isa = XCBuildConfiguration;
            baseConfigurationReference = CF85766339BED655A366B986 /* Pods-heartland_charter_s_34954.release.xcconfig */;
            buildSettings = {
                ...
                PRODUCT_NAME = "$(TARGET_NAME)";
                SWIFT_VERSION = 5.0; // Add it here
                ...
            };
            name = Release;
        };
  1. pod install and re run the app

For a Cordova app add the following line in config.xml

<preference name="SwiftVersion" value="5.3"/>
Related