APLConfiguration

Objective-C

@interface APLConfiguration : NSObject

Swift

class APLConfiguration : NSObject

Availability: All.

Subclass APLConfiguration and declare and implement properties to configure using the Appfigurate app (Simulator or App Store) with the BOOL_PROPERTY, INT_PROPERTY_, FLOAT_PROPERTY_, DOUBLE_PROPERTY_, STRING_PROPERTY_ or ENCRYPTED_STRING_PROPERTY_ macros (Objective-C) or @BoolProperty, @IntProperty_, @FloatProperty_, @StringProperty_ or @EncryptedString_ property wrappers (Swift). You must override the -[APLConfiguration publicKey] method.

  • Availability: All.

    The singleton instance of the APLConfiguration subclass. The instance is automatically instantiated on application, extension or XCUITest bundle startup. It is permissible to have a multi-level class hierarchy if required. e.g. AppConfiguration ‣ CommonConfiguration ‣ APLConfiguration.

    Declaration

    Objective-C

    + (APLConfiguration *_Nonnull)sharedConfiguration;

    Swift

    class func shared() -> APLConfiguration
  • Availability: All.

    Override to return the public key for this application. Use the Appfigurate app (Simulator or App Store) to output the public key(s).

    Objective-C example

    - (NSString*) publicKey {
    #if TARGET_OS_IOS
      return @"-----BEGIN PUBLIC KEY-----\n" \
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" \
        "yQUMO617+xo2tv5DF4M38emK7XpLR/ILLFiAiIHyRAdw9+wB80OEzek+bihwHWCs\n" \
        "WU0inAJ7gBLRqv7MHhPP4+XBbeizpLblPdBVVL1az5I3oDptpemIikAZrA37ZAH/\n" \
        "shk9C/wGogiQC4p60LmxbzI/+eYvI2x0M/Xxxpedcq6yRyHb+u+0ziNHoji5M6Qh\n" \
        "kcsailsMqANaN7VcO5NLPT3PzIc6WPG3iVJ0I8iCzXY/QNxOAtWc5t4CyB8+Z+fU\n" \
        "IEk9qAYiidZhpPb1gdJl4LN14qjBqYAmmJAo9oAabujlGmvxKQfR3Mj1FDd1GYab\n" \
        "6QIDAQAB\n" \
        "-----END PUBLIC KEY-----\n";
    #elif TARGET_OS_WATCH
      return @"-----BEGIN PUBLIC KEY-----\n" \
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" \
        "yQUMO617+xo2tv5DF4M38emK7XpLR/ILLFiAiIHyRAdw9+wB80OEzek+bihwHWCs\n" \
        "WU0inAJ7gBLRqv7MHhPP4+XBbeizpLblPdBVVL1az5I3oDptpemIikAZrA37ZAH/\n" \
        "shk9C/wGogiQC4p60LmxbzI/+eYvI2x0M/Xxxpedcq6yRyHb+u+0ziNHoji5M6Qh\n" \
        "kcsailsMqANaN7VcO5NLPT3PzIc6WPG3iVJ0I8iCzXY/QNxOAtWc5t4CyB8+Z+fU\n" \
        "IEk9qAYiidZhpPb1gdJl4LN14qjBqYAmmJAo9oAabujlGmvxKQfR3Mj1FDd1GYab\n" \
        "6QIDAQAB\n" \
        "-----END PUBLIC KEY-----\n";
    #endif
    }
    

    Swift example

    @objc override func publicKey() -> String {
    #if os(iOS)
      return "-----BEGIN PUBLIC KEY-----\n" +
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" +
        "yQUMO617+xo2tv5DF4M38emK7XpLR/ILLFiAiIHyRAdw9+wB80OEzek+bihwHWCs\n" +
        "WU0inAJ7gBLRqv7MHhPP4+XBbeizpLblPdBVVL1az5I3oDptpemIikAZrA37ZAH/\n" +
        "shk9C/wGogiQC4p60LmxbzI/+eYvI2x0M/Xxxpedcq6yRyHb+u+0ziNHoji5M6Qh\n" +
        "kcsailsMqANaN7VcO5NLPT3PzIc6WPG3iVJ0I8iCzXY/QNxOAtWc5t4CyB8+Z+fU\n" +
        "IEk9qAYiidZhpPb1gdJl4LN14qjBqYAmmJAo9oAabujlGmvxKQfR3Mj1FDd1GYab\n" +
        "6QIDAQAB\n" +
        "-----END PUBLIC KEY-----\n"
    #elseif os(watchOS)
      return @"-----BEGIN PUBLIC KEY-----\n" \
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" +
        "yQUMO617+xo2tv5DF4M38emK7XpLR/ILLFiAiIHyRAdw9+wB80OEzek+bihwHWCs\n" +
        "WU0inAJ7gBLRqv7MHhPP4+XBbeizpLblPdBVVL1az5I3oDptpemIikAZrA37ZAH/\n" +
        "shk9C/wGogiQC4p60LmxbzI/+eYvI2x0M/Xxxpedcq6yRyHb+u+0ziNHoji5M6Qh\n" +
        "kcsailsMqANaN7VcO5NLPT3PzIc6WPG3iVJ0I8iCzXY/QNxOAtWc5t4CyB8+Z+fU\n" +
        "IEk9qAYiidZhpPb1gdJl4LN14qjBqYAmmJAo9oAabujlGmvxKQfR3Mj1FDd1GYab\n" +
        "6QIDAQAB\n" +
        "-----END PUBLIC KEY-----\n"
    #endif
    }
    

    Declaration

    Objective-C

    - (NSString *_Nonnull)publicKey;

    Swift

    func publicKey() -> String
  • Availability: All.

    Override if required. Return YES if invalid digital signatures are allowed to apply configuration, or NO if only a correct digital signature is acceptable.

    It is best practice to make Release builds only allow correct digital signatures.

    If you do not override this method, the default implementation of allowInvalidSignatures is as follows:

    • for Simulator builds, always returns YES.
    • for Device builds, returns YES if the embedded entitlements file has get-task-allow = true, otherwise returns NO. (Release builds distributed through the App Store, Testflight, Ad Hoc or Enterprise will always have get-task-allow = false).

    Objective-C example

    - (BOOL) allowInvalidSignatures {
    #if DEBUG
       return YES;
    #else
       return NO;
    #endif
    }
    

    Swift example

    @objc override func allowInvalidSignatures() -> Bool {
        return !ENCRYPTED()
    }
    

    Declaration

    Objective-C

    - (BOOL)allowInvalidSignatures;

    Swift

    func allowInvalidSignatures() -> Bool
  • Availability: All.

    Returns the textual representation of all properties. Property names are shortened to camel case and appended with the value, except for NSString properties which omit the property name. Example: debugLog=5 would be returned as “DL=5”.

    Declaration

    Objective-C

    - (NSString *_Nonnull)description;

    Swift

    func description() -> String
  • Availability: All.

    Returns the textual representation of all properties that have non default values. Property names are shortened to camel case and appended with the non default value, except for NSString properties which omit the property name. Example: userInteractionTimeout=60.0 would be returned as “UIT=60.0”.

    Declaration

    Objective-C

    - (NSString *_Nonnull)modifications;

    Swift

    func modifications() -> String
  • Availability: All.

    Override if required to set default values into your properties. By default, sets properties as follows: NSString/String=nil, NSInteger/Int=0, float=0.0, double=0.0, BOOL/Bool=NO. You should ensure that all reset values conform to minimum and maximum values, list entries and regular expressions. Any values that are non-conforming will be output to the console.

    Objective-C example

    - (void) reset {
      self.decibelLimit = 5.1;
      self.foregroundColorHex = @"fa3bcc";
    }
    

    Swift example

    @objc override func reset() {
       decibelLimit = 5.1
       foregroundColorHex = "fa3bcc"
    }
    

    Declaration

    Objective-C

    - (void)reset;

    Swift

    func reset()
  • Availability: iOS only.

    By default Appfigurate uses the vendor identifier to target configuration to a specific device. The vendor identifier is the result of: [[[UIDevice currentDevice] identifierForVendor] UUIDString]

    Instead of the vendor identifier, you may prefer to use an application specific custom identifier that you tie to a specific device. The default value of customIdentifier is nil.

    Objective-C example

    - (NSString* _Nullable) customIdentifier {
       return [KeychainStorage savedCustomerUUID]
    }
    

    Swift example

    @objc override func customIdentifier() -> String? {
       return KeychainStorage.savedCustomerUUID()
    }
    

    Declaration

    Objective-C

    - (NSString *_Nullable)customIdentifier;

    Swift

    func customIdentifier() -> String?
  • Availability: iOS automation testing only.

    Converts the current state of the APLConfiguration instance into a string that can be passed as launch arguments to the app when launched as UI automation test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied.

    Objective-C example

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      c.webserviceURL = "https://localhost:443/api";       // change URL to dummy server
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArguments]; // convert to launch argument
      [app launch];                                        // launch app under test
    }
    

    Swift example

    func setUp() {
       super.setUp()
       let c = Configuration()
       c.webserviceURL = "https://localhost:443/api"       // change URL to dummy server
       let app = XCUIApplication()
       app.launchArguments = c.automationLaunchArguments() // convert to launch argument
       app.launch()                                        // launch app under test
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArguments;

    Swift

    func automationLaunchArguments() -> [String]
  • Availability: iOS automation testing only.

    Resets the apps configuration to defaults, by generating a string that can be passed as launch arguments to the app when launched as a UI automation test.

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsReset]; // convert to launch argument
      [app launch];                                             // launch app under test
    }
    

    Swift example

    func setUp() {
       super.setUp()
       let c = Configuration()
       let app = XCUIApplication()
       app.launchArguments = c.automationLaunchArgumentsReset]; // convert to launch argument
       app.launch()                                             // launch app under test
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArgumentsReset;

    Swift

    func automationLaunchArgumentsReset() -> [String]
  • Availability: iOS automation testing only.

    Allows a custom action in your APLConfiguration subclass to be executed, by generating a string that can be passed as launch arguments to the app when launched as a UI automation test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied.

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsWithAction: @"zeroLogs"]; // convert to launch argument
      [app launch];                                                               // launch app under test
    }
    

    Swift example

    func setUp() {
       super.setUp()
       let c = Configuration()
       let app = XCUIApplication()
       app.launchArguments = c.automationLaunchArgumentsWithAction("zeroLogs") // convert to launch argument
       app.launch()                                                            // launch app under test
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArgumentsWithAction:
        (NSString *_Nonnull)action;

    Swift

    func automationLaunchArguments(withAction action: String) -> [String]