Posts

Post not yet marked as solved
0 Replies
61 Views
I have a View that consists of a NavigationView. I set its style to .stack using .navigationViewStyle to force the 'stacked' modal look when appropriate (I am displaying it modally from UIKit using a UIHostingController). This works fine but I need the view to detect if it's actually shown using the stacked look or not at runtime (on an iPhone in landscape mode, it will be displayed as full screen and I need to add a Close/Dismiss button in that specific case). Suggestions?
Posted
by bbousquet.
Last updated
.
Post marked as solved
10 Replies
30k Views
My iOS app supports a document type and includes the appropriate UTI data. It can therefore open documents of a specific type from mail attachments, for instance. It works well.I am currently stumped, however: when I open a document from the iCloud Drive app (tap document, share button, "Copy to <app>") my application gets launched but any attempts to copy the item from the provided URL fails with NSCocoaErrorDomain, error 257 (basically telling me I don't have the permissions to read the file). This issue is not present when my app is running in the background, however, and does not seem to occur when the app gets launched from a mail attachment (whether it's running ot not).I compared the URLs handed to my app and they are identical, whether the app was running or not.Here's the URL my app is handed: "file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/filename.ext"The code I'm using is the following:// uniqueURL is a destination URL in my app's sandbox: // file:///var/mobile/Containers/Data/Application/12AB2BA0-EA63-4FAC-A7D8-779964868B06/Documents/filename.ext dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { let fileCoordinator = NSFileCoordinator(filePresenter: nil) fileCoordinator.coordinateReadingItemAtURL(url, options: .WithoutChanges, error: nil) { newURL in do { try NSFileManager.defaultManager().copyItemAtURL(newURL, toURL: uniqueURL) } catch { print("Error!") // this is where I'm getting NSCocoaErrorDomain:257 } }This issue seems to be identical to that other thread:https://forums.developer.apple.com/message/29985#29985However, I'm not running on a beta OS. My device is an iPhone 6s running iOS 9.3.2 (13F69).
Posted
by bbousquet.
Last updated
.
Post not yet marked as solved
1 Replies
263 Views
I have a UICollectionViewController in shared iOS/tvOS code. On iOS I use context menus while I fallback to UIAlertController (alert sheet) triggered by a long press on tvOS. viewDidLoad: override func viewDidLoad() {     super.viewDidLoad() // ...     #if os(tvOS)     let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction(_:))) collectionView.addGestureRecognizer(longPressGestureRecognizer)     #endif } Selector: #if os(tvOS) @objc func longPressAction(_ sender: UIGestureRecognizer) {     guard sender.state == .began else {         return     }     if let indexPath = collectionView.indexPathForItem(at: sender.location(in: collectionView)) {         let ac = UIAlertController(/* ... */) // alert sheet         present(ac, animated: true, completion: nil)     } } #endif Upon long pressing, the alert sheet gets displayed properly on tvOS but the first tap on one of the sheet actions is ignored (this calls longPressAction again with a .cancel state). I tried inserting a sender.isEnabled = false after the guard but it simply caused the .cancel state to come in faster while still eating the first tap. Suggestions?
Posted
by bbousquet.
Last updated
.
Post marked as solved
2 Replies
302 Views
I have a UITableViewController shared between my iOS and tvOS apps. In order to refresh some of the cells, I call reloadRows. It works fine as far as updating the cell's data but, on tvOS, it moves the focus back to the top of the table. I've noticed that preferredFocusEnvironments does not get called (unlike what happens when I do reloadData). This is pretty much the same issue mentioned in the following post (years ago): https://developer.apple.com/forums/thread/67219 Any suggestions?
Posted
by bbousquet.
Last updated
.
Post not yet marked as solved
0 Replies
697 Views
My iOS app needs to open data files from iCloud drive to flash some of our devices. We use .hex and .bin file extensions. I'm supplying the appropriate document types to UIDocumentPickerViewController (I have also defined them in my Info.plist's Imported UTIs section). UIDocumentPickerViewController keeps the .bin files grayed out, however. I understand that these fall under the system defined "com.apple.macbinary-archive" type. Is there any way to let the document picker mark those as available or should I just rely on renaming the file?
Posted
by bbousquet.
Last updated
.
Post marked as solved
4 Replies
6.6k Views
I've been experimenting with SwiftUI and couldn't figure out how to get a simple UIToolbar to appear at the bottom of the screen.Basic view:struct MyView : View { var body: some View { NavigationView { List { NavigationButton(destination: Text("1")) { Text("Element 1") } // ... }.navigationBarTitle(Text("Elements")) } } }
Posted
by bbousquet.
Last updated
.
Post not yet marked as solved
2 Replies
766 Views
I'm in the process of converting my local frameworks to local Swift packages. Things are (mostly) working well but I'm struggling with one of the packages: Package MyKit is used by an iOS and a tvOS app. It includes a storyboard for each platform. What is the most appropriate way to describe this in Package.swift? Xcode complains about iOS storyboards not being supported on tvOS so I moved them to their own targets, like this: let package = Package(     name: "MyKit",     defaultLocalization: "en",     platforms: [         .tvOS(.v13)     ],     products: [         // Products define the executables and libraries a package produces, and make them visible to other packages.         .library(             name: "MyKit",             targets: ["MyKit"]),     ],     dependencies: [         // Dependencies declare other packages that this package depends on.         // .package(url: /* package url */, from: "1.0.0"),     ],     targets: [         // Targets are the basic building blocks of a package. A target can define a module or a test suite.         // Targets can depend on other targets in this package, and on products in packages this package depends on.         .target(             name: "MyKit",             dependencies: [                 .target(name: "MyKit-iOS", condition: .when(platforms: [.iOS])),                 .target(name: "MyKit-tvOS", condition: .when(platforms: [.tvOS])),             ]),         .target(             name: "MyKit-iOS",             dependencies: []),         .target(             name: "MyKit-tvOS",             dependencies: [])     ] This builds fine but it seems clunky to me (and I'm having issues accessing the Main.storyboard file from the package itself.
Posted
by bbousquet.
Last updated
.
Post marked as solved
8 Replies
1.4k Views
Dabbling with Network.framework to see if I can replace some old socket based code on iOS. I was able to establish a TCP connection and send/receive data but I'm puzzled as to how receive timeouts should be handled: I can code my own timeouts using GCD but there doesn't seem to be a way to actually cancel the pending receive (it does seem to timeout by itself after a minute or so, tearing down the NWConnection with it - definitely not what I'm looking for).Any suggestions?
Posted
by bbousquet.
Last updated
.
Post marked as solved
1 Replies
1.2k Views
Our iOS app talks to our own BLE accessory using CoreBluetooth. This has been working for a few months on all our devices (I have personally tested it on iPod touch 6th gen, iPad mini 2, iPhone 5s, iPhone 6s and iPhone 7). We just got our hands on an iPad mini 4 and, for some reason, have been experiencing issues:- the initial connection triggers the iOS pairing dialog- after entering the proper passkey I am able to read values from the device just fine- any subsequent attempts at reading value (CBPeripheral.readValue) just sits there and the didUpdateValue delegate method is never calledI've been trying to figure out what's happening and, I was looking at the device logs, noticed the following:Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Notice>: Received XPC message "CBMsgIdCharacteristicReadValue" from session "net.prolon.Focus-central-746-120" Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Notice>: Reading value for characteristic handle 0x002d on device "<private>" Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Error>: Failed to encrypt connection BM3 STATUS 706. (status=65535) Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Notice>: encryptionStatusChangedCb handle:0x11e002fc0 status=706 address=<private> isPairing=0 Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Notice>: Encryption is now disabled for device "D51E8EAE-04F0-6B66-2EBE-D6DDA57A61DE" (<private>) Oct 23 13:18:38 iPad-mini-03 bluetoothd[77] <Notice>: Clearing database cache for device "<private>"I am not getting this error line on my other devices. Any idea what this is? I am trying to pinpoint the cause of the problem - I even tried to identify which hardware Bluetooth controller was present in the different iOS devices to try and detect a pattern of some sort.
Posted
by bbousquet.
Last updated
.
Post marked as solved
5 Replies
2.7k Views
I have been tweaking our app for iOS 11 but Xcode 9.0 b5 crashes as soon as I attempt to edit my main storyboard (build/run work fine). Xcode 9.0 b4 has no issues with the same file. Crash report will follow at the bottom of this post.I have identified the crash as being caused by the presence of 4 navigation controllers in the storyboard. Removing them with a text editor allows Xcode to display the storyboard (minus the offending navigation controllers). These were used to bring up view controllers modally when bar button items were tapped. The only common thread amongst those seem to be the fact that they aren't a visible part of their scene (the bar button items are attached as outlets and added to the toolbar or navigation bar if relevant). Note that recreating a show segue from the same bar button items causes Xcode to crash instantly.Since I get no warnings and the app builds & runs normally, I'm not overly worried. Just wondering if anyone else has been experiencing a similar issue.Crash report:Process: Xcode [33099] Path: /Applications/Xcode-beta.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 9.0 (13226.5) Build Info: IDEFrameworks-13226005000000000~14 Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: Xcode [33099] User ID: 1700997662 Date/Time: 2017-08-10 15:45:59.315 -0400 OS Version: Mac OS X 10.12.6 (16G29) Report Version: 12 Anonymous UUID: 4C707867-0F4B-A4D5-CFF4-F497B7B7F058 Time Awake Since Boot: 1200000 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: ProductBuildVersion: 9M202q ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-13178.6/InterfaceBuilderKit/Document/StoryboardDocument/Metrics/IBStoryboardMetricsInferrer.m:128 Details: Failed to push inherited simulated metrics to all scenes. Object: <IBStoryboardMetricsInferrer: 0x7fb91138a690> Method: -rebuildInferredMetrics Thread: <NSThread: 0x7fb907c18050>{number = 1, name = main} Hints: 0: Replacement view is installing: <IBStoryboardCanvasViewController: 0x7fb911167ee0 representing: (null)> Backtrace: 0 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit) 1 _DVTAssertionHandler (in DVTFoundation) 2 _DVTAssertionFailureHandler (in DVTFoundation) 3 -[IBStoryboardMetricsInferrer rebuildInferredMetrics] (in IDEInterfaceBuilderKit) 4 -[DVTDelayedInvocation runBlock:] (in DVTFoundation) 5 -[DVTDelayedInvocation invokeIfNeeded] (in DVTFoundation) 6 -[DVTDelayedInvocation invoke] (in DVTFoundation) 7 -[IBCocoaTouchDocumentPlatformAdapter updateDocumentSimulatedMetricsWithDeviceConfiguration:] (in IDEInterfaceBuilderCocoaTouchIntegration) 8 -[IBDocument switchToDeviceConfigurationWithoutFrameDeciding:] (in IDEInterfaceBuilderKit) 9 -[IBDocument switchToDeviceConfiguration:] (in IDEInterfaceBuilderKit) 10 -[IBCanvasViewController _addDeviceBarIfNeeded] (in IDEInterfaceBuilderKit) 11 -[IBAbstractDocumentEditor didFinishLoadingSubViewControllers] (in IDEInterfaceBuilderKit) 12 -[IBAbstractDocumentEditor replacementView:didInstallViewController:] (in IDEInterfaceBuilderKit) 13 __42-[DVTReplacementView _setupViewController]_block_invoke (in DVTKit) 14 DVTInvokeWithFailureHint (in DVTFoundation) 15 -[DVTReplacementView _setupViewController] (in DVTKit) 16 -[DVTReplacementView installedViewController] (in DVTKit) 17 -[IBAbstractDocumentEditor viewDidInstall] (in IDEInterfaceBuilderKit) 18 -[IBStoryboardDocumentEditor viewDidInstall] (in IDEInterfaceBuilderKit) 19 -[DVTViewController _viewDidInstall] (in DVTKit) 20 -[_DVTViewController_ViewLifecycleInterpositions viewDidMoveToWindow] (in DVTKit) 21 -[NSView _setWindow:] (in AppKit) 22 -[NSView addSubview:] (in AppKit) 23 -[NSView setSubviews:] (in AppKit) 24 -[DVTBorderedView setContentView:] (in DVTKit) 25 -[IDEEditorContext _setEditorView] (in IDEKit) 26 -[IDEEditorContext setupNewEditor:] (in IDEKit) 27 __91-[IDEEditorContext _openNavigableItem:documentExtension:document:shouldInstallEditorBlock:]_block_invoke (in IDEKit) 28 -[IDEEditorContext _performBlockInsideReentrantGuard:] (in IDEKit) 29 -[IDEEditorContext _openNavigableItem:documentExtension:document:shouldInstallEditorBlock:] (in IDEKit) 30 -[IDEEditorContext _openNavigableItem:withContentsOfURL:documentExtension:shouldInstallEditorBlock:] (in IDEKit) 31 -[IDEEditorContext _notifyDelegateAndOpenNavigableItem:withContentsURL:documentExtensionIdentifier:locationToSelect:annotationRepresentedObject:stateDictionary:annotationWantsIndicatorAnimation:exploreAnnotationRepresentedObject:highlightSelection:alwaysReplaceExistingNavigableItem:skipSubDocumentNavigationUnlessEditorIsReplaced:] (in IDEKit) 32 -[IDEEditorContext _notifyDelegateAndOpenEditorOpenSpecifier:updateHistory:] (in IDEKit) 33 -[IDEEditorContext openEditorOpenSpecifier:updateHistory:] (in IDEKit) 34 -[IDEEditorContext openEditorOpenSpecifier:] (in IDEKit) 35 -[IDEEditorModeViewController openEditorOpenSpecifier:editorContext:] (in IDEKit) 36 -[IDEEditorArea _openEditorOpenSpecifier:editorContext:takeFocus:] (in IDEKit) 37 __108+[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:]_block_invoke_2 (in IDEKit) 38 __108+[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:]_block_invoke (in IDEKit) 39 +[IDEEditorCoordinator _doOpenWithWorkspaceTabController:editorContext:target:allowFallback:documentURL:usingBlock:] (in IDEKit) 40 +[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:] (in IDEKit) 41 -[_IDEOpenRequest _primitiveRunIfNecessary] (in IDEKit) 42 -[_IDEOpenRequest _runIfNecessary] (in IDEKit) 43 __NSFireDelayedPerform (in Foundation) 44 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ (in CoreFoundation) 45 __CFRunLoopDoTimer (in CoreFoundation) 46 __CFRunLoopDoTimers (in CoreFoundation) 47 __CFRunLoopRun (in CoreFoundation) 48 CFRunLoopRunSpecific (in CoreFoundation) 49 RunCurrentEventLoopInMode (in HIToolbox) 50 ReceiveNextEventCommon (in HIToolbox) 51 _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox) 52 _DPSNextEvent (in AppKit) 53 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit) 54 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit) 55 -[NSApplication run] (in AppKit) 56 NSApplicationMain (in AppKit) 57 start (in libdyld.dylib)
Posted
by bbousquet.
Last updated
.