Install Guides
Swift
you can integrate the ditto sdk into swift projects to develop native apps for apple ios and macos platforms to install the ditto sdk and start syncing offline confirm that you meet the minimum requirements ( /#prerequisites ) install the necessary dependencies ( /#installing package dependencies ) set up your app permissions ( /#configuring permissions ) authenticate with the big peer and then start syncing offline ( /#integrating and initializing sync ) prerequisites following are the minimum requirements that must be met before attempting to install ditto ios version 14 or later mac catalyst 14 or later macos ( appkit) version 11 or later tvos version 14 or later (optional) visionos version 1, 1 1, or 1 2 installing package dependencies using xcode or cocoapods, add the necessary dependencies click file , and then select add package dependencies from the menu in the modal that appears c opy paste the following url into the search box in the upper right corner https //github com/getditto/dittoswiftpackage s elect dittoswiftpackage from the list click dependency rule and select the version of ditto you want to use if building a production level app, see docid\ d0rajszrgf1anirancfb6 if testing ditto with apple vision pro devices, see docid\ d0rajszrgf1anirancfb6 click add package for more information, see the official apple documentation > https //developer apple com/documentation/xcode/adding package dependencies to your app#3512138 from the choose package products for dittoswiftpackage modal click add to target and select your app from the list click add package developing for production to install the latest production release of the ditto sdk for swift click the dependency rule dropdown menu and select up to next major version from the list in the field on the right, set the version to 4 7 2 exploring with visionos beta ditto now supports the visionos platform in beta for our swift sdk for an overview of the ditto sdk for visionos, including steps outlining example integration with our demo chat app, https //apps apple com/us/app/dittochat/id1450111256 , see docid 9eyfpnj xg4j r85evdah to install the visionos beta ditto swift package, set the dependency rule to 4 8 0 v as follows click the dependency rule dropdown menu and select exact version from the list in the field on the right, set the version to 4 7 2 for the visionos binaries in github, see https //github com/getditto/dittoswiftpackage/releases/tag/4 8 0 visionos beta 1 library in the https //github com/getditto/dittoswiftpackage repo confirm that you have cocoapods version 1 1 0 or later installed for installation and upgrade instructions, see the official cocoapods https //guides cocoapods org/using/getting started html#installation guide open the podfile for your project, and then add the following to indicate to use dynamic frameworks for the pods you're integrating use frameworks! from your project directory, install the dittoswift framework bash pod 'dittoswift' install the latest version of ditto sdk package dependencies pod install repo update configuring permissions once you've added ditto sdk package dependencies configure your project's info plist file to ensure the necessary permissions for bluetooth low energy (le) and local network services are included ( /#ensuring privacy compliance ) if enabling the data protection entitlement, allow access after your end users have unlocked their device for the first time after a system restart ( /#setting protection entitlement ) ensuring privacy compliance configure your app for compliance with apple's guidelines for ios permissions by doing the following for more information, see the official apple documentation for https //developer apple com/design/human interface guidelines/privacy from xcode, add a new custom ios target properties entry from the left navigator area, click your project in the editor that appears, click info tab right click any row in the list, and then select add row from the menu for instructions on configuring permissions for your app, see docid 6exkalkyxp2fcbsoan6 q from your project's info plist file, add the following key value pairs, which display as dismissable prompts to your end users explaining why the app requires certain permissions key nsbluetoothalwaysusagedescription type string value uses bluetooth to connect and sync with nearby devices key nsbluetoothperipheralusagedescription type string value uses bluetooth to connect and sync with nearby devices key nslocalnetworkusagedescription type string value uses wifi to connect and sync with nearby devices key nsbonjourservices type array value item0 " http alt tcp " (string)\<key>nsbluetoothalwaysusagedescription\</key> \<string>uses bluetooth to connect and sync with nearby devices\</string> \<key>nsbluetoothperipheralusagedescription\</key> \<string>uses bluetooth to connect and sync with nearby devices\</string> \<key>nslocalnetworkusagedescription\</key> \<string>uses wifi to connect and sync with nearby devices\</string> \<key>nsbonjourservices\</key> \<array> \<string> http alt tcp \</string> \</array> if y our end users prefer a language other than english, replace each default string assigned to value with their language equivalents from xcode, ensure your app continues to sync while it runs in the background, as well as when the end user device is locked by enabling bluetooth background modes from the left navigator area, click your project click signing & capabilities click + capability and then, from the modal that appears, search and select background modes from targets , select your app from the list from background modes , click to select the following uses bluetooth le accessories acts as a bluetooth le accessory setting protection entitlement if enabling the data protection entitlement, allow access after the end user has unlocked their device for the first time after a system restart by setting the entitlement to nsfileprotectioncompleteuntilfirstuserauthentication for more information, see the official apple documentation for https //developer apple com/documentation/bundleresources/entitlements/com apple developer default data protection integrating and initializing sync once you've set up your environment, import the ditto sdk in your codebase and obtain your access credentials unless you have a specialized use case, such as a government app, you must connect to the internet at least once before you can sync offline with other peers for more information, contact ditto (see docid\ n4civtbqal1smgjno8am8 ) from the top most scope of your app's codebase, add the following to set up authentication and start syncing offline replace your app id and your playground token with your access credentials available from the portal for instructions on how to obtain your access credentials, see docid\ u214qhyymcxbv9jnamrfh let ditto = ditto(identity onlineplayground( appid "your app id", token "your playground token" )) do { try ditto startsync() } catch (let err) { print(err localizeddescription) }