11

As suggested here I've been able to import my existing Objective-C code into a .swift file via the bridging header. As of yet I've been unable to do something similar with a swift playground - it does not seem to recognise the header in the same way that a swift file does.

Interestingly, and possibly suggestive of a negative to my question is that playgrounds do not appear to share the concept of target membership like .swift/.m

Anyone had any success with this or perhaps a different mechanism?

Michael
  • 2,258
  • 1
  • 23
  • 31

1 Answers1

4

See Using Swift with Cocoa and Objective-C for how to set up an Xcode project for importing Swift into Objective-C. Then create a playground in that project and the playground should be able to work with any of the ObjC classes in the project.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Unfortunately, see the response here: https://devforums.apple.com/thread/227949?tstart=0 – Brad Larson Jun 05 '14 at 15:59
  • Ah well, that's what I get for parroting what I hear in the labs. :) [File bugs](http://bugreport.apple.com) and stay tuned, I guess. – rickster Jun 05 '14 at 16:19
  • 1
    @CameronLowellPalmer - It was to a now-obsolete discussion on Apple's old forums about how this wasn't quite possible yet. The duplicate question linked above has more recent and relevant information. – Brad Larson Feb 14 '18 at 15:11