Post

Replies

Boosts

Views

Activity

Reply to My app suddenly getting "A server with the specified hostname could not be found"
Thanks. The problem does not occur if I run on a device connected by USB to the local (development) machine. In both cases, my application is hitting an HTTP server running on my Mac, using the Mac's hostname. This previously worked in the same simulator without a problem. A can hit the same endpoints in the simulator's Safari, no problem. It's only the URLRequests in my app that fail (again only in the sim). I was surprised that my phone could hit my Mac despite not being on Wi-Fi... apparently it's using the USB connection for networking. I do have my own certificates deployed to the simulator and phone. Thanks for the link to the other problem, but I'm not seeing "PolicyDenied" in any of the error output.
Apr ’25
Reply to custom-URL-handling method not being called
So... for anyone who stumbles across this, the final (and a major) problem is that universal links do not work as documented, for two reasons: For unknown reasons, the apple-app-site-association file will not work unless it has a content-type header applied to it by the Web server. This is not automatic and not necessary for any reason other than to work around this issue on Apple's end. Take a look at this SO question for more info. I'm on Apache, so I used the following in .htaccess <FilesMatch "apple-app-site-association"> ForceType application/json </FilesMatch> This requirement is undocumented. Apple provides a complete example file in its doc, and debugging hints here: https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links It neglects to mention the need to set up special handling on your Web server to slap an otherwise nonexistent header on this file. So now my app is receiving universal inks, via the onOpenURL view-modifier. I haven't tried the method that's actually documented as the primary one, in the application delegate yet. Also, even if I delete and reinstall my app, the user is not asked if he wants to open the link in my app; it just does it. I encourage everyone to file feedback on the dysfunction of universal links that's due to this unnecessary header requirement.
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to custom-URL-handling method not being called
More undocumented tools are coming out of the woodwork. I have now tried the diagnostic tool that exists on iOS under Developer / Universal Links. That tool confirms that my URL is registered to be handled by my app. curl was able to retrieve my AASA JSON file from my domain, so at this point there is no apparent reason for this failure.
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to custom-URL-handling method not being called
I learned that the correct App-ID prefix is your team identifier. Even putting that in the apple-app-site-association file as the bundle ID prefix did not solve the problem. Based on the info here (thanks), I learned that you can't use Safari to test the links. So I used Notes. Still no dice. It doesn't prompt to open the URL in my app. All the necessary files and entitlements appear to be set.
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to custom-URL-handling method not being called
Thanks for the reply Albert. I simply said that the app is not finished, so I have not archived it and uploaded it to App Store Connect. It exists, however, and is nearly at a testable state. It builds and runs just fine on devices and simulators, and when I set up a "custom URL" scheme in the project and typed a conforming URL into Safari's address bar (in a simulator), iOS offered to open the URL in my app as expected. Unfortunately, once the app opened, the documented method for receiving the URL was never called. Based on the information in this thread, it appears that "custom URLs" may be deprecated or out of favor. So I have now implemented "universal links", following all the steps Apple provides in the document you linked to above. This includes placing the necessary JSON file at a domain I control, and I have confirmed that it's accessible. I also set up entitlements in my project, with "applinks" URLs specified. In the doc you linked to, the method under "how to handle a universal link in iOS and tvOS" is also never called if I place it in my application struct. I mean this one: func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool So as recommended in this thread, I put the onOpenURL(perform:) modifier on my root view instead. That doesn't get called either. Neither of those is surprising, though, because when I go to Safari and enter a URL conforming to one specified in my project's applinks domain entitlements, I am not asked if I want to open the URL in my app (as I used to be with "custom URL scheme"). So the question is why I'm not being asked to open the URL in my app. If I look in my project settings, I do not see an application ID similar to the "ABCDE12345" one in the JSON above. Is that potentially the problem?
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to custom-URL-handling method not being called
Thanks for that reply. Unfortunately, the app still isn't receiving the registered URLs when they're entered in the address bar in Safari. Actually, it's a bit worse than the "custom URL format" attempt, because at least that one prompted me to open the link in my app. This one just loads the URL like a normal Web page. I have the apple-app-site-association file in place at my domain, and the entitlements set up in my project. One possible issue is that I don't have an app ID to put into this file. The example shows "applinks": { "details": [ { "appIDs": [ "ABCDE12345.com.example.app"], but I only have the equivalent of "com.example.app" in my file because I don't have an app ID. My application isn't finished, and if I upload it to App Store Connect I'm concerned that its identifiers will be impossible to move to a company account that I plan to set up. Is the missing prepended app ID enough to stop this from working? What's the workaround? Thanks!
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to Infinite loop getting "_dismiss changed"
OK, update: Thanks to @gbuela mentioning Self._printChanges, I discovered the problem in my case. Maybe it will help someone else: I have a non-@State object in my view, which gets passed to another view through a NavigationLink. Apparently this is another case of SwiftUI prematurely building views that might be invoked. When this object gets passed (by reference, because it's a class) to this particular destination view, that view sets one of its members. I don't know why the parent view is rebuilding on changes to a non-state member object, though. It wasn't a state in the destination view, either. I had to eliminate several modifications to the passed object through a sequence of views, because SwiftUI pre-built a stack of them. SwiftUI's pre-building of views creates copious opportunities for bugs, and pain for developers.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25
Reply to Infinite loop getting "_dismiss changed"
I just encountered this out of nowhere. I assumed that some @State variable was changing over and over, so I removed all the @State decorations from member variables. This did not fix the problem, but it did alter it. Now the view's init() is only called twice in succession, but the view still never appears. If I get rid of all use of @Environment(.dismiss), I can restore all @States and the invoked view appears as it used to. I have no idea what triggered this crippling bug.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25