Troubleshooting

The best ways to understand sources of failure are to (1) view the Requests tab in the AIProxy dashboard and (2) view the Live Console tab while making a test request.
DeviceCheck

Missing or badly formatted authorization token

If you are seeing {"error":{"message": "Missing or badly formatted authorization token"}}. it means that DeviceCheck is failing. This is caused by your bundle identifier in Xcode not matching a bundle identifier listed in your Apple Developer account. To fix:

  1. Make sure that your app's bundle identifier in Xcode matches an identifier listed in your Apple Developer dashboard under the identifiers section here.
  2. Make sure the Apple identifier is in the account that you are signing your app with.
DeviceCheck

Requests failing DeviceCheck

  • DeviceCheck is not available in iOS simulators, so if you are making requests from a simulator you must include a bypass token in the request. Follow these steps to add your bypass token to Xcode.
  • If you are building and running on device, the bundle identifier of your app must match exactly an App ID in your Apple Developer dashboard. You can find your app identifiers here.
  • In Xcode under Targets > Signing and Capabilities, make you're signing the app with a developer account that contains that App ID.
  • Other things to double check:
    • Make sure the DeviceCheck key ID in our dashboard matches the DeviceCheck key ID on the Apple web portal.
    • Make sure the Apple Team ID in our dashboard matches the Team ID displayed on the Apple web portal.
AIProxySwift

No such module 'AIProxy' error

Occassionally, Xcode fails to automatically add the AIProxy library to your target's dependency list. If you receive the No such module 'AIProxy' error, first ensure that you have added the package to Xcode using the Installation steps. Next, select your project in the Project Navigator (cmd-1), select your target, and scroll to the Frameworks, Libraries, and Embedded Content section. Tap on the plus icon:

No such module

And add the AIProxy library:

No such module
AIProxySwift

MacOS network sandbox

If you encounter the error:

networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.

Modify your macOS project settings by tapping on your project in the Xcode project tree, then select Signing & Capabilities and enable Outgoing Connections (client)

AIProxySwift

'async' call in a function that does not support concurrency

If you use the snippets above and encounter the error:

'async' call in a function that does not support concurrency

it is because we assume you are in a structured concurrency context. If you encounter this error, you can use the escape hatch of wrapping your snippet in a Task {}.

AIProxySwift

Requests to AIProxy fail in iOS XCTest UI test cases

If you'd like to do UI testing and allow the test cases to execute real API requests, you must set the AIPROXY_DEVICE_CHECK_BYPASS env variable in your test plan and forward the env variable from the test case to the host simulator (Apple does not do this by default, which I consider a bug). Here is how to set it up:

  • Set the AIPROXY_DEVICE_CHECK_BYPASS env variable in your test environment:
    • Open the scheme editor at Product > Scheme > Edit Scheme
    • Select Test
    • Tap through to the test plan

      XCTest UI test case

    • Select Configurations > Environment Variables

      XCTest UI test case

    • Add the AIPROXY_DEVICE_CHECK_BYPASS env variable with your value

      XCTest UI test case

  • Important - Edit your test cases to forward on the env variable to the host simulator:
    func testExample() throws {
        let app = XCUIApplication()
        app.launchEnvironment = [
            "AIPROXY_DEVICE_CHECK_BYPASS": ProcessInfo.processInfo.environment["AIPROXY_DEVICE_CHECK_BYPASS"]!
        ]
        app.launch()
    }
SwiftOpenAI

Extra argument 'aiproxyServiceURL' in call when initializing SwiftOpenAI

This error is caused by having an older version of the SwiftOpenAI package. Xcode has a quirk where it defaults an SPM package's upper limit to 2.0.0. This package is beyond that limit, so you should not accept the defaults that Xcode proposes. Instead, enter the lower bound of the release version that you'd like to support (for example), and then tab out of the input box for Xcode to adjust the upper bound. Alternatively, you may select branch -> main to stay on the bleeding edge.

SwiftOpenAI
SwiftOpenAI

Property definition has inferred type 'some OpenAIService', involving the 'some' return type of another declaration

When initializing with SwiftOpenAI, make sure you add the OpenAIService type before service. For ex:

let service:OpenAIService = OpenAIServiceFactory.service(
    aiproxyPartialKey: "your_partial_key_goes_here",
    aiproxyServiceURL: "your_service_url_goes_here"
)