Using the Components in macOS and iOS Applications
Requirements: IPWorks
Contents
Introduction
There are two ways to use the components in applications for Apple platforms:
| Edition | Contents | Platforms | Languages |
|---|---|---|---|
| macOS Edition | An XCFramework (in the framework folder of the installation) | macOS, iOS, iOS Simulator, and Mac Catalyst (Intel and Apple Silicon) | Swift and Objective-C |
| C++ Edition | A dynamic library (in the lib folder of the installation) and C++ headers | macOS (Intel and Apple Silicon) | C and C++ |
For new applications, and for all iOS applications, the macOS edition is recommended.
macOS Edition
Adding the XCFramework
To add the XCFramework to an Xcode project, select the target, open the General tab, and click the + button under Frameworks, Libraries, and Embedded Content.

Select Add Other..., and then Add Files....

Browse to the framework folder of the installation, select the .xcframework file (e.g., IPWorks.xcframework), and click Open.

In the Embed column of the framework, select Embed & Sign, so that the framework is copied into the application bundle and signed with the application's signing identity.
The XCFramework can also be added by dragging it into the project navigator. In a multiplatform project, add it to each target that uses the components.
Xcode adds the framework to the Link Binary With Libraries build phase automatically. To verify this, open the Build Phases tab of the target, and expand Link Binary With Libraries.

Using the Components
To use the components, import the module. In Swift, each component is a class with the name of the component (e.g., HTTP), and methods report errors by throwing.
import IPWorks
let http = HTTP()
do {
try http.get(url: "https://www.example.com/")
print(http.transferredData)
} catch {
print(error)
}
In Objective-C, each component class has the name of the product as a prefix (e.g., IPWorksHTTP), and methods raise an NSException when an error occurs.
@import IPWorks;
IPWorksHTTP* http = [[IPWorksHTTP alloc] init];
@try {
[http get:@"https://www.example.com/"];
NSLog(@"%@", [http transferredData]);
} @catch (NSException* e) {
NSLog(@"%@", [e reason]);
}
Events are handled by assigning an object that implements the delegate protocol of the component (e.g., HTTPDelegate in Swift, or IPWorksHTTPDelegate in Objective-C) to the delegate property. Please see the demos included with the toolkit for complete examples.
Library Validation
macOS applications that use the hardened runtime only load frameworks that are signed by the same team as the application, unless library validation is disabled. When the framework is embedded using Embed & Sign, it is signed with the application's identity, and no further steps are needed.
If the framework is not re-signed (e.g., when it is loaded from outside the application bundle), disable library validation in the Signing & Capabilities tab of the target, by checking Disable Library Validation under Hardened Runtime.

Licensing
The trial version can be used without additional steps, and displays a dialog at runtime to indicate that a trial license is in use. To license a deployed application, generate a runtime license from the product key, and assign it to the runtimeLicense property of each component instance.
let http = HTTP()
http.runtimeLicense = "RUNTIME_LICENSE"
For more information, please see the readme file included in the installation.
C++ Edition on macOS
The C++ edition includes a dynamic library for macOS (e.g., libipworks.26.0.dylib in the lib folder of the installation, where 26.0 is the version), and the C++ header files for the components (in the include folder).
To use the library in an Xcode project, configure the target as follows.
In the Build Settings tab of the target, add the include folder of the installation to Header Search Paths. Add the .dylib file to the Frameworks, Libraries, and Embedded Content section of the General tab (or to the Link Binary With Libraries build phase). Add the lib folder of the installation to Library Search Paths, so that the library is found when linking. Ensure that the library can be found at runtime, either by embedding it in the application bundle (and adding @executable_path/../Frameworks to Runpath Search Paths), or by adding the folder that contains it to Runpath Search Paths.
The components can then be used by including the header file of each component (e.g., #include "http.h"). To license a deployed application, assign the runtime license to each component using the SetRuntimeLicense method.
Note that older versions of the toolkit were also distributed as a separate iOS edition (with a static library), and required Swift applications to use wrapper classes (e.g., IPWorksHTTPSwift) and a bridging header. In current versions, the macOS edition supports iOS directly, and its Swift classes can be used without a bridging header.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.