问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/24043240/is-it-possible-to-import-third-party-objective-c-code-into-a-swift-playground