Stockfish Chess Engine Integration with iOS project in Swift

I am trying to integrate the Stockfish Chess Engine with an app written in Swift. The Stockfish iOS source code is open to all but it was written in Objective-C and the engine is in C++. I don't have issue with objective-c but can not seem to understand how it will work with Swift and is that possible at all. The Stockfish engine has no documentation and it is very difficult for me to grasp how it will be build in a Swift app especially when this is the first time fopr me trying something like that. Other people suggested to me I could try with cocoapods to expose the engine to the swift but I am bit lost here. If anyone has any suggestions for me that would be great. Thank you for your time!


What you really want here is a Swift implementation of the Universal Chess Interface protocol so that any compliant engine could be packaged up with CocoaPods (or Carthage, or SPM, ...) and dropped into any compliant Swift app. That's probably what the people who suggested you try with CocoaPods were thinking.

For the less ambitious task of just getting some Objective-C code linking with Swift, yes that is absolutely possible, you need what's called a "Bridging Header" to expose the Objective-C code to Swift. The complete details are in a free book you can download to iBooks:

Using Swift with Cocoa and Objective-C

This documentation is also online at Apple, here's a direct link to the immediately relevant part:

To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app...

This process generally Just Works™. If not, search for "bridging header" and you should find lots of appropriate discussion!

链接地址: http://www.djcxy.com/p/84656.html

上一篇: 如何推断受配偶评价影响的一面

下一篇: 在斯威夫特干邑国际象棋引擎与iOS项目集成