so I have an SDK written in swift that overrides WKWebView delegation to check SSL certificates/security measure.
and I want to use it on my Objective-C project :
The delegation works as intended, but when try to execute didFailNavigation, it crashes... but when I try to use it on a swift project, it works perfectly. do you guys know why this happening in objective-c?
And one more question, in swift I can do the like this
self.webView?.navigationDelegate = safeWebDelegate.wkWebDelegate as? WKNavigationDelegate
but in iOS I cannot do :
self.webView.navigationDelegate = (WKNavigationDelegate *)safeWebDelegate.wkWebDelegate;
it says that WKNavigationDelegate not found. Is there any workaround on this? Thanks
Related
I have an existing Objective-C app and have developed a SwiftUI iOS 14 Widget for it. So far so good. Now I am trying to reload the timeline from my Objective-C app. I understand that there are no Objective-C api for accessing WidgetCenter, so I have implemented the bridging steps outlined in Apple's documentation (at least I think I have since I am totally new to Swift). I cannot seem to be able to get Widget Center nor WidgetCenter.shared.reloadAllTimelines()recognized in my Objective-C app. I have tried many approaches with no success, so I must be doing something wrong. Any help or suggestions would be greatly appreciated.
I faced with the same issue. The solution for this was to create a swift file for example: WidgetKitHelper. Create the assigned swift-objc header with that too (bridging header file) if it not generated automatically you can add it by manually (search for it).
In the helper object you can get access to widgetkit, and if you do the rest to be able to see the swift code from your objc code, you can use this as a wrapper.
Tips:
import WidgetKit
#available(iOS 14.0, *)
#objcMembers final class WidgetKitHelper: NSObject {
class func reloadAllWidgets(){
#if arch(arm64) || arch(i386) || arch(x86_64)
WidgetCenter.shared.reloadAllTimelines()
#endif
}
}
obj-c code:
First import the swift code by adding:
#import "YourProjectName-Swift.h"
Then you can use:
[WidgetKitHelper reloadAllWidgets];
I have a swift native module, which i have written in Swift 4.2, Now i have updated my xcode, and it is breaking my code with error
Swift class extensions and categories on Swift classes are not allowed
to have +load methods
If i am not exporting my module its working fine, But if i am exporting my module with #interface RCT_EXTERN_MODULE(MFobSDK, NSObject)
its breacking my Code. If anyone have any idea why its happening please let me know.
Had the same issue.
If you will notice , when you run the app on a real device it will work fine.
The problem is in the pods, do pod update.
I have changed from Obj-c to swift. However in my view controller identity inspector, only Obj-c files are available when I try to set the custom class.
Any ideas how to get the Swift files to appear?
My issue was that my class was a subclass of UIViewController despite it being a UITableView. Changing this in the class worked.
I am working in a mixed ObjC Swift project. I am currently overriding functions that where written in ObjC in a swift subclass. I'm wondering if there is a quick way to view the auto generated Swift header files for the objC file so that I can check the syntax of functions after they have been converted to swift.
I'm wondering if there is a quick way to view the auto generated Swift header files for the objC
Switch to the Generated Interface in the first menu of the jump bar.
Example: before:
after:
I am trying to utilize UIWebView functionality, specifically I want to do something like this: Open links in Safari instead of UIWebVIew?
But I am having an issue when I try and add the UIWebViewDelegate to my AppDelegate interface.
Anyone know what the issue is? Note this is Mac OS not iOS.
Add:
#import <UIKit/UIKit.h>
Anyone know what the issue is? Note this is Mac OS not iOS.
That's the issue right there.
There is no UIWebView or UIWebViewDelegate on MacOS X. UI is the prefix for UIKit, which is the iOS equivalent of AppKit. When you see a class whose name begins with UI, you know immediately that you're looking at iOS code.
The class you're probably looking for is WebView. WebView actually uses five separate delegates, so you may need to implement as many as five different protocols: WebUIDelegate, WebDownload, WebFrameLoadDelegate, WebPolicyDelegate, and WebResourceLoadDelegate. (In reality, I don't think you need to do quite that much work. For example, you may not need to implement your own access policy.)
UIWebView is iOS only. You cannot use a UIWebViewDelegate for Mac OSX. If you look at your own code, you are using a WebView, not a UIWebView.
You'll want to look at the WebView class docs