Unable to import files with custom UTI extension on IOS 13 - ios

Since the update to IOS 13 importing custom UTI files is not working (works perfectly on devices with 12.4)
I've downloaded the simple working project form this page: https://www.raywenderlich.com/813044-uiactivityviewcontroller-tutorial-sharing-data , which i also used as a base for the sharing system of my app.
On IOS 13 (12.4 works), when get the sample file (from email o data folder) and click on Copy To App, IOS goes back to the main screen, and after a few seconds i get a Safari crash error.
This is the project info.plist section for exporting files:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Book Tracker Document</string>
<key>UTTypeIconFiles</key>
<array>
<string>book_320.png</string>
<string>book_64.png</string>
<string>book_44.png</string>
<string>book_22.png</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.raywenderlich.BookTracker.btkr</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>btkr</string>
<key>public.mime-type</key>
<string>application/booktracker</string>
</dict>
</dict>
</array>
</key>
Things i tried:
Add an UTImportedTypeDeclarations, with the same details as UTExportedTypeDeclarations ones as there is none in the project ---- STILL CRASH
In this post about at the end, was suggested to remove the section from the info.plist (Not modifying the Document Types section) and create it anew from the interface ---- STILL CRASH (it also causes an infinite loop in xcode when adding array items for public.filneame-extension or mime-type)
Various combinations of the solutions above
This is the main error i always get:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
terminating with uncaught exception of type NSException
Full log is here: log
I'm kind of out out ideas! Please help!

I don't have the answer to your question but I have a similar problem with this same sample app from Ray Wenderlich. Unfortunately the comment section for this tutorial is closed.
I am using the "finished" version which has all the UTI information already set.
In my case I want to save the ".btkr" document to the Files application. That works OK but then if I tap on the .btkr document saved in Files, it opens the BookTracker application but quietly fails in the Book.swift importData(from url: URL) method.
I unraveled the guard statement into do/try/catch blocks and what I see is "The file “New Book.btkr” couldn’t be opened because you don’t have permission to view it." This is being thrown from the "let data = try Data(contentsOf: url)" statement.
The odd thing is if I share the same document via eMail, a tap on the .btkr attachment successfully opens the app and imports the .btkr just fine. Share via AirDrop works as well.
I do not know if this is only an iOS 13 bug because I no longer have any devices with older iOS's. Since the tutorials from Wenderlich are generally very good (this one is from February 2019, before iOS 13) I suspect your problem and my problem are iOS 13 bugs.

I'm seeing exactly the same thing here on my app. Wrapping readFromURL and writeToURL in between startAccessingSecurityScopedResource & stopAccessingSecurityScopedResource helped on my iPad running iOS 13.2.3, but I'm still seeing the Safari crash and unable to open the documents on the iPhone running 13.2.2.

Related

Flutter: webview_flutter just displays blank (white) on iOS

The bounty expires in 4 days. Answers to this question are eligible for a +50 reputation bounty.
Cedric wants to draw more attention to this question.
I got it to work on Android, the WebViewWidget displays correctly with the html content, no problem.
For iOS it just displays blank/white. I tried what I have seen suggested by people all over the internet, which is to add a few lines to Info.plist, that allow the WKWebView in iOS to load and display http (not secure, not only https):
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
(^^I don't really know what these lines individually do)
(^^I have also tried lowercase "yes" and <true/> as values for the first one)
I ran flutter clean, then flutter pub get, deleted Podfile.lock, ran pod install (in the ios folder) a bunch of times, but I still can't get the content to show in the webview on iOS (it works on Android), only blank white space where the html content is supposed to appear.
It's important to mention that I get my html from neither http nor https, but I load a String (which is html) and set it like this:
String text = ...
await _controller.loadHtmlString(text);
Is there maybe a way of tricking iOS to think that the html comes from https?
These are some common messages I see printed out in the console (not red, just regular color), and I only get these messages when running the app from android studio, not XCode (on a real iOS device):
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x12d07df20 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=47861, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
and:
Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
UPDATE: I found out, it also shows a blank/white page on iOS even when I use https, like _controller.loadRequest(Uri.parse('https://flutter.dev'));.
I solved the problem, it was unexpected and not related to http/https stuff... See the comments in below code for explanation
_controller.setNavigationDelegate(
//...
onNavigationRequest: (NavigationRequest request) {
print('onNavigationRequest');
//I first had this line to prevent redirection to anywhere on the internet via hrefs
//but this prevented ANYTHING from being displayed
// return NavigationDecision.prevent;
return NavigationDecision.navigate; //changed it to this, and it works now
},
);
I also removed all those lines from Info.plist, and it still works.

Flutter flutter_webview_plugin error [NSNull length]: unrecognized selector sent to instance on ios

I am using flutter_webview_plugin: ^0.4.0 to load a website. The app works fine on Android. On IOs I am getting the error
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1fb513aa0'
for the line NSURL *scopeUrl = [NSURL fileURLWithPath:localUrlScope]; in file FlutterWebviewPlugin in Xcode.
I've added
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
from the docs in my Info.plist.
I tried adding
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
in my Info.plist but it didn't work. I also tried replacing <string>YES</string> with <true/> which didn't work too.
I've tried setting the target IOs versions from 9.0 to 13.0 and the issue still exists.
I am using the file picker and alert dialog features provided by this package so I cannot use any another.
I've wrapped the URL with Uri.encodeFull().
The block of code where the error occurs is as follows:
if (#available(iOS 9.0, *)) {
if(localUrlScope == nil) {
[self.webview loadFileURL:htmlUrl allowingReadAccessToURL:htmlUrl];
}
else {
NSURL *scopeUrl = [NSURL fileURLWithPath:localUrlScope]; //ERROR OCCURING HERE
[self.webview loadFileURL:htmlUrl allowingReadAccessToURL:scopeUrl];
}
} else {
#throw #"not available on version earlier than ios 9.0";
}
I ran flutter doctor and it didn't show any issues.
Everytime I change something in the code, I delete Podfile.lock, build folder, run flutter clean so the changes made in some previous attempts aren't messing anything.
I am using an M1 Mac with Dart 2.13.4, Flutter 2.5.0, XCode 13.0 (13A233)
I have had this issue earlier when I was working on a similar thing with this package, After long hours of bashing head around, I found this from package documentation,
Focus on this portion where it says this
Thing is when you set withLocalUrl to true, you have to Add localUrlScope option to be set to a path to a directory in your flutter code or you just remove withLocalUrl:true from it.
As this option is ignored in Android so it works with no issues in it but for iOS we need to be specific with this

Why Xcode not getting GADApplicationIdentifier from info.plist which is used for Google Mobile Ad SDK?

I'm asking this question after trying all possible ways to solve the issues I'm facing. First, let's see the error and I will tell what I have done to solve it but unfortunately, nothing is really working for me.
So, I have imported the Google Mobile AD sdk using cocoaPod. Added the following line in AppDelegate:
GADMobileAds.sharedInstance().start(completionHandler: nil)
and the following in info.plist:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>GADIsAdManagerApp</key>
<true/>
However, the app keeps on throwing the following error:
Terminating app due to uncaught exception 'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized without an application ID. Google AdMob publishers, follow instructions here: https://googlemobileadssdk.page.link/admob-ios-update-plist to set GADApplicationIdentifier with a valid app ID. Google Ad Manager publishers, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist'
I tried to import Firebase but still could not resolve the issue.

What is PBItemCollectionServicer?

I searched SO ,find nothing about PBItemCollectionServicer.
My question become form my app crash(because of memory rise violently), then print:
PBItemCollectionServicer connection disconnected.
The screen shot:
I have no idea about the PBItemCollectionServicer, whats mean of that?
and how does it work?
why it print here?
Is it relate to my app crash?
Edit -1
As Nir's comment, he suspect if I use the under link framework.
https://github.com/JaviSoto/iOS10-Runtime-Headers/tree/master/PrivateFrameworks/Pasteboard.framework
No , I didn't, I searched my project with no result:
Well, I guess those annoying PBItemCollectionServicer logs appear seconds after you copied (Command+ C) something into your iOS devices or iOS simulator which is running apps via Xcode.
The "universal clipboard" service (seems to) collects strings or images to share between your own iCloud devices (Mac, iOS devices ...)
It works in Sierra & iOS 10 environment
Check this article
This log happens only when under simulator/iOS device while running on Xcode, I think.
I don't know why Xcode team let this somewhat should-be-hidden log displayed... for developers? But couldn't find any documentation... blah blah
"PBItemCollectionServicer connection disconnected." also logs when using iOS 11 table view drag-and-drop and completing a drop. It's benign there, from all I've observed.
I was receiving:
Console Log: "PBItemCollectionServicer connection disconnected."
all of a sudden while debugging an iPhone app while connected via the USB cable to my MacBook.
After a bit of searching it turned out that it was hanging for some time because of this line of code where I was clearing the pasteboard:
[pasteBoard setValue:#"" forPasteboardType:UIPasteboardNameGeneral];
After a lot of google searching without any luck I noticed that it only happens when the iPhone was connected to my Mac.
It turned out to be the shared clipboard causing the hang/delay and log message.
If you turn off "Handoff" on the iPhone (Settings/General/Handoff) and Mac (System Preferences/General/Allow Handoff) then the problem was resolved.
The problem also goes away when you disconnect the USB cable from the Mac so it doesn't affect regular use.
For me, the error occurred when PHAssetCollection fetchAssetCollectionsWithType : called with a block predicate:
PHFetchOptions *fetchOptions = PHFetchOptions.new;
// correct
fetchOptions.predicate = [NSPredicate predicateWithFormat:#"localizedTitle = %#", targetAlbumName];
// wrong
// crash with the error message "PBItemCollectionServicer connection disconnected."
//fetchOptions.predicate = [NSPredicate predicateWithBlock:xxx];
PHAssetCollection * assetCollection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:fetchOptions].firstObject;
I found that when working with drag and drop this error gets cleared up when adding
view.addInteraction(UIDropInteraction(delegate: self))
to the viewDidLoad of the view you are dropping into.
Firstly, this is not an answer to the question. And I failed to find one. It's just some information I think may be helpful for someone who can dig into this and find an answer.
I was tinkering with the copy(_:), cut(_:) and paste(_:) functions of UITextField. Almost every time I did copy/cut/paste in in field, the Xcode gave this message:
2020-07-17 15:45:38.796510+0800 MyApp[3062:1763915] [general] Connection to daemon was invalidated
2020-07-17 15:45:54.179188+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:46:53.097783+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:46:57.180499+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:48:34.901502+0800 MyApp[3062:1764656] PBItemCollectionServicer connection disconnected.
The only relevant code is an extension to UITextField:
extension UITextField {
open override func copy(_ sender: Any?) {
print(sender)
print(text)
}
open override func paste(_ sender: Any?) {
print(sender)
print(text)
}
open override func cut(_ sender: Any?) {
print(sender)
print(text)
}
}
And none of them was called. How weird. Then I commented out this extension, and to my surprise, Xcode still gave the exactly same message. Anyway, after I searched here and there, I found this in Apple Developer Forums, which is discussion about the failure of UIDropInteraction with the same error message. As all the other answers mostly talked about UIPasteboard, I think it is necessary to put it here although it doesn't contain a solution or answer.
I tried running on both Simulator(13.5) and device(13.4.1), with Xcode 11.5, and got the same error message.
I was also receiving a PBItemCollectionServicer connection disconnected line in the console log, when testing an UICollectionViewDragDelegate implementation.
It turned out that my Info.plist file didn't have that required NSUserActivityTypes configuration with the activity identifier of the NSUserActivity used in the NSItemProvider as part of the dragged UIDragItem. After fixing this, the drag-and-drop action finally worked, and the console did log the mysterious line anymore.
In order to make sure drag-and-drop works for you,
you need to specify your type identifier (e.g. com.xxx.TodoList.todoItem) in Info.plist like this:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeDescription</key>
<string>com.xxx.TodoList.todoItem</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.xxx.TodoList.todoItem</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array/>
</dict>
</dict>
</array>

Delphi 10 Seattle in iOS9 (External Exception 434C4E47432B2B00)

I created a simple application that accesses a DataSnap server.
When I run in simulator (iOS 9) or iPad 2 (iOS 9.0.1), everything works perfectly.
When I run on the iPhone 5, an error message appears when connecting to DataSnap Server (External Exception 434C4E47432B2B00).
Any idea?
Sergey Krasilnikov added a comment
Hi all!
Good news, this issue has been resolved for Seattle Update 1.
From external Jira: This is a problem with TStringHelper.InternalCompare Next code fails with iOS9 SDK: string.Compare('short', 'loooong', True);
You must change your datasnap server(tcp/ip) to rest server(http)
And change your client plist file (Project.plist)
Go to the bottom of the file and insert the following text above the last /dict tag:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
http://blogs.embarcadero.com/davidi/2015/09/24/43917

Resources