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.
Related
We have an implementation with the UIDocumentPickerViewController that looks something like this:
case .openInitialization:
// Setup UIDocumentPicker.
if #available(iOS 14, *) {
documentsPicker = UIDocumentPickerViewController(forOpeningContentTypes: [
UTType.text,
UTType.utf8PlainText,
UTType.flatRTFD,
UTType.pdf])
} else {
documentsPicker = UIDocumentPickerViewController(documentTypes: [
String(kUTTypeText),
String(kUTTypeUTF8PlainText),
String(kUTTypeFlatRTFD),
String(kUTTypePDF)], in: .open)
}
Everything works great and we can select a document. When we select a document we get a document url but in some cases (especially with one drive) we get issues when we want to turn the url into a bookmark. Following code returns nil:
guard let bookmark = try? url.bookmarkData(options: .minimalBookmark, includingResourceValuesForKeys: nil, relativeTo: nil) else { return }
Do anyone have an idea to why this is happening? Or what we can do to get it to work without returning nil?
Edit:
We've tryed to add try catch and we got following error which doesn't quite help much: Error Domain=NSCocoaErrorDomain Code=260 (file doesn't exist).
Edit 2:
So if I open from archive directly into our app it works no issues at all. But we still need to work from UIDocumentPickerViewController.
Also for some reasons files unlocked this way will just work from UIDocumentPickerViewController afterward.
Files can also be opened from onedrive and from there be opened in another app (ours). But this does't and gives a file does not exist error as well.
Edit 3:
So I've tested and read a ton. I can tell that following will return false for some files picked by documentpicker:
var exist = FileManager.default.fileExists(atPath: url.path)
But again if I open the file just once from iOS archive app it will work perfectly fine afterward. If there just were some way to tell it to update/download like apples does.
Edit 4:
I've made a sample project demonstrating the problem at github .
I answered a similar question here: PDFKit doesn’t work on iPads while works fine on a simulator [iOS, Swift]
Can you check if wrapping your url in a security access scope helps?:
url.startAccessingSecurityScopedResource()
print(FileManager.default.fileExists(atPath: url.path))
url.stopAccessingSecurityScopedResource()
The above should print true. This is because these API's access files outside of the applications sandbox.
See: https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories
Used a technical ticket for apple and they came with a solution :D
NSFileCoordinator().coordinate(readingItemAt: url, options: .withoutChanges, error:&err, byAccessor: { (newURL: URL) -> Void in
do {
let bookmark = try newURL.bookmarkData()
} catch let error {
print("\(error)")
}
})
if let err = err {
print(err.localizedDescription)
}
Before I updated to iOS 14 on my iPhone, this code was working perfectly. After, iOS 14 this is weirdly not running... it is very odd and I have not seen any solution online, additionally from my investigation, I have not been able to see any change.
This code is used in order to retrieve a videoURL for this video from the imported Camera Roll (I use import Photos...).
phResourceManager.writeData(for: resource.last!, toFile: newURL!, options: resourceRequestOptions) { (error) in
if error != nil {
print(error, "not c67omplted error?")
} else {
print("woah completedd 345?")
newUserTakenVideo.videoURL = newURL
print(newUserTakenVideo.videoURL, "<--?")
}
}
EDIT:
To be clear, it "does not run" means the compleition block never runs... as in it never even runs and gives an error, the compleition block simply never is called (nothing prints at least..)
And here is a print statement printing out all the values I pass in to the parameters:
phResourceManager:
<PHAssetResourceManager: 0x282d352c0>
resource.last:
Optional(<PHAssetResource: 0x28128bc00> {
type: video
uti: public.mpeg-4
filename: v07044090000bu6n1nhlp4leque7r720.mp4
asset: C97B45D3-7039-4626-BA3E-BCA67912A2A9/L0/001
locallyAvailable: YES
fileURL: file:///var/mobile/Media/DCIM/113APPLE/IMG_3404.MP4
width: 576
height: 1024
fileSize: 4664955
analysisType: unavailable
cplResourceType: Original
isCurrent: YES
})
newURL:
Optional(file:///var/mobile/Containers/Data/Application/E2792F47-142E-4601-8D5B-F549D03C9AFE/Documents/Untitled%2027228354.MP4)
resourceRequestOptions:
<PHAssetResourceRequestOptions: 0x28230d480>
Note: this is the decleration for the resource variable:
let resource = PHAssetResource.assetResources(for: (cell?.assetPH)!)
I have a solution to this! Swift 4+, tested on iOS 14!
I looked through using a PHAssetResourceRequest, but the file names were messed with in the process, and it generally didn't work with my sandbox. Then I also tried requesting a AVPlayerItem from the PHAsset but this too, did not work with sandboxing...
But then, I tried simply using PHAssetResourceManager.default().writeData(... and seemingly started working!
I tested a bit more and seemed to work, here is the full code:
let resource = PHAssetResource.assetResources(for: (cell?.assetPH)!)
let resourceRequestOptions = PHAssetResourceRequestOptions()
let newURL = ExistingMediaVC.newFileUrl
PHAssetResourceManager.default().writeData(for: resource.last!, toFile: newURL!, options: resourceRequestOptions) { (error) in
if error != nil {
print(error, "error")
} else {
print("good")
newUserTakenVideo.videoURL = newURL
}
}
It is quite simple!! Tell me if anything is not working, and note I still use the ExisitingMedia.fileURL variable you used in your original code as well :)
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.
As a part of upgrading the code base to Swift5, I have updated Firebase pod in my project. After that i started getting warning as below.
isDeveloperModeEnabled is deprecated: This no longer needs to be set during development. Refer to documentation for additional details..
Can somebody explain what is the alternative way to resolve this issue
remoteConfig = RemoteConfig.remoteConfig()
let conSettings = RemoteConfigSettings(developerModeEnabled: true)
if TargetBuild.isProd {
remoteConfig.configSettings = RemoteConfigSettings()
} else if settings.isDeveloperModeEnabled {
remoteConfig.configSettings = conSettings
} else {
print("Could not set config settings")
}
i need to resolve the warning on above code. This was an existing codebase. When i did a global search, i didnt see this value getting used. somebody please help me
Old way:
let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: true)
New way:
let remoteConfigSettings = RemoteConfigSettings()
remoteConfigSettings.minimumFetchInterval = 0
The iOS documentation does not yet mention that developerModeEnabled is deprecated, but an updated commented example can be found here: https://github.com/firebase/quickstart-ios/blob/master/config/ConfigExample/RemoteConfigViewController.swift#L57 (README here)
That config setting is deprecated.. With a simple google search..
https://firebase.google.com/docs/reference/android/com/google/firebase/remoteconfig/FirebaseRemoteConfigSettings.html#getMinimumFetchIntervalInSeconds()
The docs say to use getMinimumFetchIntervalInSeconds() instead of isDeveloperModeEnabled().
Update -- Android docs say it is deprecated, iOS does not say anything about deprecating isDeveloperModeEnabled
https://firebase.google.com/docs/reference/swift/firebaseremoteconfig/api/reference/Classes/RemoteConfigSettings
If you are using Objective-C, you can solve the issue with:
FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] init];
[remoteConfigSettings setMinimumFetchInterval:0];
I'm just starting developing apps with Swift 2.0, and as I'm working having problem with initiating a variable with the value of a text field in my app.
this is the function I'm having problems with. It's called when a button under the text field is pressed as submit.
#IBAction func checkName(sender: AnyObject) {
guard let name : String = nameField.text else { print("Name not valid.");return}
let checker = NameChecker()
let result = checker.nameChecker(name)
print(result)
}
this only thing this code returns on the XCode shell is "lldb". I also tried to use the debugger to figure out where I was messing up but unfortunately I found out that was harder than expected and I wasn't able to.
If you have any idea why my code is only returning "lldb" I would really appreciate is you could let me know since I've been experiencing this error quite often lately.