The Causal Labs iOS SDK integrates Causal with native iOS apps.
- iOS 13.0+
- Swift 5.8+
- Xcode 14.0+
pod 'CausalLabsSDK', '~> 0.11.0'
Note
If you check-in the
Pods/
directory into git, we recommend that you git ignorePods/CausalLabsSDK/compiler/
.
- Install Java 11 (via homebrew)
brew install java11
- Update your
.zprofile
or.zshrc
(or equivalent)
export PATH="/usr/local/opt/openjdk@11/bin:$PATH"
export CPPFLAGS="-I/usr/local/opt/openjdk@11/include $CPPFLAGS"
Note
Homebrew should indicate the path to
java
when installation completes.Depending on your machine configuration,
java
may be located somewhere else. If so, you need to replace the path/usr/local/opt/openjdk@11/libexec/openjdk.jdk
to correspond to your Java installation location.
- Verify
java
is successfully installed and in yourPATH
$ which java
/usr/local/opt/openjdk@11/bin/java
$ java -version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment Homebrew (build 11.0.18+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)
- Symlink the JDK so that
causalc
(and/usr/libexec/java_home
) can find it
sudo ln -s /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
After integrating the SDK via CocoaPods and installing Java, you'll need to add a build script phase to your Xcode project.
- Navigate to your main application target's
Build Phases
tab. - Add a new
Run Script Phase
before theCompile Sources
phase. - Name the script phase
FDL Generation
. - Set the shell to
/bin/sh
. - Create your
Features.fdl
file and place it in your project directory. - Add a new file to your project called
Causal.generated.swift
. - Add the following script to invoke the compiler and generate your Swift code from your FDL.
${PROJECT_DIR}/Pods/CausalLabsSDK/compiler/bin/compiler --swift \
${PROJECT_DIR}/PATH_TO_YOUR/Causal.generated.swift \
${PROJECT_DIR}/PATH_TO_YOUR/Features.fdl
Note
Remember to replace
PATH_TO_YOUR
above with the paths to your own files.
Now you can build and run! If your build succeeds, you should see your generated code in Causal.generated.swift
. If your build fails, check the build logs and ensure your paths to the compiler and source files are correct.
See LICENSE.txt
for details.
Copyright © 2023-present Causal Labs, Inc. All rights reserved.