4

This is my first IOS application and all has gone well up to this point. My code is in Swift and I need to use the Gold Raccoon FTP library, which is in Obj-C, in my application: https://github.com/albertodebortoli/GoldRaccoon

I imported the Gold Raccoon files and created the bridge header. The main class you work with is the GRRequestsManager, which I can successfully instantiate in a running app. I cannot however access the addRequestForUploadFileAtLocalPath method in that class.

I initially just had the GRRequestsManager.h import statement in the bridge file. Since that inherits GRRequestsManagerProtocol.h that has the actual method I'm trying to use defined in it (addRequestForUploadFileAtLocalPath), I decided to add that to my bridge header file and lo and behold all of a sudden auto suggest popped up for the method and I could put it in my code with no errors. A few minutes later I got an error message again and it won't work now no matter what. I've tried closing and reopening Xcode and cleaning/rebuilding to no avail.

Below is a combined image (can only post 1 image due to my points) showing first the bridging-header and second (separated by the red line) the error in the code where I'm trying to call the method. You can see it recognized the class just fine.

Screenshots

quant24
  • 393
  • 6
  • 22
DannyP
  • 200
  • 2
  • 10
  • Add the declaration of `addRequestForUploadFileAtLocalPath` to your question. – David Berry Mar 03 '16 at 18:19
  • This is its declaration in the GRRequestsManagerProtocol.h file: http://imgur.com/3XKOlhV and this is its implementation in the GRRequestsManager.m file: http://imgur.com/djpACLw – DannyP Mar 03 '16 at 18:48

1 Answers1

4

Well I went ahead and added an include to every single header file in the Gold Raccoon library to my bridging header and now the method is recognized and my code compiles! I'm still not too sure why I needed to do that but it did the trick. If anyone cares to explain the why I would love to understand it.

DannyP
  • 200
  • 2
  • 10
  • When you're programming in Objective-C, you `#import` in you app's `.m` file whatever headers you need, so the pattern is the same in Swift, you have to explicitly `#import` those same `.h` files in the bridging header. Whether you include _all_ the header files, or just key ones, is a function of how Gold Racoon was designed, but their documentation should make it clear which you need to import. – Rob Mar 03 '16 at 20:25
  • Thanks Rob. According to the documentation for Gold Raccoon and even in the obj-C demo app for it you should just need to include GRRequestsManager.h (and include the CFNetwork framework). It's been over a decade since I seriously wrote C and C++ but that was my recollection as well. I'm thinking there just may be some issues in how things are resolved with the bridge file in play, especially since it worked momentarily without me adding references to everything. – DannyP Mar 03 '16 at 20:44