0

I am developing iOS application in objective c I want to use swift file in this application but when I run the application I get the fallowing error:

The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

user9713861
  • 73
  • 2
  • 7
  • Isnt error clear enough? Go to every single target in your project, click on build settings and in search field on top right corner type Swift Language you will see option for selecting swift language to be used for the selected target, for all targets select the same swift version whichever you wanna support – Sandeep Bhandari Jul 30 '18 at 07:40
  • thanks I did what told me , but when run I get this error : :0: error: generate-pch command failed with exit code 1 (use -v to see invocation) Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 – user9713861 Jul 30 '18 at 07:43
  • Command + Shift + K clean the build and re-run. If that does not work then, go to Xcode preferences, select location tab, click on small arrow next to derived data, it will open derive data in finder, delete the derive data folder and restart the Xcode that should solve your problem, – Sandeep Bhandari Jul 30 '18 at 07:45
  • what else I will do like Bridging-Header how to add – user9713861 Jul 30 '18 at 07:53
  • If you want to run Objective-C code in Swift project you need Bridging header, in order to run swift code in Objective-C you need Project.Swift file imported in your Objective-C file !!! What exactly is you need ?? – Sandeep Bhandari Jul 30 '18 at 07:57

1 Answers1

1

The error is pretty clear.

  • In the project navigator select the (blue) project
  • Select the target which uses Swift
  • Click on Build Settings
  • Scroll down to Swift Language Version or in the search field type Swift L
  • In the popup of the setting select the language version
vadian
  • 274,689
  • 30
  • 353
  • 361
  • what else I will do like Bridging-Header how to add – user9713861 Jul 30 '18 at 07:48
  • 1
    You need the bridging header only if you want to run Obj-C code in a Swift target. To add a bridging header manually please see https://stackoverflow.com/questions/31716413/xcode-not-automatically-creating-bridging-header – vadian Jul 30 '18 at 07:56