Post

Replies

Boosts

Views

Activity

Reply to AppTransaction: how to use in ObjC apps (now that we are forced to use it after the exit(173) deprecation)
Just to be perfectly clear: The developer documentation says I can get XCode to generate a header that will allow a .m file to recognize Swift types and key words. I carefully followed the instructions - I got it to create the header. I included the header in my project. I imported the header into my .m file. I am including the Store Kit framework in my build settings. I imported the header storekit/storekit.h in my file. It doesn't matter how I try to use AppTransaction because XCode doesn't recognize Swift ketwords of types.
Oct ’24
Reply to AppTransaction: how to use in ObjC apps (now that we are forced to use it after the exit(173) deprecation)
I can write a Swift function to verify the receipt: func chekReceipt() async{ do{ let verificationResult = try await AppTransaction.shared switch verificationResult { case .verified(let appTransaction): var string = "receipt verified" print(string) case .unverified(let appTransaction, let verificationError): var string = "receipt unverified" print(string) } } catch{ var string = "checkReceipt threw an error" print(string) } } But I can't call it from Objective C. There are other issues: I am targeting my project for macOS 10.11 (the earliest version you can target with XCode) to provide backwards compatibility. Lots of my users are on older Macs and don't use 10.15. AppTransaction is only available on 10.13+ so I will have to support the older verification code for a long time and if Apple breaks this it will be a hassle for me and my users. Also the sample code for AppTransaction won't build. You have to add the keyword "async". This is not in my book Swift Programming 3rd Edition or the sample code so I had to go through a bunch of ** to figure this out. Criticism of Swift - it's a moving target.
Oct ’24
Reply to AppTransaction: how to use in ObjC apps (now that we are forced to use it after the exit(173) deprecation)
I have made some progress. I added the forward declaration: @class AppTransaction; @interface AppTransaction : NSObject - (AppTransaction *)returnAppTransaction; @end to myappname-Swift.h header. Now XCode recognizes AppTransaction in my code. BUT AppTransaction is declared as struct and XCode doesn't recognize .shared or .VerificationResult. members. If I remove the declaration, XCode won't recognize AppTransaction - undeclaredidentifier.
Oct ’24
Reply to AppTransaction: how to use in ObjC apps (now that we are forced to use it after the exit(173) deprecation)
After carefully studying the documentation for Importing Swift into Objective-C, I am unable to make it work. First of all the document says that the header is generated from my Product Module name. Searching the Developer documentation and the XCode Help for Product Module Name yields no results. Looking at my project's Target Build Settings I see in Packaging a field called Product Module Name. Since this is the closest thing I can find to the description in the document I put the name of my app in the fields. Then I created a header file with the name appName-Swift.h in my project. I built the project but the header is empty and #importing it into a .m file doesn't provide my code with the Swift types. Has anyone actually been able to do this as described in the document? For me, carefully studying the developer documentation often brings me to a frustrating dead end like this.
Oct ’24
Reply to AppTransaction: how to use in ObjC apps (now that we are forced to use it after the exit(173) deprecation)
I have the same problems. The app is reporting that exit(173) is no longer available, even though it isn't called. The alert tells me to use Transaction or AppTransaction. These are only available in Swift and they are for in-app purchases. The documentation tells me to use AppTransaction or Transaction. These are also Swift but not objective C APIs. I have created a header as described in the documentation for Importing Swift into Objective-C but this is not helpful because I need to read the Objective C declarations to call the Swift APIs from my Objective C code. I can't because the productname-Swift.h file is empty. It does seem to understand Objective-C versions of some APIs, such as NSPersistentHistoryTransaction *myTransaction but making wild guesses about the APIs in Objective-C isn't the real way to do this. All I need t do is call the method to validate the receipt and also if there is some way to get a test receipt to debug my code as I did with exit(173) it would be a help.
Oct ’24
Reply to Xcode 9 - Can't Update Help Book
I found out that after you delete any other copies of the application and clear the help caches with hiutil -P ~/Library/Caches/com.apple.helpd the help book still won't appear in your app when running it in your development environment with Xcode. BUT if you archive your application and then distribute it, for example as a copy to your applications folder it will.
Nov ’23
Reply to WKWebView is Blank
It looks like it could be a timing problem. When execution returns after the windowDidLoad method the window is drawn to the screen and the content is rendered. It's taking more than a second to launch the WebContent process and load the content. It looks like the Window is drawn and movedToFront before this is complete so it won't draw the html because it isn't yet created. Does this sound possible? I don't see any way to sleep or delay this until the web content is loaded. Is this possible?
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’23
Reply to Xcode 9 - Can't Update Help Book
After going over everything over and over I was able to get it to work. The only difference between this and other attempts was that I deleted the old version of the application with Launchpad, not by dragging it to the trash. This may make a difference as far as deleting the caches goes. Apple Help is a really useful feature. It goes with your application so it's there even if your user is in a remote location with no internet. BUT the implementation is pretty flakey. I'm going to replace it with an NSDocument to make it easier to program and maintain.
Oct ’23
Reply to Xcode 9 - Can't Update Help Book
It's pretty weird that my Help Book has worked for a long time now but suddenly stopped after I upgraded to XCode 15.0.1. The .plists are all correct and not changed. The Help Book is correctly registered. You have to wonder why this would suddenly fail. Help Viewer is not currently being supported by Apple and the documentation is TEN YEARS OLD. At this point it would be easier to write my own help viewer. My help files are just html files anyway. Perhaps there is some documentation describing how to display them in an NSWindow with an NSScrollingTextView. It has to be easier than dealing with the agonizing nightmare of AHRegistered help books.
Oct ’23
Reply to Xcode 9 - Can't Update Help Book
I worked on my Application. I did NOTHING to change the Help Book except change one small bit of text. I did everything listed in this thread: I deleted the existing version in the Applications folder. I cleared the Help data bases with hiutil -P ~/Library/Caches/com.apple.help.d. I have done this many times before but now with MacOS Sonoma 14.0 I get errors: Received termination response from helpd HPDHelpDataIsTerminating: Shutdown request successfully sent to helpd Unable to clear caches at path: /Users/myname/Library/Containers/com.apple.helpviewer Error: Error Domain=NSCocoaErrorDomain Code=513 "“Help Viewer” couldn’t be removed because you don’t have permission to access it." UserInfo={NSUserStringVariant=(Remove), NSFilePath=/Users/myName/Library/Containers/com.apple.helpviewer, NSUnderlyingError=0x600000d90d80 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} Caches not cleared: There was a problem clearing Help Viewer and helpd cache files, see logs for details There is nothing relevant in the logs. The Help Book is properly registered in the .plist as it has been for years. When my Application calls showHelp the help window appears with no content but if I search for terms in the Help Book they appear in the Show all Help Topics with the name of the section they are in but clicking on them leads to a page with the warning "The Selected Content is not Available". Is this some new bug for help editing? Also trying to force the Application to load the Help Book with stuff like [[NSHelpManager sharedHelpManager] registerBooksInBundle: [NSBundle mainBundle]]; does nothing. XCode isn't logging Entering AHSRegistered Help Book as it should either.
Oct ’23
Reply to Store Kit Libraries and Headers
Apple is bringing out new technologies like Store Kit as Swift only. This is the beginning of the gradual deprecation of C/Objective C and Interface builder. UGH. I am responsible for a big project for the Mac that's written in the above. Moving it all to Swift and Swift UI would be a monumental project that will probably never happen. Is there a way to mix Objective C and Swift? This would be a way to incrementally move the project to Swift/Swift UI. (Programming joke: What's the opposite of an increment?) If so how about documentation?
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’23