Prerequisites — Couchbase Lite for Objective-C
Description — Prerequisites for the installation of Couchbase Lite
Although the size of the Couchbase Lite framework that is downloaded is around 50MB, note that the framework would add only around 3.5MB to the size of the app when it is installed from the App Store. This is because when the user installs your app from the App Store, only the bits that are relevant to the device architecture are delivered.
The Couchbase Lite framework includes a "fat" binary that contains slices for both device (
arm64) and simulator (
x86_64) CPU architectures.
The fat binary allows you to link your app to the same framework and run your app on the simulator or a real device.
In addition, the bitcode that is included with the framework contributes to the majority of the download size.
Bitcode is an intermediate code representation that allows Apple to recompile the app after App submission and to deliver a thin version of the app specific to the device architecture.
When submitting a build of your application to the App Store you must ensure that it doesn’t contain any simulator architecture otherwise the upload will fail with the error message "Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]'."
The steps to remove the simulator architecture (x86_64) from CouchbaseLite.framework are outlined below in [ex-rmvsimarc]. They depend on the method you chose to install Couchbase Lite:
The Couchbase Lite framework available on the Couchbase Downloads page contains a build for both the simulator (x86_64) and iOS devices (ARM). The following steps describe how to set up a build phase in Xcode to do this automatically.
In Xcode, open the Build Phases tab, then select the + > Add Run Script Build Phase option.
Copy the contents of strip_framework.sh in the Run Script editor window.
That’s it, now every time you build and run your application, Xcode will remove binary architectures that do not match the target’s architecture type (emulator or device).
The following link describes how to set up a build phase in Xcode and run a Carthage script in order to remove the simulator architecture (x86_64).
You may encounter a
Target Integrity Error when building for iOS Simulator(or iOS).
This is because the embedded framework
CouchbaseLiteSwift.framework was built for iOS + iOS Simulator.
|Using XCFrameworks will ensure that the binaries used have the right architectures for the different platforms you target.|
As a workaround, you are recommended to strip the unnecessary architecture from the fat binary as described in Example 1
Within the folder containing the framework, use the
lipo command to convert the universal binary to a single architecture file.
Although you can disable bitcode within your app and strip away bitcode from the Couchbase Lite framework, it is not necessary to do so. In fact, it is probably best to leave it enabled to be future proof. This is because the bitcode is never downloaded by the user even though it is uploaded during App submission.
More information is available on this Apple Q&A page.