Welcome to the Apple Developer Forums:

Find answers, ask questions, and share comments on development topics with fellow developers and Apple engineers. 

To get started, search for keywords (like “app distribution”), standard tags (like [SwiftUI]), or WWDC tags (like [WWDC21]).

Learn different ways to search and use the forums

See all WWDC21 tags

Posts

Sort by:
Post not yet marked as solved
6 Views

IOS 15, javascript functions window.getSelection() or document.getSelection() not working

Hi we do have a functionality where we need to highlight some content. Our functionality was using javascript functions window.getSelection() or document.getSelection(). These were working fine with IOS 14. when our devices were updated to IOS 15, we are getting null for either window.getSelection() or document.getSelection(). Could you please help us to resolve this issue? we appreciate your help.
Asked
Post not yet marked as solved
20 Views
Post not yet marked as solved
12 Views

iOS 15 Crash on [WebLowPowerModeObserver _didReceiveLowPowerModeChange] when convert HTML to NSAttributedString

The app which is archived by XCode 12.5 and running on iOS 15 when I convert HTML to NSAttributedString. (iOS 14 is fine). Here is the crash report. Thread 0 name: Thread 0 Crashed: 0 libsystem_platform.dylib 0x00000001f2e5e0c0 _os_unfair_lock_recursive_abort + 36 (lock.c:508) 1 libsystem_platform.dylib 0x00000001f2e58a10 _os_unfair_lock_lock_slow + 304 (lock.c:567) 2 Foundation 0x00000001841e6730 -[NSProcessInfo(NSProcessInfoHardwareState) isLowPowerModeEnabled] + 68 (NSProcessInfo.m:708) 3 WebCore 0x0000000192499004 -[WebLowPowerModeObserver _didReceiveLowPowerModeChange] + 56 (LowPowerModeNotifier.mm:63) 4 CoreFoundation 0x00000001829bdee8 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:652) 5 CoreFoundation 0x0000000182a59b9c ___CFXRegistrationPost_block_invoke + 52 (CFNotificationCenter.c:173) 6 CoreFoundation 0x0000000182a2cf54 _CFXRegistrationPost + 456 (CFNotificationCenter.c:199) 7 CoreFoundation 0x00000001829d3d54 _CFXNotificationPost + 716 (CFNotificationCenter.c:1147) 8 Foundation 0x00000001841d8028 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96 (NSNotification.m:560) 9 Foundation 0x00000001842509d4 NSProcessInfoNotifyPowerState + 188 (NSProcessInfo.m:693) 10 Foundation 0x00000001841e6768 -[NSProcessInfo(NSProcessInfoHardwareState) isLowPowerModeEnabled] + 124 (NSProcessInfo.m:714) 11 WebCore 0x0000000191a1d118 -[WebLowPowerModeObserver initWithNotifier:] + 96 (LowPowerModeNotifier.mm:50) 12 WebCore 0x000000019249916c WebCore::LowPowerModeNotifier::LowPowerModeNotifier(***::Function<void (bool)>&&) + 52 (LowPowerModeNotifier.mm:76) 13 WebCore 0x00000001933bec4c WebCore::Page::Page(WebCore::PageConfiguration&&) + 1848 (memory:2099) 14 WebKitLegacy 0x00000001a64e2e34 -[WebView(WebPrivate) _commonInitializationWithFrameName:groupName:] + 3060 (WebView.mm:1568) 15 WebKitLegacy 0x00000001a64e2214 -[WebView(WebPrivate) _initWithFrame:frameName:groupName:] + 116 (WebView.mm:1715) 16 UIFoundation 0x000000018d78e028 -[NSHTMLReader _loadUsingWebKit] + 832 (NSHTMLReader.m:2570) 17 UIFoundation 0x000000018d78f15c -[NSHTMLReader attributedString] + 32 (NSHTMLReader.m:3212) 18 UIFoundation 0x000000018d7484e8 _NSReadAttributedStringFromURLOrData + 8420 (NSAttributedStringAdditions.m:2651) 19 UIFoundation 0x000000018d746378 -[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 156 (NSAttributedStringAdditions.m:1462) 20 MyAppExtensions 0x108aa0894 NSAttributedString.init(htmlString:font:useDocumentFontSize:) + 36 (__hidden#925_:36) 21 MyAppName 0x1045eca18 {foo_class}.convertHTML(_:) + 670 (xxxx.swift:670) 22 MyAppName 0x1045e5c58 {foo_class}.some_function_3 + 620 (xxxx.swift:620) 23 MyAppName 0x1045e4760 {foo_class}.some_function_2 + 212 (xxxx.swift:212) 24 MyAppName 0x1045e4200 {foo_class}.some_function_1 + 138 (xxxx.swift:138) . (some other functions related to my business logic) . . . 37 CoreFoundation 0x00000001829b5304 __invoking___ + 148 38 CoreFoundation 0x00000001829d2ad4 -[NSInvocation invoke] + 468 (NSForwarding.m:3378) 39 CoreFoundation 0x0000000182a09934 -[NSInvocation invokeWithTarget:] + 80 (NSForwarding.m:3475) 40 Lime 0x00000001037fba58 0x102838000 + 16530008 41 CoreFoundation 0x00000001829c118c ___forwarding___ + 968 (NSForwarding.m:3626) 42 CoreFoundation 0x00000001829c05c0 _CF_forwarding_prep_0 + 96 43 MyAppName 0x0000000103807558 0x102838000 + 16577880 44 MyAppName 0x000000010382084c 0x102838000 + 16681036 45 UIKitCore 0x000000018501d584 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 56 (UIGestureRecognizer.m:136) 46 UIKitCore 0x0000000184fe61d0 _UIGestureRecognizerSendTargetActions + 116 (UIGestureRecognizer.m:1481) 47 UIKitCore 0x0000000184faf05c _UIGestureRecognizerSendActions + 284 (UIGestureRecognizer.m:1520) 48 UIKitCore 0x0000000184fe8580 -[UIGestureRecognizer _updateGestureForActiveEvents] + 636 (UIGestureRecognizer.m:0) 49 UIKitCore 0x0000000184fa06fc _UIGestureEnvironmentUpdate + 1988 (UIGestureEnvironment.m:206) 50 CoreFoundation 0x00000001829d4570 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 (CFRunLoop.c:1804) 51 CoreFoundation 0x00000001829a3854 __CFRunLoopDoObservers + 572 (CFRunLoop.c:1917) 52 CoreFoundation 0x000000018299e8ec __CFRunLoopRun + 1052 (CFRunLoop.c:2979) 53 CoreFoundation 0x00000001829b23c8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268) 54 GraphicsServices 0x000000019e1c338c GSEventRunModal + 164 (GSEvent.c:2200) 55 UIKitCore 0x00000001853580bc -[UIApplication _run] + 1100 (UIApplication.m:3457) 56 UIKitCore 0x00000001850d5be8 UIApplicationMain + 2124 (UIApplication.m:5013) 57 libswiftUIKit.dylib 0x0000000199f86184 UIApplicationMain(_:_:_:_:) + 104 (UIKit.swift:530) 58 Lime 0x000000010284d894 main + 180 (main.swift:7) 59 dyld 0x0000000104e59a24 start + 520 (dyldMain.cpp:876) Any thoughts? Thanks
Asked
by chen_.
Post not yet marked as solved
10 Views

Instruments command-line won't work for me

On three different machines (all running Xcode 13 and Big Sur), it always tells me that the command-line developer tools need to be installed. I've "installed" them four times so far on one machine, and at least twice on the other two.
Asked
by kithrup.
Post not yet marked as solved
7 Views

Instruments command-line won't work for me

On three different machines (all running Xcode 13 and Big Sur), it always tells me that the command-line developer tools need to be installed. I've "installed" them four times so far on one machine, and at least twice on the other two.
Asked
by kithrup.
Post not yet marked as solved
13 Views

iBeacon Support in macOS

Do iBeacons work on macOS at all? I see the necessary APIs, but they do not appear to do anything. When I look at the CLLocationManager and other documentation, I see macOS listed as supported. But my experience suggest that it is not.
Asked
by j2inet.
Post not yet marked as solved
23 Views

SwiftUI: Pop back from NavigationLink in TabView crashes tvOS app

I am trying to make a simple tvOS app. I was testing some basic SwiftUI code shown here: struct ContentView: View { var body: some View { TabView { NavigationView { NavigationLink(destination: Text("Subview")) { Text("Subview") } } .tabItem { Text("Main") } NavigationView { Text("Settings") } .tabItem { Text("Settings") } } } } ContentView() is called directly from the entry point: @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } When testing this code on my Apple TV (Apple TV 4K, running tvOS 15.0), the app launches successfully. I can switch between tabs and click on the NavigationLink to go to the subview. However, when pressing the back/menu button on the Apple TV Remote, the app closes with the following error: [Common] Error response from snapshot request action of type 1 gave Error Domain=BSActionErrorDomain Code=1 "(null)" Is this intended behavior? Looking at the resources and documentation online it appears like NavigationViews nested inside TabViews should work as expected. Any feedback about what the error is trying to explain might be helpful too, as the vague output makes it difficult to determine if this is an issue with my SwiftUI code or if it is a bug with tvOS and SwiftUI. Thanks!
Asked
by Sammcb.
Post not yet marked as solved
9 Views

Calling an AppleScript application from a Java Program

Code Example I am trying to call an AppleScript application from a Java program. I found this code example: package com.devdaily.mac.applescript; import java.io.IOException; public class MultilineAppleScriptTest { public static void main(String[] args) { new MultilineAppleScriptTest(); } public MultilineAppleScriptTest() { Runtime runtime = Runtime.getRuntime(); // an applescript command that is multiple lines long. // just create a java string, and remember the newline characters. String applescriptCommand = "tell app \"iTunes\"\n" + "activate\n" + "set sound volume to 40\n" + "set EQ enabled to true\n" + "play\n" + "end tell"; String[] args = { "osascript", "-e", applescriptCommand }; try { Process process = runtime.exec(args); } catch (IOException e) { e.printStackTrace(); } } } Problem When searching for the package "com.devdaily.mac.applescript" it references in Eclipse for installing new software, it does not find the package or even just searching for "applescript" in general. So, this must be a one off custom package the author created. Any ideas on locating this package OR do you know of any other examples I can try that performs a similar purpose? Thank you!
Asked
by robhoth.
Post not yet marked as solved
19 Views

Packaging a Java Application ITMS-90238: Invalid Signature Error

Hi, When packaging an application using JDK 17 and the latest version of jpackage I get the below error when uploading to the App Store. All test prior to uploading complete just fine. I think it might be realated to the structure of the .app folder but not sure, any ideas would be helpful ITMS-90238: Invalid Signature - The main app bundle Test at path Test.app has following signing error(s): a sealed resource is missing or invalid. Refer to the Code Signing ... and ITMS-90296: App sandbox not enabled - The following executables must include the 'com.apple.security.app-sandbox' entitlement with a Boolean value of true in the entitlements property list: [[Test.app/Contents/MacOS/Test]] The app verifies in Transporter just fine and codesign as well. codesign --verify --verbose=4 'Test.app' Test.app: valid on disk Test.app: satisfies its Designated Requirement Also entitlements seems to be fine. codesign -d --entitlements :- ./Test.app/Contents/MacOS/Test Executable=/Users/ryan/flat/Test.app/Contents/MacOS/Test <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.cs.allow-jit</key> <true/> <key>com.apple.security.cs.allow-unsigned-executable-memory</key> <true/> <key>com.apple.security.cs.disable-library-validation</key> <true/> <key>com.apple.security.cs.allow-dyld-environment-variables</key> <true/> <key>com.apple.security.cs.debugger</key> <true/> </dict> </plist> The app structure looks like the below, noting runtime contains the java runtime and app contains the application jar file. ls -al ./Test.app/Contents total 16 drwxr-xr-x 9 ryan staff 288 27 Sep 08:36 . drwxr-xr-x 3 ryan staff 96 27 Sep 08:35 .. -rw-r--r-- 1 ryan staff 1229 27 Sep 08:36 Info.plist drwxr-xr-x 3 ryan staff 96 27 Sep 08:36 MacOS -rw-r--r-- 1 ryan staff 8 27 Sep 08:36 PkgInfo drwxr-xr-x 3 ryan staff 96 27 Sep 08:36 Resources drwxr-xr-x 3 ryan staff 96 27 Sep 08:36 _CodeSignature drwxr-xr-x 6 ryan staff 192 27 Sep 08:36 app drwxr-xr-x 3 ryan staff 96 27 Sep 08:35 runtime The jpackage commands looks like the below: Noting that in the first, jpackage finds the correct certificate and entitlements because of the option --mac-app-store Further details can be found here https://docs.oracle.com/en/java/javase/17/jpackage/support-application-features.html#GUID-8D9F0607-91F4-4070-8823-02FCAB12238D rm -rf Test.app iconutil --convert icns flat.iconset /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/jpackage \ -i input \ -n Test \ --app-version 1.0.9 \ --main-class com.formdev.flatlaf.demo.FlatLafDemo \ --main-jar flatlaf-demo-1.6.jar \ --icon flat.icns \ --mac-package-name Test \ --mac-package-identifier "com.formdev.flatlaf.demo.FlatLafDemo" \ --java-options -Xmx2048m \ --mac-sign \ --mac-app-store \ --mac-signing-key-user-name "Ryan Henderson (A8KKM73GSU)" \ --type app-image --verbose codesign --verify --verbose=4 'Test.app' rm -rf *.pkg /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/jpackage \ -n Test \ --app-version "1.0.9" \ --description "Test Pkg" \ --vendor "Ryan" \ --copyright "Ryan" \ --app-image Test.app \ --mac-app-store \ --mac-sign \ --mac-signing-key-user-name "3rd Party Mac Developer Installer: Ryan Henderson (A8KKM73GSU)" \ --type pkg If you want I can also supply the verbose output from the .app generation and the .pkg generation using jpackage. From what I can see it's doing all the right things when signing etc. Thanks Ryan
Asked
by Ryanhend.
Post not yet marked as solved
13 Views

How do you apply a diffable data source UI snapshot only after awaiting (with async/await) data fetched from the network?

I'm new to async/await, and am currently migrating my completion handler code to Swift 5.5's concurrency features. After generating an sync alternative in Xcode to my function func fetchMatchRecords(completion: @escaping ([Match]) -> Void), it becomes func fetchMatchRecords() async -> [Match]. I'm not sure how it would be used in the context of UIKit and diffable data sources. In a viewDidLoad, previously it would be MatchHistoryController.shared.fetchMatchRecords() { matches in DispatchQueue.main.async { self.dataSource.apply(self.initialSnapshot(), animatingDifferences: false) } } But I'm not sure how it would be used now Task { await MatchHistoryController.shared.fetchMatchRecords() } self.dataSource.apply(self.initialSnapshot(), animatingDifferences: false) How would I make sure that the snapshot is applied only after awaiting a successful fetch result? Here's the definition of initialSnapshot() that I used: func initialSnapshot() -> NSDiffableDataSourceSnapshot<Section, Match> { var snapshot = NSDiffableDataSourceSnapshot<Section, Match>() snapshot.appendSections([.main]) snapshot.appendItems(MatchHistoryController.shared.matches) return snapshot }
Asked
by Curiosity.
Post not yet marked as solved
29 Views

Xcode Mac Catalyst Share Extension import problem

When I setup Share extension or Action extension on iOS to import a Vcard into my app it works great but when running the app on Mac catalyst I'm left with a Vcard at the bottom of my screen and I can't close it or do anything, deleting the app and reinstalling doesn't even fix it, I'm going to have to format my computer. How do I deal with these? the just keep building up, How do I make sure my app doesn't do this? How do I close the ones that are open, I'm stuck. Theres a few things I tried. The .plist option to 'Supports Document Browser' is set to 'No' 'Supports opening documents in place' has to be se to 'Yes' or not included for a Mac Catalyst app or I get this error - error: 'LSSupportsOpeningDocumentsInPlace = NO' is not supported on macOS. Either remove the entry or set it to YES, and also ensure that the application does open documents in place on macOS. What I'm thinking is I did not ensure that the app did not open a document in place? Now I have no idea how to undo what I've done. Its just stuck there, attached to my app somehow. I tried deleting the app and all the files associated to the app I could find, but its still there. How do I prevent this from happening but still get all the card info into my app. it does work to populate the card info into my app, its just this thing here is not closing or I don't want that to happen, that's probably what the error is warning me about.
Asked
Post not yet marked as solved
78 Views

Can NSTextView work with custom NSTextContentManager implementation? (TextKit2)

I'm trying to implement custom NSTextContentManager and use it with NSTextView, however it seems that NSTextView expect NSTextContentStorage all the time. final class MyTextContentManager: NSTextContentManager { // ... } It's added to layout manager, and NSTextView instance finds it properly: let textContentManager = MyTextContentManager() textContentManager.addTextLayoutManager(textLayoutManager) however, when I use it, I see errors at: [MyTextContentManager textStorage]: unrecognized selector sent to instance 0x600003d84870 the textStorage property is part of NSTextStorageObserving, that is not NSTextContentManager interface. It looks like NSTextView is not ready to work with custom NSTextContentManager. What did I miss?
Asked
Post not yet marked as solved
21 Views

Uploading firmware via Bluetooth is not working in iOS

We were DFU-Library to upload firmware to our BLE accessory earlier. But our new set of accessories doesn't support DFU library and we need to upload the firmware to an OTA service in its respective characteristics and we does the same using following code, var offset = 0 var bytesToSend = fromData.count let packetSize = BoardInformationService.packetSize var chunkArray: [Data] = [] repeat { let chunkLength = min(bytesToSend, packetSize) let chunk = fromData.subdata(in: Int(offset) ..< Int(offset + chunkLength)) chunkArray.append(chunk) offset += chunkLength bytesToSend -= chunkLength } while bytesToSend > 0 print("BT: Total Chunk size:\(chunkArray.count)") return chunkArray } func uploadNextChunk() { if let firmwareCharacteristic = fileCharacteristic { print("Found fileCharacteristic to upload") if self.currentPacket < self.totalNumberOfPackets { // Send next chunk let nextPacket = self.fileByteChunkArray[self.currentPacket] print("BT: current packet uploading: \(self.currentPacket)/\(self.totalNumberOfPackets) Data:\(nextPacket)") self.currentPacket += 1 // Write to peripheral BTDiscovery.sharedInstance().peripheralBLE.writeValue(nextPacket, for: firmwareCharacteristic, type: .withResponse) } else { updateCompleteCompletion!() } } else { print("No fileCharacteristic to upload") } } // This is a delegate method which gets called when we get response from our peripheral after sending each packet. func ackReceivedFromPeripheral() { uploadNextChunk() } But this doesn't work on iOS but the same approach working on Android. Can you please guide me what could be wrong here.
Asked
by ios__dev.