Here’s a look at some of the tech highlights to watch this year at WWDC

Complimentary food guide:

One: Experience one-stop development without leaving Xcode? Xcode Cloud Beta is free for a limited time. If you are interested in Xcode Cloud Beta, please go to the official website to apply.

How to make async/await, Structured concurrency, Actors more secure and convenient?

Swift Playgroud brings the iPad back to productivity. It’s time to build apps on the iPad!

Four: Focus mode, don’t let notifications distract you! Notice the four new levels of interference?

Five: How to make your widgets more visible to users? A: Make a bigger Widget

Six: With Shareplay, let the group building is no longer limited by distance!

(warm prompt: the film content sources from WWDC21: Platforms the State of the Union

If you want to know more about WWDC2021, you can read my article below. Welcome to communicate and correct

Detect and diagnose memory problems

The ultimate APP performance survival guide

Xcode Cloud

Imagine a one-stop iOS development experience, where code is submitted in Xcode, automatically compiled and tested in the cloud, then developers simply improve the code based on the test results displayed in Xcode, and when everything is ready, the app is automatically distributed to TestFlight on each platform… In order to achieve such a smooth development experience, Apple integrates all the links involved in the development process into Xcode.

Tips: Xcode Clould is currently free for a limited timewebsiteApply for Beta permission

  • The original development process

    • Each link

      Coding -> test -> integration -> distribution -> improvement

      Integration here refers to the integration of functional branches into trunk branches.

    • Pain points

      Each step relies on different tools, and the process of changing environments often interrupts the way we write code

  • Xcode Cloud

    A tool responsible for continuous integration and distribution of services

    • Advantage:

      • Built into Xcode, no need to switch working context;
      • After committing the Commit, the file is automatically compiled in the cloud.
      • Flexible and extensible, support integration with other CI systems;
      • Data security, ensure source code, key security.
    • Workflow:

      • Select the project

      • Validation workflow

      • Granting access to source code

      • Connect to App Store Connect

      • View the results

        • The left navigator groups projects by their branch names

        • The right detail page displays the status of all actions

      • Adding a new workflow

        • Sets the conditions that trigger compilation

          • Scenario 1: Triggers every code change on the branch

          • Scenario 2: Triggers every code change on the Pull Request branch

          • Solution 3: Triggered when the Tag is modified

        • Select the version of Xcode

        • Add the Action

          • Add UI Test

        • View the Action result

          • You can use Xcode Cloud to view the process in action through a screenshot of the UI Test process

  • Branch consolidation

    • Manage Pull Requests in Xcode

    • Xcode Cloud automatically builds and tests new commits on all Pull Merge branches under current compilation conditions

    • You can also quickly navigate to the code in the comment

      Click the class name with information identifier in the left column. Click to directly locate the corresponding position and view the comments

  • distribution

    • Cloud autosignature

      Developers don’t have to worry about describing files and keys

    • Support for automated distribution of TestFlight on multiple platforms (including Mac)

  • To improve the

    • During testing, the Xcode Organizer receives feedback from TestFlight users within minutes, and developers can make code improvements based on user descriptions

Swift

asynchronous

  • Understand asymc/await

    Await means that the current caller is waiting for the result of the asynchronous function

    For example, completing a dance performance requires three asynchronous steps: actors warm up, workers retrieve props from the warehouse, and a stage is set up before the actors can perform.

    • The original nested method (pseudocode) :

      func prepareForShow {
        // The actor warms up
      	danceCompany.warmUp {
          // The staff retrieve the props from the warehouse
      		 self.crew.fetchStageScenery {
              // Set up the stage
      		 		self.setStage {
                // Show up
      		 		  dancers.moveToPosition
      		 		}
      		 }
      	}
      }
      Copy the code
  • Write in line with async/await:

      func prepareForShow(a) async throws -> Scene {
      	let dancers = try await danceCompany.warmUP(duration: .minutes(45))
      	let scenery = await crew.fetchStageScenery()
      	let openingScene = setStage(with: scenery)
      	return try await dancers.moveToPosition(in: openingScence)
      }
    Copy the code
  • Structured Concurrency

    Another example: completing a dance performance requires three asynchronous steps: actors warm up, workers retrieve props from the warehouse, and a stage is set up before the actors can perform. The actors warm up and the staff find props from the warehouse and build the stage at the same time

    • Create and send a subtask

      func prepareForShow(a) async throws -> Scene {
      	async let dancers = try await danceCompany.warmUP(duration: .minutes(45))
      	async let scenery = await crew.fetchStageScenery()
      	let openingScene = setStage(with: await scenery)
      	return try await dancers.moveToPosition(in: openingScence)
      }
      Copy the code
  • actors

    • actor

      actor StageManager {
      	var stage: Stage
      	
      	func setStage(with scenery: Scenery) -> Scene{}}Copy the code

      In the past, using serial Dispatch Queue for mutually exclusive access to attributes, it was easy to introduce additional competition mechanism due to the need to manage a lot of redundant code, which caused problems. However, embedding actor as a first-class construct in Swift can avoid this situation at the lower design level.

  • MainActor

    Functions are synchronized to the main thread

      @MainActor
      func display(scene: Scene)
    Copy the code

Summary: Async /await makes asynchronous code more natural to write, structured concurrency makes code easier to understand, and actors are used to build safe shared state

Swift Playgrounds

Swift Playgrounds is now available on the iPad

  • You can publish your app directly to TestFlight on the iPad

Focus

  • notice

    Old notifications pile up on our screens the same way, regardless of their priority. It’s impossible to tell which one is more important

    • Notifications can now be classified into four levels of interference

      • Passive

        Silent, does not wake up the device, and is displayed the next time you pick up the phone, for less time-sensitive notifications

      • Active (same as the default notification type)

        With sound and tactile feedback, just like any other notification

      • Time Sensitive

        This level of notifications is pushed to the user immediately, and if the user doesn’t click it, it stays on the lock screen for a period of time for the notifications that need to be read immediately

      • Critical

        Sound is played even when the device is muted. This level can only be set for major health and safety notifications and requires user authorization

      In addition, there is a special notice:

      • Message Type Notification (message or call)

        If you develop a communication APP, you can tell the system that this is a message or call type notification, and the system will automatically adjust the style and the way the notification works, so that people can see the message better

    • Notice the

      To prevent people from missing notifications, and to help users see notifications when they want, a new notification presentation style has been introduced, the notification summary, which allows users to focus on notifications at a time of their choosing

      • Message type: Only Passive or Active notifications are displayed

      • There are two rotation positions at the top of the notification digest

        • Rotation bit notification selection rules:
          • Notifications with large thumbnails will be selected over those without
          • By default: Apps with the most pushes get featured first, though users can customize the summary based on that
    • Level adjustment

      According to the interaction between users and APP notifications, the system recommends users to adjust the interference level to the appropriate level

      • If the user is constantly using an APP in focus mode

        The system will suggest allowing notifications when the APP is adjusted to focus mode

      • If the user frequently interacts with an APP’s Time Sensitive notifications

        The system will suggest that the notification level of the changed APP be changed back to Active

      • If an APP keeps sending notifications, the user doesn’t respond

        The system will suggest that notifications sent by this APP be muted

  • summary

    • By setting the notification relevance score and an appropriate thumbnail, the notification occupies the rotation position at the top of the digest
    • Think about what level of interference your APP’s notifications are best suited to
      • For example: if you are using chat software, you should use the latestUser Notifications APITo tell the system about messages and incoming calls from the APP
    • Use the latestFocus Status API, display the user’s focus mode state in the APP

Widget

Make your APP more usable and visible to users with new Widget features

  • Use the super-sized widgets on the iPad

  • Use the Intents framework to automatically add widgets to smart stack widgets

SharePlay

When people get together, it’s important to share experiences as well as chat, and SharePlay Kit is designed to help people stay connected even when it’s hard to see each other.

  • The entrance

    • FaceTime
    • iMessage

    Allow people to video chat while doing an activity together, such as sharing a video play, sharing a canvas.

  • Share video

Group Activities and AVPlayer are synchronized in the video APP so that this function can be quickly integrated.

  • Sharing the canvas

    Based on Group Activities, the strokes are sent to everyone in the FaceTime Group, so as to realize collaborative painting

Summary: FaceTime-based shared experience can be realized only by making the APP realize Group Activities