Post not yet marked as solved
Hi,
I want to query the user's current location from my widget, so I added have the 'NSWidgetWantsLocation' key in my widget's Info.plist, and added the code to find the location with CLLocationManager. But now if I launch the app for the very first time, before I even interact with the widget or do anything else, I start seeing the location permissions prompt which says "Allow <MyApp> to use your location".
If I ignore it for a few seconds, the prompt goes away, but it's back the next time the app launches. It makes for a poor user experience for users who just download the app to try it out, and might not care about the widget at all.
Why would this be happening? Does the widget run in the background even if the user never even launched the widget-picker mode? How would I know when the user *has* opened the widget, so I can see if I need to ask for location permissions or not?
Here's what I've tried: deleting the app, and then resetting Privacy prompts (same problem)
setting 'NSWidgetWantsLocation' to No stops the prompt from showing up, but defeats the purpose of finding the user's location
Thanks for the help.
Post not yet marked as solved
Hi,
I can't seem to find a way to view the Build Timeline with Xcode 14. I see a "Recent Build Timeline" option in the drop-down when I click on the top-left button in the editor (where "Recent Files" lives), but it doesn't do anything.
Do I have to build the app in some special way to make this visible?
Hi,
The presentation "Capture Machine Readable Codes and Text with VisionKit" mentions at the end that the DataScannerViewController can be used with an async stream. In the presentation, there is a code snipper for the updateViewAsyncStream method, but it's not really used anywhere. How do utilize this when the DataScannerViewController is active and capture the recognized items?
Also there is a sendDidChangeNotification() function sat the end but the compiler complains that it's not in scope.
Thanks.
Post not yet marked as solved
Hi,
I want to work with some of the new iOS16 APIs while maintaining backward compatibility with iOS15 as well as Xcode 13. I'm running into a problem here that I can't seem to store the new iOS16 API as a property of an existing class.
For e.g. I'm interested in using the new DataScannerViewController and want to store it as a property so I can reference it when scanning. If I declare it in my ViewController:
var dataScanner: DataScannerViewController?
it won't compile with Xcode13. I can't seem to also mark this with @available or #available(iOS 16) either:
if #available(iOS 16, *) {
var dataScanner: DataScannerViewController?
}
What's the best way to handle this? In Objective-C, we could use __IPHONE_OS_VERSION_MIN_REQUIRED or something to that effect to avoid this problem, but I'm not sure what the best Swift solution is.
Hi,
I am getting a crash report from a user, where they get an application crash when they open a CSV file on their device. I use the standard DataFrame(contentsOfCSVFile: fileURL, options: options) initializer to create a DataFrame, but that's where it's crashing, even though it's inside a try-catch block:
public func loadInitialCSVData(withURL fileURL: URL) throws -> DataFrame {
let options = CSVReadingOptions(hasHeaderRow: true, delimiter: ",")
do {
let dataFrame = try DataFrame(contentsOfCSVFile: fileURL, options: options)
} catch {
// log error here - doesn't get here
}
This is from the crash report:
Exception Type: SIGTRAP
Exception Codes: TRAP_BRKPT at 0x21e02be38
Crashed Thread: 0
Thread 0 Crashed:
0 TabularData 0x000000021e02be38 __swift_project_boxed_opaque_existential_1 + 9488
1 TabularData 0x000000021e099d64 __swift_memcpy17_8 + 4612
2 TabularData 0x000000021e099958 __swift_memcpy17_8 + 3576
3 TabularData 0x000000021e09935c __swift_memcpy17_8 + 2044
4 Contacts Journal CRM 0x000000010433f614 Contacts_Journal_CRM.CJCSVHeaderMapper.loadInitialCSVData(withURL: Foundation.URL) throws -> TabularData.DataFrame (CJCSVHeaderMapper.swift:26)
5 Contacts Journal CRM 0x00000001043009d8 (extension in Contacts_Journal_CRM):__C.MacContactsViewController.handleSelectedCSVFileForURL(selectedURL: Foundation.URL) -> () (MacContactsViewControllerExtension.swift:28)
6 Contacts Journal CRM 0x0000000104301e64 @objc (extension in Contacts_Journal_CRM):__C.MacContactsViewController.handleSelectedCSVFileForURL(selectedURL: Foundation.URL) -> () (<compiler-generated>:0)
7 Contacts Journal CRM 0x0000000104222c94 __51-[MacContactsViewController importCSVFileSelected:]_block_invoke (MacContactsViewController.m:954)
8 AppKit 0x00000001bbe8f294 -[NSSavePanel didEndPanelWithReturnCode:] + 84`
I can't diagnose the crash, because it doesn't have more information. I don't have access to the CSV file currently either, so I don't know what else I can do to prevent it.
What could possibly be causing this crash? Does it not matter that I am also trying to catch the errors it's throwing, or can the app crash because of some internal reasons with the framework?
Post not yet marked as solved
I'm confused about this ... the MailKit headers files seem to suggest that MailKit APIs are available for iOS16 now. But I haven't seen any documentation mention it, and you can't create a MailKit extension for iOS (using Xcode 14) like you can with macOS. So is it available to use in iOS or not? If so, how do we create an iOS target for the MailKit extension?
Post not yet marked as solved
Hi,
My app is free-to-download but with an in-app purchase to unlock all the features. A user wants to buy 15 copies of the "unlock" IAP and distribute it to his team, using MDM to distribute it easily.
I don't believe there is a way to do this through business purchases, is that right? You can only download apps through MDM but not in-app purchases. So what's the best way to do this? Are there any standard solutions?
Can I upload a new version of the app that's "paid up-front" but not available through the regular App Store, but only through MDM?
Post not yet marked as solved
Hi,
I am trying to build a Mail 'action' extension, and want to access the email body and parse it for specific content. Not sure how to go about converting the 'rawData' that comes in the MEMessage into something that I can read.
Here's how I access the rawData property:
func decideAction(for message: MEMessage, completionHandler: @escaping (MEMessageActionDecision?) -> Void) {
var action: MEMessageActionDecision? = nil
if let messageData = message.rawData {
print("messageData = \(messageData)")
// what to do here??
} else {
action = MEMessageActionDecision.invokeAgainWithBody
}
return action
}
The documentation just says this is 'unprocessed data':
The content is available after MailKit downloads the message. MailKit provides the content as unprocessed data. For details about the format of the data, see RFC 2822.
But I'm not sure what I'm supposed to do to go about converting the unprocessed 'data' into something that is accessible and useful to my app.
Let me know if you have any thoughts or recommendations
Post not yet marked as solved
Hi,
I have a paid app available through the Mac App Store, and when the user opens the app, I want to verify that the transaction of the payment is valid. I would have assumed that in StoreKit2, the 'Transaction.all' would work, but when I tested this, it shows 0 transactions for all users.
This is what I'm testing:
for await result in Transaction.all {
guard case .verified(let transaction) = result else { continue }
print("verified product = \(transaction.productID)")
// send to analytics
}
But nothing gets observed in the analytics.
Does the StoreKit2 framework have an easy way to determine transactions that are made for paid-up-front apps?
Hi,
I am trying to invoke this NSApplicationDelegate callback from my Mac app, but it's not getting called:
- (void)application:(NSApplication *)application openURLs:(NSArray<NSURL *> *)urls
I have registered the URL scheme in my Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.my.testapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>mytestapp</string>
</array>
</dict>
</array>
Now I use a 2nd Mac app to test this out, by invoking the following code:
if let url = URL(string: "mytestapp://") {
NSWorkspace.shared.open(url)
}
This causes my first app to come to the foreground, and the
"applicationDidBecomeActive:(NSNotification *)notification" method gets called, but the "application:(NSApplication *)application openURLs:(NSArray<NSURL *> *)urls" method mentioned above doesn't get invoked, which is what I want.
Any ideas about why that might be the case?
Post not yet marked as solved
Hi,
I am working on a widget for my existing Mac app. The problem I am running into is that when I add a Link from the widget to the main app, the method 'openURLs' isn't called at all:
- (void) application: (NSApplication *)application openURLs:(NSArray<NSURL *> *)urls
So I'm not able to direct the app on how to best handle the widget tap.
I'm trying to work around that by trying to detect if a Link was selected. Something like this could work
Link("Test", destination: URL(string: "https://duckduckgo.com")!)
.environment(\.openURL, OpenURLAction { url in
print("---> testing link actioned")
return .systemAction
})
When I add this to the main app, it works fine. But when I add something like this to the widget, the completion handler isn't called (supposedly).
Can someone confirm if this was supposed to work inside a widget? Or is it only something that works from the main app?
Post not yet marked as solved
Hi,
I have a paid app in the Mac App Store, and I want to verify that the user purchased the app legitimately. Does the StoreKit2 framework have an easy way to determine this? From the documentation I've seen, I believe the 'Transaction.currentEntitlements' call will only return transactions for IAP and subscriptions. I would assume that 'Transaction.all' would work, but when I run the app (with Xcode debugger attached) I get no results.
What's the best way to test this out for an app that's going to be paid-up-front?
Post not yet marked as solved
I want to use the "SF Pro Text" font in my app. It works fine when I build my app on my main computer running macOS11 Big Sur, but I have a 2nd partition to run macOS Monterey, and it doesn't seem to be available there at all, whether through Interface Builder or through code (using NSFontManager).
Using this returns nil on my Monterey partition:
NSFont* regularFont = [[NSFontManager sharedFontManager] fontWithFamily:@"SF Pro Text" traits:NSFontWeightRegular weight:5 size: 16.0];
Maybe I'm missing something here ... should I have to install the font manually? I thought the SF Font is a 'system font', so it would be available on all Macs?
Post not yet marked as solved
Hi,
When I login to App Store connect, I get a banner message saying "Review the updated Paid Applications Schedule":
In order to update your existing apps, create new in-app purchases, and submit new apps to the App Store, the user with the Legal role (Account Holder) must review and accept the Paid Applications Schedule (Schedule 2 to the Apple Developer Program License Agreement) in the Agreements, Tax, and Banking module.
When I click the link, select "View and Agree Terms", and select the checkbox and select the "Agree" button to accept the terms, I get an error message:
We are currently unable to process your request. Please try again later.
This has been happening for the past 2 days now. What should I try to do to overcome this problem? I'll file a bug with Apple, but it takes them many days to respond to these issues usually.
Post not yet marked as solved
Hi,
I have an existing AppKit-based Mac app that I have been working on for a few years. For a new feature, I wanted to have the app opened by a different app, so I setup the URL scheme under CFBundleURLTypes in my Info.plist, and adopted this delegate callback:
- (void)application: (NSApplication *)application openURLs:(nonnull NSArray<NSURL *> *)urls
Now when I invoke the URL from the 2nd app, it opens my app correctly, BUT this delegate method isn't called. What's interesting is that if I make a totally new app with a URL scheme and adopt this delegate method, it gets called without a problem!
SO what about my original project could be responsible for this 'opensURLs' method to not be called? I've been searching for a solution for a couple of days without any luck. The macOS app's target has a Deployment Target of 10.15 and I'm running this on macOS12.0 with Xcode 13.