2

I was wondering if someone knows a workaround around this bug in XCode

I have a mix and match Obj C / Swift project.

Always when I am changing the target and then build the project I get errors in the file XXX-Swift.h regarding duplicate interfaces and previous declarations.

Then I have to clean and build again in order for it to work.

Any help appreciated.

1 Answers1

0

I'm not sure exactly what is the sequence of events that leads to the errors, but I'm guessing that you are making changes to 'XXX-Swift.h'. This file is generated by Xcode and you should not make changes to it. (Although I would expect Xcode to just re-create it and discard your changes, rather then throwing errors).

Can you show the errors?

Joride
  • 3,722
  • 18
  • 22
  • I´m not changing that file. Basically all the errors are: - Property has a previous declaration - Duplicate interface definition for class 'MyClass' - And finally 'Too many errors emitted, stopping now' My guess is that the Swift classes need to be converted again to Obj C code when I change targets and therefore it only works when I clean and build after changing targets. Hopefully this will get fixed in later versions. – Tomas Gudmundsson May 03 '16 at 17:55
  • What do you mean with "changing the target". Also I think xcode shows you the option to unfold the error, and I think it will tell you something like 'previous devlaration found here'. Otherwise you can search for it. Can you show the line where the error occurs and the results of a search for the same method? – Joride May 03 '16 at 19:08
  • Changing the target in the target dropdown menu right next to the build and run button in the top left corner in XCode. The errors are all in the XXX-Swift.h file. It's probably because XCode does not delete the old file when I build and creates a new XXX-Swift.h file and then complains about duplicate interfaces and previous declarations in that file. – Tomas Gudmundsson May 04 '16 at 10:14
  • Do you mean the Schemes dropdown, or the simulator/device dropdown? Changing the scheme results in a build in its own folder, so I would not expect problems. Changing the simulator/device might affect the build architecture, but this also lives in its own folder. Maybe you should check the actual location of the -Swift.h file, see if it is in the same location, and see if there are actual difference. Who knows, maybe some Xcode cache is misbehaving. In that case, you should file a bug with Apple. – Joride May 04 '16 at 10:41