Integrating Specto using Swift Package Manager

πŸ“˜

Specto supports integration with Swift Package Manager in Xcode 12.5 or later.

Add dependency to Xcode

  1. In Xcode, go to File > Swift Packages > Add Package Dependency...
  2. Enter https://github.com/specto-dev/Specto-SwiftPackage as the package URL and click Next
Entering the Specto Swift package URL in Xcode (step 2)Entering the Specto Swift package URL in Xcode (step 2)

Entering the Specto Swift package URL in Xcode (step 2)

  1. Select a version constraint. We recommend the default setting of Up to Next Major. Click Next
Selecting the version constraint for the Specto Swift package (step 3)Selecting the version constraint for the Specto Swift package (step 3)

Selecting the version constraint for the Specto Swift package (step 3)

  1. Add the Specto package target to your application target. Click Finish
Add the Specto Swift package target to your application target (step 4)Add the Specto Swift package target to your application target (step 4)

Add the Specto Swift package target to your application target (step 4)

  1. You should see the Specto package in the list of Swift packages in the Xcode project navigator
Successful integration of Specto as a Swift Package Dependency (step 5)Successful integration of Specto as a Swift Package Dependency (step 5)

Successful integration of Specto as a Swift Package Dependency (step 5)

Add Run Script build phase

Specto uses a tool that runs at build time to synchronize your app metadata and upload debug symbols (dSYMs) to our service. Download the tool here. We recommend putting the SpectoTools directory in the root of your project directory. If you choose to place it in an alternate location, remember to change the references to $(SRCROOT)/SpectoTools in the steps below to the actual path.

πŸ“˜

A new version of the symbol upload tool is released alongside every new SDK release. When you update your SDK, remember to update the symbol upload tool as well.

Once you've downloaded the tool, follow the steps below to add the Run Script build phase:

  1. Select your project from the Xcode Project Navigator
  2. Select your application target
  3. Select the Build Phases tab
  4. Click the + button on the top left
Adding a Run Script build phase in Xcode (steps 1-4)Adding a Run Script build phase in Xcode (steps 1-4)

Adding a Run Script build phase in Xcode (steps 1-4)

  1. Click New Run Script Phase
Adding a Run Script build phase in Xcode (step 5)Adding a Run Script build phase in Xcode (step 5)

Adding a Run Script build phase in Xcode (step 5)

  1. Ensure that the new build phase is ordered after all of the other build phases, and give it a descriptive name
  2. Copy the API key that was automatically created upon sign up or create a new API key from the dashboard and use the following as the contents of the script, replacing the placeholder with your actual API key:

For Release builds only

If you only want to upload symbols that are built with a Release configuration, use the following script:

"${SRCROOT}/SpectoTools/specto-upload-symbols" --key "Insert your API key here"

For all builds (including Debug)

If you want to upload symbols for all builds, add the --allow_debug option:

"${SRCROOT}/SpectoTools/specto-upload-symbols" --key "Insert your API key here" --allow_debug

By default, Xcode does not generate dSYM files for debug builds. You will need to set Debug Information Format to DWARF with dSYM File for both Debug and Release configurations:

Setting the Debug Information Format setting to DWARF with dSYM File in Xcode build settingsSetting the Debug Information Format setting to DWARF with dSYM File in Xcode build settings

Setting the Debug Information Format setting to DWARF with dSYM File in Xcode build settings

8. (Going back to the Build Phases tab) Make sure that the Based on dependency analysis checkbox is unchecked. We also recommend that you uncheck the For install builds only checkbox, but you can optionally leave this option checked if you only want to upload symbols for Archive builds that are generated for an App Store or TestFlight submission. Enabling this option means that you won't be able to use Specto in your local development builds, which is why we recommend unchecking the box.

Adding a Run Script build phase in Xcode (steps 6-8)Adding a Run Script build phase in Xcode (steps 6-8)

Adding a Run Script build phase in Xcode (steps 6-8)

Build and run the app

  1. Build & run (⌘ + R) the app to run the upload tool, which will register your application with the Specto service. If you chose above to only enable symbol uploads for Release or Archive builds, ensure that your current build configuration is set accordingly
  2. Select the Report Navigator tab
  3. Select the latest Build action
  4. Find the Run Script build phase step for the Specto upload tool and ensure that it succeeded without any errors or warnings
  5. If the step failed, click the disclosure button to expand the step and view the logs. Include these logs when contacting support
Building & running the app in Xcode, and viewing the build results (steps 1-5)Building & running the app in Xcode, and viewing the build results (steps 1-5)

Building & running the app in Xcode, and viewing the build results (steps 1-5)


What’s Next

Follow the quick start guide to configure the Specto SDK and collect your first performance metrics.