Post

Replies

Boosts

Views

Activity

MailKit: access rawData for email
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
2
0
1.6k
Apr ’22
StoreKit2 to validate purchase of paid-app
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?
2
0
1.2k
Mar ’22
Detecting Link tap inside WidgetKit
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?
0
0
678
Mar ’22
StoreKit2: does Transaction.all include paid apps?
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?
1
0
1.1k
Mar ’22
Swift: using new iOS16-only API as a property
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.
0
0
2.6k
Jun ’22
DataScannerViewController in Objective-C
Hi, Is DataScannerViewController available to be called directly from Objective-C? I see the header file has an "objc" attribute on it, but trying to initialize it from an Objective-C file doesn't seem to be working for me. Maybe it's something I'm doing wrong, but I wanted to first clarify and confirm that if it indeed possible to use it directly in Objective-C, or not?
1
0
1k
Aug ’22
StoreKit2: save currentEntitlements in keychain
Hi, With StoreKit2 giving us the up-to-date subscription status using Transaction.currentEntitlements, is there any value in storing the status separately in keychain as well? Or will that just add an unnecessary layer to manage (and possibly mess up)? I just want to subscription status to know if I need to unlock certain features in the app or not, and wondering if just looking at currentEntitlements and saving that in my Store object is enough. Thanks.
1
0
857
Oct ’22
Xcode Organizer not letting me distribute to Mac App Store
I recently had to make a change to my Mac app where I need to add a special "Contact Notes" entitlement, so that means that I can't rely on "Automatic Code Signing" anymore. So here are the steps I took to build and distribute the app with manual code signing: from "Certificates, Identifiers & Profiles" from the Developer, I added entitlement to my app identifier, and then created new manual provisioning profiles (one for "macOS App Development" under Development, and one for "Mac App Store" under Distribution) in Xcode, added the entitlement to the Entitlements files in Xcode, in Signing & Capabilities, unselected the checkbox for "Automatically manage signing", and under "Provisioning Profile", for both Debug and Release builds, I chose to import the new provisioning profiles that were created I can build and run in debug mode, and it works fine. I then created an 'archive' of the app, which also built fine, and opened up Organizer. In Organizer, I choose the "Distribute" button, select "App Store Connect" as the distribution method, and choose "Upload" as the destination. After it prepares the archive, it shows the usual two checkboxes for "upload app symbols" and "manage version and build number", and I select Next. Till now, everything works as expected. Now I get the "Select certificates and Mac App Store profiles" page ... here, for the dropdowns for my app's targets, I select the correct provisioning profiles. BUT .. the "Next" button never next gets enabled, so I can't move forward! There's no error message, or anything in Console that makes sense to me. But I just can't seem to be able to select "Next" to the final step before uploading the build to App Store Connect. When I went back and selected "Automatically manage signing" again, and build and archive, the new archive doesn't have this step again, so it works fine and goes to the final upload page. What can I do to find out the issue that's causing this page to not validate? Can I upload the archive build through some other way (like from Terminal) that might give more information? NEVERMIND: turns out, I needed to "Mac Installer Distribution" Certificate, which I generated from the dropbox.
0
0
940
Oct ’22
StoreKit2: using AppTransaction.shared triggers user login
Hi, I plan to use the new AppTransaction.shared API in StoreKit2 to find the user's original purchase date and version for my macOS app. However, when testing this running in the debugger, the app shows up with an App Store login prompt, asking for my login and password, which is undesirable. I wanted to know if this is just a sandbox quirk, or is the "AppTransaction.shared" API supposed to trigger this prompt for all users, even in production? In that case, is it like the old "Refresh receipt" API where we shouldn't trigger this automatically when a user opens the app, and instead have a button somewhere that triggers the call? Thanks.
1
0
845
Mar ’23
Distributing Swift Package, without remote repo
Hi, I am working on distributing a 'framework' I made to a client. The framework itself has a couple of dependencies on a couple of 3rd-party frameworks. Also, I don't want to disclose my source code to the client. So after doing some research, it seems like the best way to do this would be to use Swift Packages, and make it a binary distribution, which would basically wrap a .xcframework (which I would generate with my source code). But I'm confused about the next steps ... how would I go about sharing the 'package' with the client? Would I just zip up the 'package' folder and email it to them, and they can unzip it on their end, and add it to their project by using "Add local package"? Or is there a more elegant way to do this, which doesn't require publishing a package publicly?
0
0
578
May ’23
Create Swift Package with 3rd party dependencies
I am trying to create a Swift Package for a custom framework I'm building for a client. The framework has a dependency on a couple of 3rd party frameworks. I've read about how even though binary frameworks don't support dependencies directly, there is way to do this with a 'wrapper' target, so this is what I came up with for Package.swift: let package = Package( name: "SBCardScannerFramework", platforms: [ .iOS(.v16) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SBCardScannerFramework", targets: ["SBCardScannerFramework-Target"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"), .package(url: "https://github.com/marmelroy/PhoneNumberKit.git", from: "3.3.3") ], targets: [ .target(name: "SBCardScannerFramework-Target", dependencies: [ .target(name: "SBCardScannerFramework", condition: .when(platforms: [.iOS])), .product(name: "Algorithms", package: "swift-algorithms"), .product(name: "PhoneNumberKit", package: "PhoneNumberKit") ] ), .binaryTarget(name: "SBCardScannerFramework", path: "SBCardScannerFramework.xcframework") ] ) This works, and I can add the package to my test project and import the framework and it links against the dependancies as well, and works correctly. The problem is that every time I run the app, it also shows these messages in the Xcode console: objc[845]: Class _TtC14PhoneNumberKitP33_0FE53357E470A64027C8F0CAF7B114C812BundleFinder is implemented in both /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/Frameworks/SBCardScannerFramework.framework/SBCardScannerFramework (0x100f4aaf0) and /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/TestSBCardScannerFrameworkImport (0x10069b778). One of the two will be used. Which one is undefined. There's multiple lines for different classes that show the "Class X is implemented in both [.../MyApp.app/Frameworks/MyFramework.frameworkMyFramework/] and [.../MyApp.app/MyApp]". I'm not sure how to avoid this problem, and whether this could cause a problem down the line. The framework that is the basis for this Swift Package is linked against the two dependencies, because I wouldn't be able to build the framework without them. But they also need to be added to the app target (at least, and if I don't, I get a run-time crash when using the PhoneNumberKit initializer. PhoneNumberKit/resource_bundle_accessor.swift:40: Fatal error: unable to find bundle named PhoneNumberKit_PhoneNumberKit Is there a good way to resolve this issue? I'm worried this will could be a problem for the client when they integrate it into their app, and the app is deployed to 1000s of devices.
0
0
1.3k
May ’23
Bridging header issue when building for visionOS SDK
When I build my iOS app for the visionOS simulator, it works fine, and it runs in the compatibility mode. When I try to build against the new visionOS SDK, I get build errors related to the bridging header: SimpleList-Bridging-Header.h:5:9: error: 'MyFramework/MyFramework.h' file not found #import <MyFramework/MyFramework.h> ^ 1 error generated. :0: error: failed to emit precompiled header '...DerivedData/CJ-bkylkdabwgxlstdympoknglfewum/Build/Intermediates.noindex/PrecompiledHeaders/SimpleList-Bridging-Header-swift_3HAL1I7NW16O7-clang_3RN0BYG6SZHIS.pch' for bridging header '.../SimpleList/Classes/SimpleList-Bridging-Header.h' 2 errors generated. I don't know why it's not finding my framework for the visionOS SDK, while it works fine for the iOS SDK. The framework is included in the project itself (i.e. it's not an external dependency). Any tips?
2
0
1.7k
Jul ’23
New warning when updating app in macOS Sonoma
Hi, I am testing out an update for my app in macOS Sonoma. I first installed the App Store version of my app on the device running macOS Sonoma, and it ran fine. I then installed an updated version of my app through TestFlight (built with macOS Ventura SDK), but when I run this updated version, I get prompted ”MyApp differs from previously opened versions. Are you sure you want to open it?". Why is this happening? Is this warning only because the app is updated through TestFlight, or do I need to do something to prevent this warning from happening when I update my app through the App Store? I see this mentioned in an Apple security update:: App Sandbox now associates your macOS app with its sandbox container using its code signature. The operating system asks the person using your app to grant permission if it tries to access a sandbox container associated with a different app. For more information, see Accessing files from the macOS App Sandbox. My app is already sandboxed, and I'm not trying to access a different app's sandbox container, just my own. For the TestFlight build, it probably also uses the same Release configuration that the App Store build uses. I might have changed my provisioning profiles recently because they expired. Would that affect this and cause a prompt to be showed? Would love to know more about this prompt and how to avoid it. Thanks.
3
0
4.4k
Mar ’24