AWS SDK for iOS

repository·main·Indexed 23 days ago

https://github.com/aws-amplify/aws-sdk-ios

Low-level access to various AWS services for iOS applications. Currently in a maintenance phase, with a recommendation to migrate to AWS Amplify for Swift for new development. Includes utility libraries such as UICKeyChainStore for secure data storage, GZIP for NSData compression, Mantle for JSON serialization and model mapping, Reachability for network monitoring, and TMCache for parallel key/value storage.

Tokens
14.4K
Snippets
29
Records
65
Agent score
80%

What's inside aws-sdk-ios

  1. Maintenance Phase Notice for AWS SDK for iOS

    main

    As of August 1, 2025, the AWS SDK for iOS has entered the Maintenance Phase.

    What this means for your project:

    • Supported: Critical bug fixes and security patches.
    • Not Supported: New features or enhancements.
    • End of Support: This version is scheduled to reach End of Support on August 1, 2026, after which no further updates will be provided.

    Recommendation: It is highly recommended to migrate to AWS Amplify for Swift, which is the modern, feature-rich library for cloud-connected apps. You can use the AWS SDK for iOS migration guide to assist with the transition.

  2. What is TMCache and how does it work?

    main

    TMCache is a fast, parallel key/value store designed for persisting temporary objects that are expensive to reproduce (e.g., downloaded data or slow processing results).

    It consists of two self-similar stores:

    1. TMMemoryCache: An in-memory store. On iOS, it automatically clears itself when the app receives a memory warning or enters the background.
    2. TMDiskCache: A disk-based store. Objects remain until the cache is manually trimmed or a byte/age limit is reached.

    Key Characteristics:

    • Thread Safety: Backed by GCD and safe for simultaneous access from multiple threads.
    • Coordination: TMCache coordinates both stores so that objects added to memory are immediately available to other threads while being written to disk safely in the background.
    • Concurrency: TMMemoryCache allows concurrent reads and serialized writes. TMDiskCache serializes disk access across all app instances to prevent file contention.
    • Requirements: Objects must conform to NSCoding.
  3. Features of UICKeyChainStore

    main

    UICKeyChainStore provides several key capabilities for managing secure data:

    • Simple interface for easy usage
    • Support for access groups
    • Support for accessibility settings
    • Support for iCloud sharing
    • Support for TouchID and Keychain integration (iOS 8+)
    • Support for Shared Web Credentials (iOS 8+)
    • Cross-platform support for both iOS and OS X
  4. Import XCFramework modules with the XCF suffix

    main

    When using XCFrameworks (via Swift Package Manager, Carthage, or Dynamic Frameworks), certain modules are named with an XCF suffix to resolve Swift compatibility issues. Specifically, AWSMobileClient is named AWSMobileClientXCF and AWSLocation is named AWSLocationXCF.

    To use these SDKs, you must import them using the XCF suffix, but you can call their methods in your application code using the standard names without the suffix.

    import AWSMobileClientXCF
    import AWSLocationXCF
    
    // Use the standard names in your code
    AWSMobileClient.default().initialize() 
    let locationClient = AWSLocation.default()
  5. Create model objects with MTLModel

    main

    Instead of writing extensive boilerplate for NSCoding, NSCopying, isEqual:, and hash, you can inherit from MTLModel. MTLModel provides default implementations for these methods based on your @property declarations. It also simplifies JSON parsing and serialization through key path mapping and value transformers.

    @interface GHIssue : MTLModel <MTLJSONSerializing>
    
    @property (nonatomic, copy, readonly) NSURL *URL;
    @property (nonatomic, copy, readonly) NSURL *HTMLURL;
    @property (nonatomic, copy, readonly) NSNumber *number;
    @property (nonatomic, assign, readonly) GHIssueState state;
    @property (nonatomic, copy, readonly) NSString *reporterLogin;
    @property (nonatomic, strong, readonly) GHUser *assignee;
    @property (nonatomic, copy, readonly) NSDate *updatedAt;
    
    @property (nonatomic, copy) NSString *title;
    @property (nonatomic, copy) NSString *body;
    
    @property (nonatomic, copy, readonly) NSDate *retrievedAt;
    
    @end
  6. Persist MTLModel objects using NSCoding

    main
    Mantle does not provide automatic persistence. However, because MTLModel conforms to <NSCoding>, you can archive your model objects to disk using NSKeyedArchiver. For more complex persistence needs or to avoid keeping entire models in memory, consider using Core Data.
  7. Core FMDB Classes

    main

    FMDB is built around three primary classes:

    1. FMDatabase: Represents a single SQLite database connection. It is used to execute SQL statements (updates and queries).
    2. FMResultSet: Represents the results returned from executing a query on an FMDatabase.
    3. FMDatabaseQueue: A thread-safe wrapper used to perform queries and updates across multiple threads by serializing access to a single FMDatabase instance.
  8. Encode indefinite-length data

    main

    To encode indefinite-length arrays, maps, strings, and byte strings, you must explicitly use open- and close-stream CBOR values. Between these markers, use chunk functions like encodeArrayChunk or encodeMapChunk to add data.

    let map: [String: Int] = ["a": 1]
    let map2 = ["B": 2]
    CBOR.encodeMapStreamStart() + CBOR.encodeMapChunk(map) + CBOR.encodeMapChunk(map2) + CBOR.encodeStreamEnd()
    
    let bs: [UInt8] = [0xf0]
    let bs2: [UInt8] = [0xff]
    CBOR.encodeByteStringStreamStart()
        + CBOR.encode(bs, asByteString: true)
        + CBOR.encode(bs2, asByteString: true)
        + CBOR.encodeStreamEnd()
  9. Update the AWS SDK for iOS

    main

    To update the SDK to a newer version, use the command corresponding to your dependency manager:

    CocoaPods

    Run pod update in your project directory. Note: If you encounter issues, delete Podfile.lock and the Pods/ directory, then run pod install for a clean installation.

    Carthage

    Run carthage update in your project directory.

    Frameworks

    If you manually added frameworks:

    1. In Xcode's Project Navigator, search for "AWS".
    2. Select all AWS Frameworks/XCFrameworks and delete them (Move to Trash).
    3. Re-run the initial installation process to include the new version.
    $ pod update