Week 41: Reading Notes

October 16, 20235 min read#swift, #reading

SwiftFormat Automation for iOS apps

Link

SwiftFormat is more powerful than another very similar Swift command line utility called SwiftLint. SwiftFormat is a code formatting tool that extends SwiftLint’s static analysis (linting) capability. The difference here is that SwiftFormat has a more powerful autocorrect capability than SwiftLint, so it is able to fix more issues, even though SwiftLint may be able to identify a wider range of issues, such as file length, and cyclomatic complexity.

iOS: UI Testing Strategy and Tooling

Link

This post aims to introduce you to our end-to-end UI testing process and set a base for future content related to testing and releasing the Reddit app for iOS.

  • UI tests are written in Swift and use XCUITest
  • Tools
    • UITestKit - Supports functional and push notification tests.
    • UIEventsTestKit - Supports tests for analytics/telemetry events.
    • UITestHTTP - HTTP proxy server for stubbing network calls.
    • UITestRPC - RPC server to retrieve or modify the app state.
    • UITestStateRestoration - Supports reading and writing files from/to app storage.
  • Types of UI Tests:
    • Functional
    • Analytic Events
    • Push Notifications
    • Experiments
    • Internationalization & Localization
    • Performance (developed by a partner team)
  • Test Execution: Engineers can run UI tests locally using Xcode, in their terminal using Bazel, in CI on simulators, or on real devices using BrowerStack App Automate.
  • Test Stability: a ~90% pass rate on average for nightly test executions of smoke, events, and regression tests.
  • Mitigating Flaky Tests: a service to detect and quarantine flaky tests helping us mitigate unexpected CI failures and curb infra costs.
  • Test Reporting: Slack, Github Status, TestRail reports for non-engineers
  • Test Triaging: eview the test code, the test data, and the expected results to find root cause.
  • Developer Education: regularly hold training sessions around testing and quality in general.

How async/await works internally in Swift

Link

async/await in Swift was introduced with iOS 15, and I would guess that at this point you probably already know how to use it. But have you ever wondered how async/await works internally? Or maybe why it looks and behaves the way it does, or even why was it even introduced in the first place?

Although Swift prevents you from making memory-related mistakes, it does NOT prevent you from making logic mistakes / writing straight-up incorrect code, and the way the feature works today makes it very easy for you to introduce such mistakes.

Network Path Monitoring

Link

Apple released the Network framework in iOS 12, macOS 10.14. It includes a NWPathMonitor that is now the preferred way to monitor changes to network status. The three steps to monitor network changes:

  • Create a NWPathMonitor.
  • Call the start method of the path monitor passing a queue that will receive path change events.
  • Receive path changes in the pathUpdateHandler.

network_monitor

Embedded Swift

Swift is a general purpose programming language suitable for both high-level application software and for low-level systems software. The existing major supported deployments of Swift are primarily targeting “large” operating systems (Linux, Windows, macOS, iOS), where storage and memory are relatively plentiful, multiple applications share code via dynamic linking, and the system can be expected to provide a number of common libraries (such as the C and C++ standard libraries). The typical size of the Swift runtime and standard library in these environments is around 5MB of binary size.

However, lots of embedded platforms and low-level environments have constraints that make the standard Swift distribution impractical. These constraints have been described and discussed in existing prior work in this area, and there have been great past discussions in the Swift forums (link) and in last year’s video call (link), which shows there is a lot of interest and potential for Swift in this space. The motivation of “Embedded Swift” is to achieve a first class support for embedded platforms and unblock porting and using Swift in small environments.

Describing use of required reason API

Link

From Fall 2023 you’ll receive an email from Apple if you upload an app to App Store Connect that uses required reason API without describing the reason in its privacy manifest file. From Spring 2024, apps that don’t describe their use of required reason API in their privacy manifest file won’t be accepted by App Store Connect.

A shell script to find if any “required reason API” are used in Swift or Objective-C files within that folder or subfolders: Link

Quick Drop logo

Profile picture

Personal blog by An Tran. I'm focusing on creating useful apps.
#Swift #Kotlin #Mobile #MachineLearning #Minimalist


© An Tran - 2024