cloudinary / cloudinary_ios

Cloudinary iOS SDK
MIT License
166 stars 106 forks source link

Error: `method '...' not exposed to Objective-C` #391

Closed robingenz closed 1 year ago

robingenz commented 1 year ago

Bug report for Cloudinary iOS SDK

Describe the bug in a sentence or two.

I want to use the Cloudinary iOS SDK in a project where I need to export my Swift class to Objective-C (Read more). Unfortunately, I get the following two errors in Pods/Cloudinary/ios/CLDCropView.swift when building the project:

Argument of '#selector' refers to instance method 'gridPanGestureRecognized' that is not exposed to Objective-C

Add '@objc' to expose this instance method to Objective-C
Argument of '#selector' refers to instance method 'timerTriggered()' that is not exposed to Objective-C

Add '@objc' to expose this instance method to Objective-C

Issue Type (Can be multiple)

[x] Build - Can’t install or import the SDK [ ] Performance - Performance issues [ ] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)

Steps to reproduce

The project is open source: https://github.com/capawesome-team/capacitor-cloudinary/tree/main/ios You can just try to build the project.

Error screenshots or Stack Trace (if applicable)

grafik

Build/Dependency management

[x] Cocoa-Pods [ ] Carthage [ ] Manual import [ ] Other (Specify)

Is the issue reproducible only on a specific device?

[x] No [ ] Yes (specify model + iOS version)

Versions and Libraries (fill in the version numbers)

iOS Cloudinary SDK version - 3.3.0 OSX (on the dev environment) - 12.6 XCode - 14.1 Swift - 5.1 Target iOS - 13.0

michalkcloudinay commented 1 year ago

Hi @robingenz,

I see you opened a direct ticket to our support team, we will further discuss this on that thread.

Thanks

robingenz commented 1 year ago

Hi @michalkcloudinay, thank you for your response. It would be great if we could discuss this here so that it is transparent to the open source community. I know a few people in the Capacitor community are following this issue.

Regarding your mail: I am aware that this is a native SDK. How this SDK is then called from the WebView is handled by Capacitor. We can ignore that for now. I only mentioned Capacitor to give some context. However, this requires that I can convert my Swift class to Objective-C and that's not working right now.

According to Cloudinary documentation this should be supported though, see: grafik and grafik

michalkcloudinay commented 1 year ago

Hi @robingenz, Sure, we can continue the discussion here. We are further checking this internally and I will update here once I have new insights. Thanks

michalkcloudinay commented 1 year ago

Hi @robingenz, We have tested the latest version of our SDK with an Objective-C project and it worked correctly without any errors. We are not familiar with CapacitorJS, but this might be related to the way you are exporting the Swift class to Objective-C. If you can provide the steps you are doing to export the files to Objective-C, we can try and reproduce on our end.

Looking forward to your updates

robingenz commented 1 year ago

Hi @michalkcloudinay, Capacitor is just another SDK (pod) in the XCode project and has no influence on the build process. I use normal @objc attributes (read more here) that tell XCode to export the Code not only as Swift code but also as Objective-C code. It seems that only certain parts of the Cloudinary SDK are affected where this is lacking compatibility.

Please use my provided example for testing so you can reproduce the issue:

$ git clone https://github.com/capawesome-team/capacitor-cloudinary.git
$ npm install
$ cd ios
$ pod install
$ open Plugin.xcworkspace

Now when you build the project in Xcode, you get the build error.

atdcloud commented 1 year ago

Hi @robingenz, I followed the steps but I was able to build the project successfully: https://tdatu-res.cloudinary.com/video/upload/v1669753413/ios/ciggqzvexocie3s2ljrp.mp4

Perhaps re-clone the repo again, redo the steps but add npm install | tee -a install-steps.log and pod install | tee -a ../install-steps.log? This should save the normal output in install-steps.log file where we can check if any of the depencies were properly installed.

Regards, Anthony

robingenz commented 1 year ago

@atdcloud Thank you for your help! It was actually a local problem. After running the following it worked:

pod cache clean 'Cloudinary' --all
pod install

Unfortunately, I don't know how this could happen, since I installed the Cloudinary pod for the first time with version 3.3.0. Either way, thanks to you both for your help!

atdcloud commented 1 year ago

@robingenz Thanks for the update and sharing your solutions here! Glad everything is OK now.