Code Diagnostics

Enable runtime checks to detect and avoid bugs in your code using Code Diagnostics.

Code Diagnostics Documentation

Posts under Code Diagnostics tag

31 results found
Post marked as unsolved
38 Views

Cannot find 'application' in scope

i get 2 of these errors ""Cannot find 'application' in scope"" what am i doing wrong or why is it not in scope? // // ViewController.swift // Diabell App // // Created by Richard Klug on 23/04/2021. // import UIKit import MessageUI class ViewController: UIViewController, MFMailComposeViewControllerDelegate {  override func viewDidLoad() {   super.viewDidLoad()   // Do any additional setup after loading the view.  }     //Function Email Bottom Left     @IBAction func Mail(_ sender: Any) {   showMailComposer()  }     func showMailComposer() {    guard MFMailComposeViewController.canSendMail() else{     return    }    let composer = MFMailComposeViewController()    composer.mailComposeDelegate = self    composer.setToRecipients(["richard.klug@diabell.se"])    composer.setSubject("Diabell App Help")    composer.setMessageBody("Fyll i vad du behöver hjälp med", isHTML: false)    present(composer, animated: true)  }      //Funktion Call Bottom Right       @IBAction func btnCallClick(_ sender: UIButton) {     if let phoneURL = URL(string: "tel://+46706106310"){       if application.canOpenUrl(phoneURL){         application.open(phoneURL, [:], completionHandler: nil)       }else{       }   }    } }
Asked
Last updated .
Post marked as solved
72 Views

how to resolve Cannot find 'XXXX' in scope

Hi im new at developing and i got 2 errors i can't seem to find an answer on google. here is my code and the errors are Cannot find 'self' in scope Cannot find 'present' in scope // // ViewController.swift // Diabell // // Created by Richard Klug on 14/04/2021. // import UIKit import MessageUI class ViewController: UIViewController {   override func viewDidLoad() {     super.viewDidLoad()     // Do any additional setup after loading the view.   }       @IBAction func emailbButtonTapped( sender: Any) {    showMailComposer()   } }   func showMailComposer() {     guard MFMailComposeViewController.canSendMail() else{       return     }     let composer = MFMailComposeViewController()     composer.mailComposeDelegate = self     composer.setToRecipients(["richard.klug@diabell.se"])     composer.setSubject("Diabell App Help")     composer.setMessageBody("Fyll i vad du behöver hjälp med", isHTML: false)     present(composer, animated: true)       }   extension ViewController: MFMailComposeViewControllerDelegate {     func mailComposeController( controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {       if let _ = error {         controller.dismiss(animated: true)         return       }       switch result {       case .cancelled:         print ("Cancelled")       case .failed:         print ("Failed to send")       case .saved:         print ("Saved")       case .sent:         print ("Email Sent")       }       controller.dismiss(animated: true)     } }
Asked
Last updated .
Post marked as unsolved
42 Views

How can I replace a UIViewController with a SwiftUI View?

I am trying to incorporate some SwiftUI into my UIKit based iPhone application. I have a view controller in my Storyboard called ‘SellingNewsViewController’ with an associated “.swift” file. In this “SellingNewsViewController.swift" file, I am using the following code to try and create a UIHostingController to show the SwiftUI code I currently have in another file called “ContentView.swift”. class SellingNewsViewController: UIViewController {     override func viewDidLoad() {         super.viewDidLoad() let controller = UIHostingController(rootView: ContentView())         self.addChild(controller)         self.view.addSubview(controller.view)         controller.didMove(toParent: self)     } And I have a SwiftUI file in this directory (the code I am trying to run) named ‘ContentView.swift’ which has the following Syntax: import SwiftUI import SwiftyJSON import SDWebImageSwiftUI import WebKit struct ContentView: View {     @ObservedObject var list = getData()     var body: some View {         NavigationView{             List(list.datas){i in             NavigationLink(destination:                 webView(url: i.url)                                 .navigationBarTitle("", displayMode: .inline)){                     HStack(spacing: 15){                       VStack(alignment: .leading, spacing: 10){                             Text(i.title).fontWeight(.heavy)                             Text(i.desc)                         }                         if i.image != "" {                             WebImage(url: URL(string: i.image)!, options: .highPriority, context: nil)                                 .resizable()                                 .frame(width: 110, height: 135)                                 .cornerRadius(20).lineLimit(2)                         }                     }.padding(.vertical, 15)                 }             }.navigationBarTitle("Headlines")         }     } } struct ChildHostingController_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct dataType : Identifiable {     var id : String     var title : String     var desc : String     var url : String     var image : String } class getData : ObservableObject{     @Published var datas = [dataType]()     init() {         let source = "https://newsapi.org/v2/top-headlines?country=gb&category=business&apiKey=mykeyishere"         let url = URL(string: source)!         let session = URLSession(configuration: .default)         session.dataTask(with: url) { (data, _, err) in             if err != nil{                 print((err?.localizedDescription)!)                 return             }       let json = try! JSON(data: data!)             for i in json["articles"] {                 let title = i.1["title"].stringValue                 let description = i.1["description"].stringValue                 let url = i.1["url"].stringValue                 let image = i.1["urlToImage"].stringValue                 let id = i.1["publishedAt"].stringValue                 DispatchQueue.main.async {                     self.datas.append(dataType(id: id, title: title, desc: description, url: url, image: image))                 }             }         }.resume()     } } struct webView : UIViewRepresentable { var url : String     func makeUIView(context: UIViewRepresentableContextwebView) - WKWebView{         let view = WKWebView()         view.load(URLRequest(url: URL(string: url)!))         return view     }     func updateUIView(_ uiView: WKWebView, context: UIViewRepresentableContextwebView) {     } } I understand that I need to use a UIHostingController to show SwiftUI views in my UIKit application, however whenever I load up my ‘SellingNewsViewController’, I just receive a blank screen, as shown here - h ttps://imgur.com/a/GlyWV9i Am I doing something wrong to try and create/show the UIHostingController? 
Asked
Last updated .
Post marked as unsolved
30 Views

URL returns nil for all url

URL returns nil for all url. I have tried many method but it persist same; let url : URL! = "https://soop. asia any url".
Asked
by Ganesan.
Last updated .
Post marked as unsolved
84 Views

Virtual Memory in Big Sur

Is there a new way in Big Sur, running on an M1, to enable and utilize large memory pages? I've done a lot of searching on the internet and many tests, but haven't been able to figure it out. Closest I've come to insight is thinking there might be a conflict with JIT preventing the usage of it? This is what used to work in C++: void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0); Also tried: void *p = mmap((void *) 0x000200000000, 8 * 1024 * 1024, PROT_READ | PROT_WRITE, MAP_ANON | MAP_FIXED | MAP_PRIVATE, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0); Maybe there's an alternative way to accomplish Huge pages.
Asked
by rovodean.
Last updated .
Post marked as unsolved
44 Views

when linking C/C++ pre written library, only part of the structure not available

I have included FWLIB64.H library included in swift project with bridging file. Most of the functions & structures works correctly. So far on Two occasions when variable of Structure created. Only root level variable accessible, Sub structure variable not accessible. Example of Structure: typedef struct odbsinfo { long sramnum; /* Number of S-RAM data */ struct { char sramname[12]; /* S-RAM data Name */ long sramsize; /* S-RAM data Size */ short divnumber; /* Division number of S-RAM file */ char fname[6][16]; /* S-RAM file names */ } info[8]; } ODBSINFO; If I create variable abc = ODBSINFO() when I access the abc.sramnum work. But abc.info.sramname is not available. lots of other structure with sub structure is no problem. Can someone share there experience please. Thank you
Asked
by icnc313.
Last updated .
Post marked as unsolved
34 Views

Redirection to app from SSO login stoped working

We have hybrid app developed using cordova. Our app is "Swift Enterprise" available on apple store. We have functionality of SSO login which we are achieving using InAppBrowser plugin. Earlier it was working fine but from Aug 2020 it stopped working. We are able to login to SSO url, using InAppBrowser plugin but after login we were redirecting to our main app. Issue is, now we are not able to redirect to our app. Application not able to load. I guess it is cookies issue, I tried setting manual cookies as well but nothing works out. Please suggest some solution on this issue as our app stopped working because of this. Awaiting for your response and some suggestion.
Asked
by digitePR.
Last updated .
Post marked as unsolved
70 Views

What am I doing wrong?

Let me start out by saying I'm completely new to coding. I purchased an app from another developer and am having issues trying to open the source files he sent over. The app was built using unity but unity isn't recognizing the files at all. I need some guidance from you guys and girls I really feel like I have failed myself already.
Asked
by TheNewbie.
Last updated .
Post marked as unsolved
296 Views

What is written in panic-full?

Hi all, I hope to find someone here who knows some details of the content of Apples crash log panic-full. I cannot reproduce the crash. I stressed the device by 3D Games, Video, full brightness, etc. but it was stable. Then it crashed when using Safari, so it seems not to be related to any Hardware Performance issue (I hope). Crashes occur every 1-2 days. I would like to learn something about the code in the panic-full ips, would be glad if you can give me some hints. The full log is attached in two parts, because it exceeds 250k chars. Thanks panic-full part1 - https://developer.apple.com/forums/content/attachment/060e8c4e-d738-4734-b84a-0b48e0f97c15 panic-full part2 - https://developer.apple.com/forums/content/attachment/508c81e0-6215-435a-8020-9ac91a8a0f57
Asked
by HansM.
Last updated .
Post marked as unsolved
82 Views

iphone diagnostics

How can i run iphone hardware diagnostics
Asked
Last updated .
Post marked as unsolved
87 Views

iphone dianostics

How can i run iphone hardware diagnostic.
Asked
Last updated .
Post marked as unsolved
266 Views

Is git already installed when buying a new Macbook?

Greetings, due to the current situation (Corona-Virus) I had to download Xcode, MS Visual Studio and Visual StudioCode on my personal MacBook Pro (2017; no Touch Bar). These applications were all asking for git (git-scm) and I have accepted. After some regrets I have decided to delete all applications again. I was able to delete Xcode, MS VS and VS Code but there was no program with the name git“, but hundreds of files with a big red „h“ on them, that I have never seen before. I used the function for a secured system restart and at the end I was reinstalling MacOS BigSur. Every time I logged in my entire display was black and my cursor in a neon blue I installed a new MacOS again and now everything seems to be fine (at least no black screen). I used some codes, I got from google, on my terminal (sudo rm -rf /usr/bin/git/), I am afraid that it has done more damage than it was helpful. Any idea how I can reverse the last 24 hours? Summary: Is Git already installed when I buy a new MacBook? If not, how can I delete all unnecessary files? Has „sudo rm -rf /usr/bin/git/„ changed anything? My terminal said that I was having Apple Git 128. After deleting XCodes there seems to be no git $ which git /usr/bin/git $ git --version xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Sorry for all the questions, but I am totally unskilled when it is about using git. Kind Regards,
Asked
by JoGo_01.
Last updated .
Post marked as unsolved
95 Views

Do I need to upgrade my old code in order to publish an app?

Hi all, I am a complete novice and have paid a developer to create an app for me in 2016. Due to some personal circumstances we didn't publish and my app has been sat in Dropbox for almost 5 years. I'd like to dust it off and publish it but suspect the code may be out of date. I have a .IPA file which I assume contains the code but am unsure of what I need to do (if anything) before it is in a ready-state to publish. Any advice would be very much appreciated!
Asked
by PBeau.
Last updated .
Post marked as unsolved
253 Views

Set cookie of WKWebview does not work in ios12 and below.

As a result of executing the code below In iOS13 and above version, we could set Cookie and check cookies in HTML loaded on webView. However, cookies were not set in iOS11, iOS12. Can I check if Apple API Guide function is defective? It's my code.    if (@available(iOS 11.0, *)) {     dispatch_async(dispatch_get_main_queue(), ^{       for (NSArray *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {         [webview.configuration.websiteDataStore.httpCookieStore setCookie:cookie completionHandler:^{           [webview loadRequest:request];         }];       }     });   }
Asked
by khson.
Last updated .