Number : 041, Date: 2024-10-21

2024.10.14 ~ 2024.10.20

✅ Writing async & await API Code


To try out Swift Testing, I first wrote the code responsible for external API networking.

I structured it as a networking module that takes a request model and returns only the response model, making it reusable.

  1. The RequestModel provides the URL string, query parameters, headers, HTTP method type, request body, and the type to decode.
  2. The response is a decoded model.

I separated it into a package, and since there was no need to upload it remotely, I developed it as a local package.

  1. $ swift package init --name --type
  2. Added the path in Tuist Project.swift

The biggest impression I got from using test code is that you can run the package on a Mac or execute $ swift test in the terminal without having to build the entire app. This lets you verify if the response values are correct, making testing incredibly fast.

🌎 WebView


I referred to blog posts by @whitelips on Medium, where WebView-related content is well organized.

A WebView is a web browser embedded in a native app.

On iOS, there are three ways to implement WebView: UIWebView, WKWebView, and SFSafariViewController. UIWebView cannot be used on iOS 12 and later. SFSafariViewController allows displaying web content through the Safari browser, and WKWebView is generally used.

The articles explain WKWebView’s cookie management, timeouts, multi-process architecture, strong references, and more, based on the WebKit open-source code, which is highly recommended.

❎ UIApplication.shared.open Method Failure


Starting from iOS 18, there is an issue where the UIApplication.shared.open method does not get called. If you check the console at the time of failure, you’ll see the error: BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate to the non-deprecated UIApplication.open(:options:completionHandler:). Force returning false (NO).

It appears that this issue is under discussion in the Apple Developer Forum.

🅾️ : UIApplication.shared.open(urlString, options: [:], completionHandler: nil)

❎ : UIApplication.shared.open(urlString)

From now on, you need to be careful with the parameters when using the open method.

🙋🏻‍♂️ Other Notes


  1. In the Facebook (Meta) developer review, make sure to verify that Debug mode works, though it’s unclear how they tested Debug mode.
  2. I initially used Tistory for my development blog, but due to issues such as Google Search Console not working properly for indexing, I migrated the blog to Medium.
  3. I reviewed the possibility of adding a Flutter module to an existing iOS app.
    • You can check it out by navigating to the flutter-add-to-app repository and running $ flutter pub get in the Flutter module you want to add.