After updating to Xcode 11.4, I started to get this error
Failed to produce diagnostic for expression please file a bug report
On:
let provider = MoyaProvider<EndPoint>(requestClosure: requestClosure)
I updated Moya but it doesn't look like the issue. Runs fine on previous Xcode versions.
full code:
let requestClosure: MoyaProvider.RequestClosure = {
[unowned self] (endpoint: Endpoint, done: #escaping MoyaProvider.RequestResultClosure) in
guard let request = try? endpoint.urlRequest() else { return }
self.authenticator.authenticate(request, done: { (request) in
done(.success(request))
})
}
provider = MoyaProvider<EndPoint>(requestClosure: requestClosure
I found the issue, Xcode 11.4 compile issues are not verbose enough when it comes to optionals and generics.
Moya version and Swift version were not changed.
An issue with generics:
let requestClosure: MoyaProvider<EndPoint>.RequestClosure
Had to explicitly define the type in the closure, which makes sense, but was not a requirement pre-Xcode version 11.4
let requestClosure: MoyaProvider<EndPoint>.RequestClosure = {
[unowned self] (endpoint: Endpoint, done: #escaping MoyaProvider.RequestResultClosure) in
guard let request = try? endpoint.urlRequest() else { return }
self.authenticator.authenticate(request, done: { (request) in
done(.success(request))
})
}
provider = MoyaProvider<EndPoint>(requestClosure: requestClosure
For me the I was getting that error because one of my property was of type Error and I was assigning a value of type LocalizedError to it. Changing the property type to LocalizedError fixed the problem.
It seems to be an Xcode bug for some cases at least. I renamed a protocol and then renamed it back and the issue was gone.
Related
I'm having an issue with trying to build a file I downloaded from PWABuilder.
The error I'm getting is: Value of type 'WKWebView' has no member 'underPageBackgroundColor'
Heres the snippet:
if #available(iOS 15.0, *), adaptiveUIStyle {
themeObservation = OVATION.webView.observe(\.underPageBackgroundColor) { [unowned self] webView, _ in
currentWebViewTheme = OVATION.webView.underPageBackgroundColor.isLight() ?? true ? .light : .dark
self.overrideUIStyle()
As I downloaded it from PWABuilder, it should just build fine, so not sure why I'm getting this error. I don't know swift, so not entirely sure why it's happening. I've followed the article here but doesnt make any mention. Any thoughts would be great.
I get crash on every 32 bit device / simulator running iOS 9 on save(to:for:completionHandler:).
Xcode 8.2. Base SDK is 10.2. Target is 9.0. Standard architectures. Swift 3. For both develop and release builds. Sample project.
Could not find if it's known, neither any related issues. Can you recommend any workaround? Should I require 64 bit architecture?
The work around is to return NS object, Apple engineer recommended NSMutableData specifically:
override func contents(forType typeName: String) throws -> Any {
guard let data = text.data(using: .utf8) else { ... }
if #available(iOS 10, *) {
return data
} else {
return NSMutableData(data: data)
}
}
I am working on developing my first ResearchKit App. I have been watching this video. One of the techniques used that is going to be helpful for me is serializing the results of a survey to JSON. The method used in the video is ORKESerializer.JSONDataForObject(taskResult). He explains that this is not a standard part of researchKit, but it was included in a test app, called ORKTest that is on GitHub.
I set up my taskViewController delegate just like he had it set on the video, like this:
extension ViewController : ORKTaskViewControllerDelegate {
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
switch reason {
case .Completed:
let taskResult = taskViewController.result
let jsonData = try! ORKESerializer.JSONDataForObject(taskResult)
if let jsonString = NSString(data: jsonData, encoding: NSUTF8StringEncoding) {
print(jsonString)
}
break
case .Failed, .Discarded, .Saved:
break
}
//Handle results with taskViewController.result
// let taskResult = taskViewController.result
taskViewController.dismissViewControllerAnimated(true, completion: nil)
}
}
I am getting this error upon compiling : use of unresolved identifier: ORKESerializer
So in the ORKTest app, in the GitHub files, I found 2 files. One called ORKESerialization.h, and one called ORKESerialization.m. I tried dragging those into my project, as I saw those files in the man's project in the video. And then that also prompted me to create a bridging header file as well, which I also saw in his project.
After doing that I am still getting the same error. The truth is I don't know exactly how to include these serialization packages with my app. Does anyone know how to included the right files so that I can implement this ORKEserialization method?
Thanks!
You need to import ORKESerialization.h in your bridging header:
#import "ORKESerialization.h"
Today i updated my xcode to version 7 with swift 2.0.
Then i got so many errors in my production app, But i already fixed most of it by myself.
The problem is some of it i don't know how to fix.
So the images below are errors that i could not fix it myself.
If anyone knows how to fix it please help.
Thanks!
As explain in the comment, you simply have to rewrite those lines by checking the method signature :
1.
// Use the NSURL methods instead of String ones
let path = NSURL(fileURLWithPath: documentsFolder).URLByAppendingPathComponent("baseDeck.sqlite").path!
2.
// Make sure the productId is a String
request = SKProductsRequest(productIdentifiers: [productId])
3.
// Be careful to parameters, they are optionals
motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()) { (data: CMAccelerometerData?, error: NSError?) -> Void in
//...
}
4.
// Be careful too, the invalidProductIdentifiers method return an array of string whereas the response.products an array of SKProduct
let products = responses.products.filter { productIndentifiers.contains($0.productIdentifier) }
I hope it'll help you.
I'm working on project first time with swift language. I have used alamofire for web service api. I have created a common func for it.
class func postWebService(methodname:String,param:NSDictionary,userName:String,password:String, CompletionHandler:(success:Bool,response:NSDictionary) -> ())
{
let mainlink :String = "mymainurl"
var link = mainlink + methodname
var url:NSURL = NSURL(string: link)!
let plainString = "\(userName):\(password)" as NSString
// example : let plainString = "textuser:testpwd" as NSString
let plainData = plainString.dataUsingEncoding(NSUTF8StringEncoding)
let base64String = plainData?.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0))
Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders = ["Authorization": "Basic " + base64String!]
request(.GET, url, parameters: param as? [String : AnyObject]).responseJSON { (req, res, jsonresp, error) -> Void in
if(error != nil) {
NSLog("Error: \(req) \(error)")
var errDict:NSDictionary = ["message":"\(error?.localizedDescription)"]
CompletionHandler(success: false,response: errDict)
}
else {
var json: NSDictionary = jsonresp! as! NSDictionary
NSLog("%#",json)
CompletionHandler(success: true,response: json)
}
}
}
It is working fine and gives me response when I run it in simulator. But if I load my project in device than It gives me a error
Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x17dc4580 {NSDebugDescription=Invalid value around character 0.})
If there is a problem in code than it should not work in simulator also. And it is nice and working code for web service api. Any help will be appreciated. Thanks in advance.
==== EDIT====
Mention : it is server url.
I figured out one more thing. If I run this code in ios 8 and above device it is working fine. And this problem is occurred in ios 7 device. I'm dealing with iPod with ios7. I have checked in ios8 devices like iPhone and iPad, it is working fine.
May or not be the case with you but I once had that error when accessing a url that was not correct. In my case it was pointing to localhost, which was perfect for the simulator but complete useless on the device.
Double check your URL, make sure the web service is online and can be reached from your device...
Hope this helps, if not others will chime in ;)
I have researched for this and mainly I checked all information of Alamofire on github. In this page I have found solution and it is my main and big mistake is that Alamofire have not support of ios 7. It Requires ios 8+.
Above My code is right and good for web service api. There is no problem in URL or in Code. My problem is for ios 7.0 which is not supported so this problem occured.
So, It is my own mistake, not of Alamofire Framework or code. But is should support ios7 because we can't ignore ios version 7 for our projects. There are may be lots of devices having ios7. Thanks for all support.