First Steps
iOS Classic - First Steps
You are viewing the V4 docs. (Note that v4 for iOS is in Beta. )
For the V3 docs, go here .
While reading the documentation, take a look at our Sample App.
Xcode 13
A known issue in Xcode 13.0 occasionally prevents smooth scrolling on iOS 15 devices.
This can affect users making fast-fling gestures through the Taboola Feed.
To address this, publishers are advised to use Xcode 13.1 or higher.
The following steps are required for both Classic and Web integrations.
Installation overview
- Install the Taboola SDK, using any one of the following dependency managers:
- CocoaPods
- Carthage
- Swift Package Manager (SPM)
- (Recommended) Add the SKAdNetwork ID for Taboola.
Flow 1: Install with CocoaPods
Install CocoaPods on your system
If not already present, install CocoaPods on your system:
- Run the following command from the Terminal:
$ sudo gem install cocoapods
- Wait for the installation to complete. Then run the following command to complete the setup:
pod setup --verbose
The above installation is required once per system.
Install Taboola SDK for your project
- Using the Terminal, navigate to your iOS project directory and run the following command:
$ pod init
This creates a Podfile for your project.
- Using a text editor, open your Podfile. Add the Taboola SDK dependency, with an exact version number - and save:
target 'DemoProject' do
# Comment out the next line if you're not using Swift and you don't want to use dynamic frameworks.
use_frameworks!
# Taboola SDK
pod 'TaboolaSDK', '~>4.0'
end
Make sure to indicate the latest version - e.g.
<<iosV4Version>>
.
- Using the Terminal, navigate to your iOS project directory and install the Taboola SDK:
$ pod install
- Quit Xcode and open the newly created workspace file - e.g.
DemoProject.xcworkspace
.
From this point onward, use the workspace (
.xcworkspace
) file, not the project (.xcodeproj
) file.
Update vs Install
If you already installed the Taboola SDK and just need to update the version - e.g. from
3.3.0
to3.4.0
- you can use theupdate
command:
- Edit the Podfile (as described above) and change the version number.
- Run:
pod update
.
Flow 2: Install with Carthage
Install Carthage on your system
If not already present, install Carthage on your system:
- In the Mac terminal, use Homebrew to install Carthage:
$ brew update
$ brew install carthage
This installation is required once per system.
Install Taboola SDK for your project
- Using a text editor, open your Cartfile. Enter the Taboola SDK dependency, with an exact version number, and save:
binary "https://cdn.taboola.com/taboola-mobile-sdk/ios/carthage/TaboolaSDK.json" == <<iosV4Version>>
Make sure to indicate the latest version - e.g.
<<iosV4Version>>
.
- Using the Mac terminal, run
carthage update
to build the framework. - In the Xcode project navigator, select the project node (top, left), and the
General
tab (right). - Scroll down to
Frameworks, Libraries and Embedded Content
and drag yourTaboolaSDK.framework
file into Xcode to add it. - Still within your project settings, select the
Build Phases
tab (top, right). - Click the
+
icon and selectNew Run Script Phase
:
a. Specify your shell (e.g.:
/bin/sh
).
b. Add the following line to the script area (below the shell path):
$ /usr/local/bin/carthage copy-frameworks
$ /opt/homebrew/bin/carthage
M1/M1X machine
On an M1/M1X machine, Homebrew installs Carthage on a different path.
Use this path:
/opt/homebrew/bin/carthage
c. Under
Input Files
, add the paths to the frameworks that you want to use. For example:
$(SRCROOT)/Carthage/Build/iOS/TaboolaSDK.framework
d. Under
Output Files
, add the paths to the copied frameworks. For example:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/TaboolaFramework.framework
Flow 3: Install with SPM (Swift Package Manager)
- Within
Xcode
, select theHelp
menu. Start typing"Add Packages..."
, and then select it from the options shown. - A modal dialogue displays:
- In the search box (top, right), paste in this URL:
https://github.com/taboola/taboola-spm-ios-sdk
.Information about the Taboola SDK package is shown.
- Tip: Using the dropdown provided (top), add a dependency rule - e.g.
Up To Next Major Version
. - Click on ‘Add Package’ (bottom, right).
The package tree displays in the Project navigator pane, under
Package Dependencies
.
- In the search box (top, right), paste in this URL:
Add the skAdNetwork ID for Taboola
With the release of iOS 14, you need to include the IDs of all your Ad Networks in Info.plist.
Requires Taboola SDK 3.2.0 or higher.
Method 1 (via the UI):
In Xcode:
- Open Info.plist from the project navigator.
- Next to the top-level key, click on Add (+):
- Enter SKAdNetworkItems as the new key's name.
- Select Array as the type.
- Expand the newly created Array key (using the arrow).
- Click on Add (+) and select Dictionary as the new key's type.
To add the Taboola Network ID:
- Expand the newly created Dictionary key (using the arrow).
- Click on Add (+):
- Enter SKAdNetworkIdentifier as the new key's name.
- Leave the type as String.
- Enter p4ybsjem3u.skadnetwork as the value.
Your newly created entries should like this:
To add more Ad Networks, repeat the previous step:
- Enter SKAdNetworkIdentifier as the name of each new key.
- Enter the Ad Network's unique ID as the value of the key.
Method 2 (via XML):
Edit Info.plist in a text editor and add this code snippet:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>p4ybsjem3u.skadnetwork</string>
</dict>
</array>
Troubleshooting
iPhone simulator with Apple silicon (M1/M2)
Problem
In some cases, when running the iPhone simulator with an Apple silicon (M1/M2) machine, Xcode throws the following error:
building for iOS Simulator, but linking in dylib built for iOS, file '../TaboolaSDK.framework/TaboolaSDK' for architecture arm64
This issue affects the simulator only - not real devices.
Resolution
To work around this problem, add arm64
to the excluded architectures for both your project and your Podfile.
Step 1: Update your project settings
Using Xcode:
- Select the project within the project navigator (top, left).
- Select the
Build Settings
tab (right). Make sure that theAll
tab (just below) is also selected. - Under
Architectures
, locate theExcluded Architectures
node. - Next to the
Debug
orRelease
node, click on the+
icon to add a new exclusion:- For the key, select
Any iOS Simulator SDK
. - For the value, type in
arm64
.
- For the key, select
Depending on your needs, add an exclusion under Debug or Release - or both.
- Scroll down to the
Build Options
section, and locate theValidate Workspace
node.- Set the value to
Yes
.
- Set the value to
Depending on your needs, set the value for Debug or Release - or both.
Step 2: Update your Podfile
Navigate to your project's ios
directory, and edit your Podfile to include the following:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
Additional steps
If the above steps do not resolve the problem, you may need to:
- Update your existing pods (a sample script is provided below).
clean
andrebuild
your project.
rm -rf ~/Library/Developer/Xcode/DerivedData/
pod deintegrate
pod update
The sample script
- Removes all build cache from Xcode.
- Updates all pods across your project.
Need a hand?
Go ahead! Ask a question in our Support Forum.
Tip: Provide as much detail as possible, including your platform and SDK version.
Updated about 1 month ago