Inability Sharing a file via iOS Share Extension - ios

I've received the following log from a customer who claims to be sharing photos from the photos app via Share Extension. The customer is making an assumption that internet connection to the router is bad. The behavior as described by the customer is as follows:
Upload a file via share extension via a bad connection
Let device sleep, in our case the connection should get terminated and the file is not uploaded to our servers.
Attempt to re-upload the same file.
Expected Result:
The file should upload fine.
Actual Result:
Share Extension never loads, that means that user can infinitely click the app icon with no success of showing the view.
Adding to this, we have never been able to reproduce such a problem in house. However, the customer can do so every time while in the airport.
I took a peek in his device logs, and I can see the following with no clue what is going in. Starting from the out of bound exception which I can't explain due to the fact that the view never loaded.
Any idea or did anyone else encounter the same problem?
Apr 13 15:11:07 audi pkd[153] : assigning plug-in
(2.1.2) to plugin sandbox
Apr 13 15:11:07 audi pkd[153] : enabling pid=386 for plug-in
(2.1.2)
D89CEF37-B025-4C6F-A8B6-FBB6B4D94A84/private/var/containers/Bundle/Application/AF69E215-04AE-4929-A8C8-51BE8FADF397/.app/PlugIns/.appex
Apr 13 15:11:07 audi kernel[0] : xpcproxy[451] Container:
/private/var/mobile/Containers/Data/PluginKitPlugin/669C0F52-1C21-441D-9906-E2EFBD8A7D00(sandbox)
Apr 13 15:11:08 audi kernel[0] :
LwVM::_generateMappedExtentsList - failed to map unmap range to partition
Apr 13 15:11:08 audi backboardd[60] : Unable to
bootstrap_look_up port with name .gsEvents:
unknown error code (1102) Apr 13 15:11:08 audi[451] :
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 ..
0]' First throw call stack: (0x18400ae38 0x18366ff80 0x183eeb158
0x1000e4a40 0x1000e4738 0x183a554bc 0x183a5547c 0x183a5ab84
0x183fc0dd8 0x183fbec40 0x183ee8d10 0x1857d0088 0x1891bdf70
0x183cacd74 0x183caea2c 0x184acbd30 0x18b2e2c48 0x18b2e28dc
0x18b2e2c6c 0x1848de058 0x183a868b8)
Apr 13 15:11:08 audi MobileSlideShow[386] : plugin
interrupted
Apr 13 15:11:08 audi MobileSlideShow[386] : plugin
invalidated
Apr 13 15:11:08 audi diagnosticd[84] : error evaluating process
info - pid: 451, puniqueid: 451
Apr 13 15:11:08 audi mediaserverd[28] : ''
(pid = 451) setting DiscoveryMode =
DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Apr 13 15:11:08 audi MobileSlideShow[386] : 2016-04-13
15:11:08.629|MobileSlideShow|0x14ce07cd0: HOST: Failed to load remote
view controller with error: Error Domain=NSCocoaErrorDomain Code=4099
"The connection to service named
.viewservice was interrupted, but the
message was sent over an additional proxy and therefore this proxy has
become invalid." UserInfo= {NSDebugDescription=The connection to
service named .viewservice was interrupted,
but the message was sent over an additional proxy and therefore this
proxy has become invalid.}
Apr 13 15:11:08 audi MobileSlideShow[386] : 2016-04-13
15:11:08.633|MobileSlideShow|0x14ce07cd0: Sheet not being presented,
calling premature completion
Apr 13 15:11:08 audi com.apple.xpc.launchd[1]
([451]) : Service exited due to
signal: Abort trap: 6
Apr 13 15:11:08 audi ReportCrash[452] : Formulating report for
corpse[451]
Apr 13 15:11:08 audi ReportCrash[452] : Report of type
'109(109_)' not saved because the limit of 25 logs has been
reached
Apr 13 15:11:08 audi ReportCrash[452] : Notice: This report is
abbreviated for syslog inclusion because it could not be saved to
disk.
Symbolication may be possible by manually cleaning up and including
the Binary Image section of a full report from this same device – good
luck!
Apr 13 15:11:08 audi ReportCrash[452] : Process:
[451] Path:
/private/var/containers/Bundle/Application/AF69E215-04AE-4929-A8C8-51BE8FADF397/.app/PlugIns/.appex/

in many cases the file is large, and connection is being freed before finishing, or something in same vane is happing, if it is something in this vane, a possible way around, write your file to app document folder first, then upload via a URL link from your document folder in app like this: (example with an image)
let documentsDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let path = documentsDirectoryPath.appending("/outImage.jpg")
let outURL = URL(fileURLWithPath: path)
try? FileManager.default.removeItem(at: outURL)
if let data2c = self.newImage.jpegData(compressionQuality:1.0)
{
do
{
try data2c.write(to: outURL)
DispatchQueue.main.async
{
var filesToShare = [Any]()
filesToShare.append(outURL)
let activityVC = UIActivityViewController(activityItems: filesToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [.print,.assignToContact,.copyToPasteboard,.addToReadingList,.markupAsPDF,.postToTencentWeibo,.postToTencentWeibo]
activityVC.popoverPresentationController?.sourceView = self.view
activityVC.preferredContentSize = CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height-60)
activityVC.modalPresentationCapturesStatusBarAppearance = true
self.present(activityVC, animated: true, completion: nil)
}
} catch {
print("Couldn't write file")
}
}

Related

Application crashes when try to scan card using Card.io-iOS-SDK.

I am working with Card.io since long time but now it started to crash accidentally when i tap on camera button to scan card.
Below is the crash logs.
<Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[NSTaggedPointerString getCharacters:range:]: Range {0, 7} out of bounds; string length 6'
*** First throw call stack:
(0x1845b5900 0x183c23f80 0x1845b5848 0x18459ce88 0x1844a7994 0x18459d634 0x100414aa8 0x1844eda04 0x1004147f4 0x1004153d4 0x10041557c 0x1003e8ea0 0x1892a80c0 0x1892a7cc4 0x189648930 0x189605930 0x189602340 0x189558b70 0x189566030 0x189299c24 0x18456c588 0x18456a32c 0x18456a75c 0x184499680 0x1859a8088 0x189310d90 0x10016de20 0x18403a8b8)
Feb 2 12:15:27 iPhone SpringBoard[54] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Feb 2 12:15:27 iPhone SpringBoard[54] <Warning>: UNNotificationRegistrarConnectionListener connection invalidated
Feb 2 12:15:27 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.upperlife.instacare[0x4a0a][369]) <Notice>: Service exited due to signal: Abort trap: 6
Feb 2 12:15:27 iPhone SpringBoard[54] <Warning>: Application 'UIKitApplication:com.upperlife.instacare[0x4a0a]' crashed.
Feb 2 12:15:28 iPhone UserEventAgent[23] <Warning>: 215163172432: id=com.upperlife.instacare pid=369, state=0
As you are using old version of Card.io SDK for iOS, so that's the main reason why the crash for iOS 9 is occurring, it has been fixed in version 5.1.0 .
Issue already raised in github:-
https://github.com/card-io/card.io-iOS-SDK/issues/120
Resolved:-
https://github.com/card-io/card.io-iOS-source/commit/b9b3c0a329b75d048a20190f8843da4f247d755a

Persistent store migration on iPhone 5s crashes tableview

I have a relatively straightforward master detail application in Xcode 6.0.1 with iOS Simulator 8.0.
The application uses core data. The application is local only. I plan to use iCloud or Dropbox to backup
the data, but not for synchronization. At the moment it is local only.
Everything works beautifully with one huge exception. Every time I use the simulator and simulate iPhone 5s,
as soon as I migrate the store and then access the tableview detail, the app crashes. No log info, no error info,
it simply stops. Same is true for a 5s phone.
If I run the simulator in iPhone 5 mode, or run the app on an iPhone 4s it works perfectly. I've read dozens of
tutorials and articles about core data and the persistent store - never even heard of this issue.
So there must be some issue for post- persistent-store migration on the 64 bit devices. Can anyone help?
(void)migrateStore:(NSString *)newSQLFileName {
// migrate current store from one URL to another
// write out the current store URL before the migration
NSURL *storeURL = [self.persistentStoreCoordinator.persistentStores.lastObject URL];
NSLog(#"storeURL before migration: %#", [storeURL description]);
// get the current store
NSPersistentStore *currentStore = self.persistentStoreCoordinator.persistentStores.lastObject;
// create a new URL
NSURL *newStoreURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:newSQLFileName];
//add the options dictionary once you get it working
// migrate current store to new URL
[self.persistentStoreCoordinator migratePersistentStore:currentStore toURL:newStoreURL options:nil withType:NSSQLiteStoreType error:nil];
// check to see if the new store is active, write out the URL again
storeURL = [self.persistentStoreCoordinator.persistentStores.lastObject URL];
NSLog(#"storeURL after migration: %#", [storeURL description]);
}//migrateStore:newSQLFileName
from the debug log window:
2014-10-02 16:35:09.274 BiopLog[31758:2509702] User entered PIN to validate
2014-10-02 16:35:09.277 BiopLog[31758:2509702] ** User Authenticated!!
2014-10-02 16:35:09.389 BiopLog[31758:2509702] the document path is: /Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents
2014-10-02 16:35:12.384 BiopLog[31758:2509702] storeURL before migration: file:///Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents/BiopLog.sqlite
2014-10-02 16:35:12.843 BiopLog[31758:2509702] storeURL after migration: file:///Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents/BiopBak201410021635.sqlite
(lldb)
and the Devices log includes:
Oct 2 17:42:41 JohniPhone SpringBoard[48] : Application 'UIKitApplication:com.carbonrose.BiopLog[0x9dbb]' crashed.
Oct 2 17:42:41 JohniPhone assertiond[58] : pid_suspend failed for : Unknown error: -1, Unknown error: -1
Oct 2 17:42:41 JohniPhone assertiond[58] : Could not set priority of to 2, priority: No such process
Oct 2 17:42:41 JohniPhone assertiond[58] : Could not set priority of to 4096, priority: No such process
Oct 2 17:42:41 JohniPhone UserEventAgent[17] : id=com.carbonrose.BiopLog pid=886, state=0
Oct 2 17:42:41 JohniPhone locationd[55] : Location icon should now be in state 'Active'
Oct 2 17:42:41 JohniPhone geod[127] : Can't get bundle identifier for process 565
Oct 2 17:42:43 JohniPhone locationd[55] : Gesture EnabledForTopCLient: 1, EnabledInDaemonSettings: 0
Oct 2 17:42:43 JohniPhone kernel[0] : xpcproxy[888] Container: /private/var/mobile/Containers/Data/Application/EC6B60D8-510D-4E46-82B1-29891D0F4E79 (sandbox)
Oct 2 17:42:43 JohniPhone yweather[888] : assertion failed: 12A405: libxpc.dylib + 71820 [4BC9CA3D-4DEE-314C-ADBF-53BDCEEFE45C]: 0x7d
Oct 2 17:42:43 JohniPhone Unknown[888] :
Oct 2 17:42:43 JohniPhone yweather[888] : CFURLSetResourcePropertyForKey failed because it was passed this URL which has no scheme: /var/mobile/Containers/Data/Application/EC6B60D8-510D-4E46-82B1-29891D0F4E79/Documents/YI13N/sqlite/yi13nevents.db
Oct 2 17:42:43 JohniPhone yweather[888] : Enabling Crittercism v4.3.4...
I had created an sqlite file with sample data and loaded that file when initializing the app. the difference in the storage of numbers from the 32 bit to the 64 bit machines was the reason the process was failing. The solution is to read in data from code and if later necessary, migrate the core data store to another device. the migration process will create the correct number storage locations.

iOS Keyboard extension: Not showing if no full access

I am working on an iOS keyboard extension with a containing app. My problem is that I can not "start" the keyboard will not show up. The frame is empty, I can't get into my code. Why is that?
My setup is a quite standard keyboard extension with nothing fancy. I have a hosting application that shows some settings. I store this setting in a NSUserDefaults suite with my app group as the identifier. Do I need full access to access this suite?
Bests,
Philip
UPDATE:
To see if it crashes or exits in the line where I open the settingsSuite I added an NSLog(#"Hello") to the first line of viewDidLoad. It is never reached. I get the following error message:
Sep 29 12:02:16 iPhone-6 kernel[0] <Notice>: xpcproxy[16389] Container: /private/var/mobile/Containers/Data/PluginKitPlugin/6A7DF264-59B2-4F38-92CB-63875B6C1469 (sandbox)
Sep 29 12:02:16 iPhone-6 Fancy Keyboard[16389] <Error>: assertion failed: 12A405: libxpc.dylib + 71820 [4BC9CA3D-4DEE-314C-ADBF-53BDCEEFE45C]: 0x7d
Sep 29 12:02:16 iPhone-6 Unknown[16389] <Error>:
Sep 29 12:02:16 iPhone-6 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system) <Error>: Caller not allowed to perform action: Fancy Keyboar.16389, action = pid-local registration, code = 1: Operation not permitted, uid = 501, euid = 501, gid = 501, egid = 501, asid = 0
Sep 29 12:02:16 iPhone-6 Fancy Keyboard[16389] <Error>: _GSRegisterPurpleNamedPortInPrivateNamespace Couldn't register com.apple.accessibility.gax.client with the bootstrap server. Error: unknown error code (1100).
This generally means that another instance of this process was already running or is hung in the debugger.
Sep 29 12:02:16 iPhone-6 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system) <Error>: Caller not allowed to perform action: Fancy Keyboar.16389, action = pid-local registration, code = 1: Operation not permitted, uid = 501, euid = 501, gid = 501, egid = 501, asid = 0
Sep 29 12:02:17 iPhone-6 ReportCrash[16390] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
Any ideas what that means?

In-App Purchase crashes App after release

Apple has approved our first app that has In-App Purchases - however suddenly when a user taps the "Upgrade" button the app hangs momentarily and then crashes. By using the Console feature in XCode's Organizer I was able to obtain the following report:
Sep 18 15:12:48 iPad MyApp[53107] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x316f92a3 0x3958497f 0x31643e8d 0x54b23 0x335ec0c5 0x335ec077 0x335ec055 0x335eb90b 0x335ebe01 0x335145f1 0x33501801 0x3350111b 0x351f35a3 0x351f31d3 0x316ce173 0x316ce117 0x316ccf99 0x3163febd 0x3163fd49 0x351f22eb 0x33555301 0x4b81f 0x399bbb20)
Sep 18 15:12:48 iPad ReportCrash[53109] <Notice>: Formulating crash report for process MyApp[53107]
Sep 18 15:12:48 iPad com.apple.launchd[1] (UIKitApplication:com.mycompany.MyApp[0x716c][53107]) <Warning>: (UIKitApplication:com.mycompany.MyApp[0x716c]) Job appears to have crashed: Abort trap: 6
Sep 18 15:12:48 iPad ReportCrash[53109] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Sep 18 15:12:48 iPad backboardd[26] <Warning>: Application 'UIKitApplication:com.mycompany.MyApp[0x716c]' exited abnormally with signal 6: Abort trap: 6
Sep 18 15:12:48 iPad ReportCrash[53109] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/MyApp_2013-09-18-151248_iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
This does not occur when I run the app on my device, and it must've worked when Apple review it or else they would not have cleared it for sale.
My guess it that my products array is null and when trying to purchase _products[0] (the only available one) it crashes.
More Info:
I followed Ray Wenderlich's Tutorial when adding In-App Purchases:
[[AppStoreHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success) {
_products = products;
}
[refreshControl endRefreshing];
}];
To sum up: why does it only work in testing mode?
Thanks in advance!
It works now. I guess Apple's servers needed some time to process the purchase...

NSAssert works in debugger but the message is missing from console when run directly on device

NSAssert works fine in Xcode 4 (up to 4.6 inclusive) when running debugger. Assertion fires, you breakpoint it, then it outputs the assertion message.
But when running outside the debugger (debug build on device), assertions fire - but with no message.
This makes assertions useless: you can see the line number which asserted, but the detailed message from the programmer has been wiped.
Is this an Xcode problem? A clang/LLVM problem? Is it a setting with the wrong value? Or is there a workaround?
Example code:
NSAssert(FALSE, #"X was invalid: %i", x );
Example output (console):
<Warning>: *** Assertion failure in -[myClass method:], myClass.m:124
<Notice>: Formulating crash report for process MyApp[82]
Expected output (console):
<Warning>: *** Assertion failure in -[myClass method:], myClass.m:124
<Warning>: *** "X was invalid: -435"
<Notice>: Formulating crash report for process MyApp[82]
NB: I'm only guessing how Apple would format the assertion message.
UPDATE: Found the problem. I was wrong with my original description:
The message was not being output to console while running in the debugger
Two observations:
The NSAssert is intended for debugging purposes only. When you build a release version of your app, NSAssert does nothing.
When you use NSAssert in a debug build of an app running on a device (not through the debugger), the message is in the device's console, not Xcode's. If you go to the "Organizer" in Xcode, choose "Devices", select your device and look at the "Console", you'll see your assertion there.
For example, I put in a line of code in a "Assertion Test" app:
NSAssert(FALSE, #"Assertion performed here");
When I look at the device's "Console" through Xcode's Organizer, I see:
Aug 6 09:10:53 Rob-iPod amfid[200] : Aug 6 09:10:53 SecTrustEvaluate [leaf CriticalExtensions IssuerCommonName]
Aug 6 09:10:53 Rob-iPod Assertion Test[199] : *** Assertion failure in -[ViewController viewDidLoad], /Users/rryan/Documents/Development/Xcode/Assertion Test/Assertion Test/ViewController.m:21
Aug 6 09:10:53 Rob-iPod kernel[0] : launchd[199] Builtin profile: container (sandbox)
Aug 6 09:10:53 Rob-iPod kernel[0] : launchd[199] Container: /private/var/mobile/Applications/7A7A62EF-8CEC-4388-932D-5C02DE77B841 (sandbox)
Aug 6 09:10:53 Rob-iPod Assertion Test[199] : *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Assertion performed here'
*** First throw call stack:
(0x315592a3 0x391d797f 0x3155915d 0x31e2eab7 0x843f7 0x33380595 0x333c0d79 0x333bcaed 0x333fe1e9 0x333c183f 0x333b984b 0x33361c39 0x333616cd 0x3336111b 0x350535a3 0x350531d3 0x3152e173 0x3152e117 0x3152cf99 0x3149febd 0x3149fd49 0x333b8485 0x333b5301 0x84149 0x3960eb20)
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : Formulating crash report for process Assertion Test[199]
Aug 6 09:10:54 Rob-iPod com.apple.launchd[1] (UIKitApplication:com.robertmryan.Assertion-Test[0x7be0][199]) : (UIKitApplication:com.robertmryan.Assertion-Test[0x7be0]) Job appears to have crashed: Abort trap: 6
Aug 6 09:10:54 Rob-iPod backboardd[26] : Application 'UIKitApplication:com.robertmryan.Assertion-Test[0x7be0]' exited abnormally with signal 6: Abort trap: 6
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Assertion Test_2013-08-06-091053_Rob-iPod.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
If you look at that fifth line, you'll see the assertion message there.
This is very situation specific ... I hadn't realised, but we had HockeyApp / QuincyKit embedded in the app.
Hockey appears to have a nasty bug where it:
captures NSAssertions
Allows them to crash
Deletes the message
Deletes the logging
... does not upload anything to the Hockey website
So ... the messages were visible in the debugger, but only in the debugger variables - I was a fool, and not paying attention: they weren't appearing in the console.
To be clear: some assertions sometimes appear in Hockey (looking at the Hockey console), but most assertions are silently missing. 100% of App crashes appear, but only about 10% of assertion crashes.

Resources