Drag and drop AppfigurateLibrary.xcframework into your project.
Note: Cocoapods integration is deprecated and support will be removed in the upcoming Appfigurate 4 release. Swift Package Manager is the suggested replacement.
Note: Ensure you are running Cocoapods 1.9.0 or later (to provide support for distribution of XCFrameworks).
Add the following to your apps Podfile:
pod'AppfigurateLibrary'
Run either the pod install or pod update from the terminal to download and build the AppfigurateLibrary pod.
Note: Cathage integration is deprecated and support will be removed in the upcoming Appfigurate 4 release. Swift Package Manager is the suggested replacement.
Add the following to your apps Cartfile:
github"electricbolt/appfiguratesdk"
Run the carthage update from the terminal to download the appfiguratesdk repository into your apps Carthage/Checkouts directory.
Note: Carthage will output the following error:
*** Skipped building appfiguratesdk due to the error:Dependency"appfiguratesdk"hasnosharedframeworkschemesIfyoubelievethistobeanerror,pleasefileanissuewiththemaintainersathttps://github.com/electricbolt/appfiguratesdk/issues/new
You can ignore this error as we will be using the Carthage/Checkouts directory (instead of Carthage/Build).
Drag and drop AppfigurateLibrary.xcframework from the Carthage/Checkouts/ directory into your project.
Add new app into Appfigurate Simulator
Run Appfigurate in the iOS Simulator.
Tap ≡Add app.
Select app type iOS.
Enter a URL scheme that will be used by Appfigurate to launch your app in order to read or apply configuration. The URL scheme must be 4-64 ASCII characters in length and must be unique to your app. e.g. YOUR-APP-URLSCHEME
Tap Add app.
Output source code snippets
Tap ≡YOUR-APP-URLSCHEME.
The Edit app screen will be displayed.
Under the SWIFT/IOS LIBRARY INTEGRATION section:
Tap Output implementation then tap Clipboard.
Open the macOS Console.app. Select the iOS Simulator device in the left hand pane. Type process:appfigurate in the search box in the top right.
In Appfiguate Simulator app, under the OBJ-C/IOS LIBRARY INTEGRATION section:
Tap Output header then tap Console.
Tap Output implementation then tap Console.
Create APLConfiguration subclass
In Xcode, tap File ‣ New ‣ New "Configuration.swift" file from Clipboard.
Note:your public key copied into the clipboard in the Output source code snippets section above will be different to the public key in the following example.
The APLConfigurationClass function with C calling convention must be implemented in your app otherwise a linker error will be issued. The recommended place to implement is at the bottom of your APLConfiguration subclass.
In Xcode, add a new Cocoa Touch class, subclassing APLConfiguration, e.g. Configuration
In your apps Configuration.h file, paste the .h header file output to the Console in the section Output source code snippets above.
In your apps Configuration.m file, paste the .m implementation file output to the Console in the section Output source code snippets above.
Note:your public key copied into the clipboard in the Output source code snippets section above will be different to the public key in the following example.
The APLConfigurationClass function must be implemented in your app otherwise a linker error will be issued. The recommended place to implement is at the bottom of your APLConfiguration subclass.
Edit Info.plist
In your apps Info.plist file (right click, Open As ‣ Source Code) include the following. Replace the text YOUR-APP-URLSCHEME with your own app's URL Scheme - the same value you added in the section Add new app into Appfigurate Simulator above.
importAppfigurateLibrary...funcapplication(_app: UIApplication, openurl: URL, options: [UIApplication.OpenURLOptionsKey :Any] = [:]) ->Bool {// When your app opens a URL while running or suspended in memory.returnAPLApplicationOpenURL(url)}funcapplication(_application: UIApplication, didFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey:Any]?) ->Bool {// After launch.APLApplicationDidFinishLaunchingWithOptions(launchOptions)returntrue}
Objective-C UIApplicationDelegate example
@import AppfigurateLibrary;
...
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
// When your app opens a URL while running or suspended in memory.
return APLApplicationOpenURL(url);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// After launch.
APLApplicationDidFinishLaunchingWithOptions(launchOptions);
return YES;
}
For apps using UIWindowSceneDelegate
If your app has a UIWindowSceneDelegate, in your apps SceneDelegate.swift/m file, include calls to APLApplicationOpenURL. Create any missing delegate methods as appropriate.
Swift UIWindowSceneDelegate example
importAppfigurateLibrary...funcscene(_scene: UIScene, openURLContextsURLContexts: Set<UIOpenURLContext>) {// When your app opens a URL while running or suspended in memory.iflet url = URLContexts.first?.url {APLApplicationOpenURL(url) }}funcscene(_scene: UIScene, willConnectTosession: UISceneSession, optionsconnectionOptions: UIScene.ConnectionOptions) {// After launch.iflet url = connectionOptions.urlContexts.first?.url {APLApplicationOpenURL(url) }}
Objective-C UIWindowSceneDelegate example
@import AppfigurateLibrary;
...
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
// When your app opens a URL while running or suspended in memory.
NSURL *url = [[[URLContexts allObjects] firstObject] URL];
APLApplicationOpenURL(url);
}
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// After launch.
NSURL *url = [[[connectionOptions.URLContexts allObjects] firstObject] URL];
APLApplicationOpenURL(url);
}
Test your iOS app
To test that you've successfully updated your app to use Appfigurate:
Compile and run your app to the Simulator instance.
Launch the Appfigurate Simulator app.
Tap your applications row. The app will be run and made visible, it's configuration read, and then swap back to Appfigurate.
Appfigurate's Configure app screen will now be displayed. You can now change the debugLogging and serverURL properties. Tap Apply⌄ to apply the configuration to your app.