View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Use Accelerate to improve performance and incorporate encrypted archives

    The Accelerate framework helps you make large-scale mathematical computations and image calculations that are optimized for high-performance, low-energy consumption. Explore the latest updates to Accelerate and its Basic Neural Network Subroutines library, including additional layers, activation functions, and improved optimizer support. Check out improvements to simd.h that include better support for C++ templates. Discover support for Apple Encrypted Archive, an extension to Apple Archive that combines compression with powerful encryption and a digital signature. And learn how you can keep data your safe and secure without compromising on performance.

    Ressources

    • Encrypting and Decrypting Directories
    • Accelerate
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC19

    • Introducing Accelerate for Swift
  • Rechercher dans cette vidéo…
    • 1:55 - Using Accelerate in C/C++

      // How to use in your own code
      
      // C / Objective C / C++
      #include <Accelerate/Accelerate.h> // Add framework Accelerate
      #include <AppleArchive/AppleArchive.h> // Add framework AppleArchive
      #include <Compression/Compression.h> // Add framework Compression
      #include <simd/simd.h> // No framework to add
      
      // Swift
      import Accelerate
      import AppleArchive
      import Compression
      import simd
    • 4:26 - simd example

      import simd
      
      public func swishharder_scalar (_ data: [Float]) -> [Float] {
        return data.map { x in
          if x <= -.pi { return 0 }                         //        {  0                if  x ≤ -π
          if x <=  .pi { return 2*exp(x) * (x + .pi)/2 }    // f(x) = {  2eˣ * (x+π)/2    if -π <  x < π
          else         { return 2*exp(x) }                  //        {  2eˣ              if  π ≤  x
        }
      }
      
      func swishharder_elementwise(_ x: SIMD8<Float>) -> SIMD8<Float> {
          let y = 2*simd.exp(x)
          let a = y.replacing(with: 0, where: x .<= -.pi)
          let b = ((x + .pi)/2).replacing(with: 1, where: .pi .<= x)
          return a*b
      }
      
      extension SIMD {
          internal func store(
              into buffer: UnsafeMutableBufferPointer<Scalar>,
              startingAt offset: Int
          ) {
              for i in 0 ..< scalarCount {
                  buffer[offset + i] = self[i]
              }
          }
      }
      
      public func swishharder_simd(_ data: [Float]) -> [Float] {
          return Array<Float>(unsafeUninitializedCapacity: data.count) {
              (buffer: inout UnsafeMutableBufferPointer<Float>, count: inout Int) in
              for i in stride(from: 0, to: data.count, by: 8) {
                  let v = SIMD8(data[i ..< i+8])
                  let w = swishharder_elementwise(v)
                  w.store(into: buffer, startingAt: i)
              }
              count = data.count
          }
      }
    • 12:14 - AEA Encryption

      /// Encrypts and archives the directory at the specified URL.
          ///
          /// - Parameter sourceURL: The URL of the directory that the function encrypts and archives.
          /// - Returns: A string containing the status message.
          ///
          /// This function writes the result to `directory`. The archive shares the name
          /// of the supplied directory with an `aea` extension.
          static func encrypt(sourceURL: URL) -> ConsoleMessage {
              
              // Verify that the URL path represents a directory.
              if !sourceURL.hasDirectoryPath {
                  return ConsoleMessage(status: .error,
                                        message: "The specified URL doesn't point to a directory.")
              }
      
              guard let source = FilePath(sourceURL) else {
                  return ConsoleMessage(status: .error,
                                        message: "Unable to create file path from source URL.")
              }
      
              // Create the destination `FilePath`.
              let destination = directory
                  .appending(sourceURL.lastPathComponent)
                  .appending(".aea")
              let archiveDestination = FilePath(destination)
      
              // Create the encryption context + setup credentials
              let encryptionKey = SymmetricKey(size: .bits256)
      
              let context = ArchiveEncryptionContext(
                  profile: .hkdf_sha256_aesctr_hmac__symmetric__none,
                  compressionAlgorithm: .lzfse)
              do {
                  try context.setSymmetricKey(encryptionKey)
              } catch {
                  return ConsoleMessage(status: .error,
                                        message: "Error setting password (\(error).)")
              }
      
              // Create the file stream, encryption stream, archive encode stream.
              guard
                  let archiveDestinationFileStream = ArchiveByteStream.fileStream(
                      path: archiveDestination,
                      mode: .writeOnly,
                      options: [ .create, .truncate ],
                      permissions: FilePermissions(rawValue: 0o644)),
                  
                      let encryptionStream = ArchiveByteStream.encryptionStream(
                          writingTo: archiveDestinationFileStream,
                          encryptionContext: context),
                  
                      let encoderStream = ArchiveStream.encodeStream(
                          writingTo: encryptionStream) else {
                          
                          return ConsoleMessage(status: .error,
                                                message: "Error creating streams.")
                      }
              
              // Remember to close things in the correct order
              defer {
                  try? encoderStream.close()
                  try? encryptionStream.close()
                  try? archiveDestinationFileStream.close()
              }
      
              // Encode all files in the target directory with the specifed fields.
              do {
                  
                  let fields = ArchiveHeader.FieldKeySet("TYP,PAT,DAT,UID,GID,MOD")!
                  try encoderStream.writeDirectoryContents(archiveFrom: source,
                                                           keySet: fields)
              } catch {
                  return ConsoleMessage(status: .error,
                                        message: "Error writing directory contents.")
              }
              
              if let url = URL(archiveDestination) {
                  NSWorkspace.shared.activateFileViewerSelecting([url])
              }
      
              let message = """
      Encrypted with key '\(encryptionKey.base64Encoded)'.
      Archived and encrypted to: \(archiveDestination.description).
      """
              
              return ConsoleMessage(status: .encryptionSuccess(base64EncodedKeyData: encryptionKey.base64Encoded),
                                    message: message)
          }

Developer Footer

  • Vidéos
  • WWDC21
  • Use Accelerate to improve performance and incorporate encrypted archives
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines