Appfigurate™️
HomeDocumentation
  • Introducing Appfigurate™️ 3
  • Getting Started
    • Getting Started
    • Examples
    • Upgrade guide
      • v1.4.0 to v2.2.0
      • v2.1.1 to v2.2.0
      • v2.2.1 to v3.0.0
      • v3.2.1 to v4.0.0
    • iOS native app integration
      • iOS app extension integration
    • watchOS app integration
      • watchOS app extension integration
    • Android native app integration
    • Mobile Flutter integration
      • Flutter iOS
      • Flutter Android
    • React Native integration
      • iOS native module integration
      • Android native module integration
      • JavaScript integration
    • Third party remote configuration providers
      • Firebase Remote Config
      • Launch Darkly
      • Other third party remote configuration providers
  • Configuration subclasses
    • Supported property types
      • Boolean
      • Integer
      • Float
      • Double
      • Plain String
      • Encrypted String
    • Custom executable actions
    • Slider icon types
  • Additional reading
    • Info.plist options
    • AndroidManifest.xml options
    • Displaying overridden configuration
    • Security
      • Best practice
      • Encryption
      • Export compliance
      • App Store compliance
      • PrivacyInfo.xcprivacy
      • Rotating your private key
  • Automation testing
    • iOS native app automation testing
    • Android native automation testing
  • API
    • iOS and watchOS API
    • Android API
    • Mobile Flutter API
    • React Native API
  • Appfigurate User Guide
    • Introduction
    • Main menu
    • Select app
    • Add app
    • Import app
    • Install example apps
    • Settings
      • Passcode Lock
      • Restore
      • Backup
      • Delete all apps and Settings
      • Analytics
    • Edit app
    • Configure app
    • Permissions
  • Appfigurate SE user guide
    • Introduction
    • Manual encryption
      • ENCRYPTED_STRING macro/function
      • ENCRYPTED_STRING_IOS_WATCHOS macro/function
    • Setup iOS Simulator app
    • Setup Android Emulator app
    • Xcode source editor extension
      • Troubleshooting
    • Real device cloud testing services
      • BrowserStack
  • LEGAL
    • License Agreement
    • Privacy Policy
    • Release History
    • Third party notices
Powered by GitBook
On this page
  • Prerequisites
  • Add AppfigurateLibrary.xcframework to the watchOS app target
  • Add new app into Appfigurate Simulator
  • Share the iOS app APLConfiguration subclass with the watchOS app
  • WKApplicationDelegate/WKExtensionDelegate
  • WCSessionDelegate
  • Test your watchOS app
  1. Getting Started

watchOS app integration

Integrating Appfigurate Library into watchOS apps

PreviousiOS app extension integrationNextwatchOS app extension integration

Last updated 5 months ago

watchOS apps can be developed in both Swift and Objective-C.

Independent watchOS apps are not supported, watchOS apps must be bundled inside a companion iOS app. (The companion iOS app's Appfigurate Library is used to proxy any configuration payloads applied to the watchOS app).

Prerequisites

You must perform the following before starting watchOS native integration:

  • of Appfigurate Library.

In addition to the , you must also have:

  • watchOS SDKs and associated watchOS Simulators.

  • Use paired iOS and watchOS Simulators.

  • Appfigurate Simulator app installed into one or more paired iOS Simulators (use the for easy 1 click installation).

  • Your watchOS app must target watchOS 5.0+ in order to link Appfigurate Library.

Add AppfigurateLibrary.xcframework to the watchOS app target

In Xcode:

  • Tap on your watchOS app target.

  • Tap the General tab. Tap the + button under the Frameworks, Libraries, and Embedded Content section.

  • Select AppfigurateLibrary package.

Add new app into Appfigurate Simulator

Run Appfigurate in the paired iOS Simulator.

Select app type watchOS.

Tap Duplicate.

Share the iOS app APLConfiguration subclass with the watchOS app

WKApplicationDelegate/WKExtensionDelegate

Swift WKApplicationDelegate example

import AppfigurateLibrary

...

class MyApplicationDelegate: NSObject, WKApplicationDelegate, ObservableObject {
    func applicationDidFinishLaunching() {
        APLApplicationDidFinishLaunching()
    }
}

Swift WKApplicationDelegateAdaptor example

@main
struct MyApp: App {
    @WKApplicationDelegateAdaptor private var applicationDelegate: MyApplicationDelegate

    var body: some Scene { ... }
}

Swift WKExtensionDelegate example

import AppfigurateLibrary

...

func applicationDidFinishLaunching {
    APLApplicationDidFinishLaunching()
}

Objective-C WKExtensionDelegate example

@import AppfigurateLibrary;

...

- (void) applicationDidFinishLaunching {
    APLApplicationDidFinishLaunching();
}

WCSessionDelegate

Swift WCSessionDelegate example

import AppfigurateLibrary

...

func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
    let reply = APLSessionDidReceiveMessage(message)
    if reply != nil {
        replyHandler(reply)
    } else {
        ...

Objective-C WCSessionDelegate example

@import AppfigurateLibrary;

...

- (void) session: (WCSession*) session didReceiveMessage: (NSDictionary<NSString*,id>*) message replyHandler: (void (^)(NSDictionary<NSString*,id>*)) replyHandler {
    NSDictionary* reply = APLSessionDidReceiveMessage(message);
    if (reply != nil) {
        replyHandler(reply);
    } else {
        ...

Test your watchOS app

To test that you've successfully updated your watchOS app to use Appfigurate:

  • Compile and run your watchOS app to the paired Simulator instance.

  • Launch the Appfigurate Simulator app.

  • Tap your watchOS applications row. The companion iOS app will be run and made visible. The companion iOS app will read the watchOS apps configuration, then swap back to Appfigurate.

Tap ≡ YOUR-IOS-APP app. The screen will be displayed.

Tap Duplicate row row. The screen will be displayed.

Share the iOS app's subclass with the watchOS app extension.

Open your subclass (e.g. Configuration.swift/m file) into the Xcode editor. In the Target Membership inspection pane tick on your watchOS app target.

For watchOS apps using SwiftUI, you must call in the 's method.

Ensure you use the property wrapper inside your declaration to tell SwiftUI about the delegate type:

For watchOS apps using Storyboards, you must call in the 's method.

You must call in the 's method.

If your watch app has an existing WCSessionDelegate, then you must add a call to the method. If your watch app does not have a WCSessionDelegate then a default implementation is automatically provided.

Appfigurate's screen will now be displayed. You can now change the debugLogging and serverURL properties. Tap Apply⌄ to apply the configuration to your watchOS app.

Now jump to .

Edit app
APLConfiguration
APLConfiguration
APLApplicationDidFinishLaunching()
WKApplicationDelegate
applicationDidFinishLaunching
WKApplicationDelegateAdaptor
App
APLApplicationDidFinishLaunching()
WKExtensionDelegate
applicationDidFinishLaunching
APLApplicationDidFinishLaunching()
WKExtensionDelegate
applicationDidFinishLaunching
APLSessionDidReceiveMessage()
Configure app
Supported property types
iOS native app integration
AppfigurateSE macOS app
Duplicate app
iOS native app integration prerequisites