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 {
      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";
    }
    

    Swift example

    override func publicKey() -> String {
      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"
    }
    

    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).

    For Swift, ensure that DEBUG is defined in your: App target ‣ Build Settings ‣ Swift Compiler - Custom Flags ‣ Active Compilation Conditions for the Debug build configuration.

    Objective-C example

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

    Swift example

    override func allowInvalidSignatures() -> Bool {
      #if DEBUG
        return true
      #else
        return false
      #endif
    }
    

    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

    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

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

    Declaration

    Objective-C

    - (NSString *_Nullable)customIdentifier;

    Swift

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

    Generates a string that can be passed as launch arguments to the app under test, to apply configuration. 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";
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArguments]; // Convert apply operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      c.webserviceURL = "https://localhost:443/api"
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArguments() // Convert apply operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

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

    Swift

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

    Generates a string that can be passed as launch arguments to the app under test, to reset the configuration to defaults.

    Objective-C example

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsReset]; // Convert reset operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArgumentsReset() // Convert reset operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

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

    Swift

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

    Generates a string that can be passed as launch arguments to the app under test, to execute a custom action. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this action to be executed. See also -[APLConfiguration automationSendReadConfiguration].

    Objective-C example

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsWithAction: @"zeroLogs"]; // Convert execute action operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArguments(withAction: "zeroLogs") // Convert execute action operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

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

    Swift

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

    Applies this configuration to the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied. An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
      Configuration* c = [Configuration new];
      c.webserviceURL = "https://localhost:443/api"; // Change URL to mock server.
      [c automationSendConfiguration];               // Apply this configuration to the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
      let c = Configuration()
      c.webServiceURL = "https://localhost:443/api" // Change URL to mock server.
      c.automationSendConfiguration()               // Apply this configuration to the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfiguration;

    Swift

    func automationSendConfiguration()
  • Availability: iOS XCUITest automation testing only.

    Resets the configuration to defaults in the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be reset. An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
      Configuration* c = [Configuration new];
      [c automationSendResetConfiguration]; Resets the configuration to defaults in the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
    
      let c = Configuration()
      c.automationSendResetConfiguration() Resets the configuration to defaults in the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfigurationReset;

    Swift

    func automationSendConfigurationReset()
  • Availability: iOS XCUITest automation testing only.

    Execute a custom action in the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied. An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
    
      Configuration* c = [Configuration new];
      [c automationSendConfigurationWithAction: @"zeroLogs"]; // Execute a custom action in the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
    
      let c = Configuration()
      c.debugLogging = true
      c.serverURL = "https://m.electricbolt.co.nz/test"
      c.automationSendConfiguration(withAction: "zeroLogs") // Execute a custom action in the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfigurationWithAction:(NSString *_Nonnull)action;

    Swift

    func automationSendConfiguration(withAction action: String)
  • Availability: iOS XCUITest automation testing only.

    Updates this configuration by reading the configuration from the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this method to succeed. An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond. You should use this method after - [APLConfiguration automationLaunchArgumentsWithAction] if the action in the app under test changes property values.

    Objective-C example

    - (void) testURL {
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsWithAction: @"zeroLogs"];
      [app launch];
      [c automationSendReadConfiguration]; // Updates this configuration by reading the configuration from the app under test.
      ...
    

    Swift example

    func testURL() {
       super.setUp()
       let c = Configuration()
       let app = XCUIApplication()
       app.launchArguments = c.automationLaunchArgumentsWithAction("zeroLogs")
       app.launch()
       c.automationSendReadConfiguration() // Updates this configuration by reading the configuration from the app under test.
       ...
    

    Declaration

    Objective-C

    - (void)automationSendReadConfiguration;

    Swift

    func automationSendReadConfiguration()