https://www.growthbook.io/ logo
Join Slack
Powered by
# sdk-swift
  • b

    brief-honey-45610

    09/21/2023, 4:05 AM
    set the channel description: Ask questions here related to the Swift SDK.
  • b

    brief-honey-45610

    02/15/2024, 8:28 PM
    Hi @most-spoon-61816 👋🏻 If I understand correctly, you are the maintainer of the Swift SDK for GrowthBook, correct? We have a customer who is seeing duplicate calls to the trackingCallback instead of it only being fired once per experiment. I suspect the Swift SDK may not be de-duplicating these calls, which is done in the JavaScript SDK for example. Is that true? If so, are there any plans to fix this in the next release?
  • m

    most-spoon-61816

    02/15/2024, 9:14 PM
    Hello @brief-honey-45610 yes, correct, we do maintain. Nice to meet you @millions-lunch-81673 We will check tomorrow and get back to you ASAP. Potentially might be the case, as you described, we will fix and do new releases quickly.
    🙌 1
    r
    • 2
    • 1
  • c

    calm-dog-24239

    02/16/2024, 5:18 PM
    Hi, @brief-honey-45610 we’ve addressed the issue of calling the trackingCallback twice, and now it’s functioning properly, only being invoked once. This change is currently under review, and we’ll proceed with merging it after the pull request changes are approved.
  • b

    brief-honey-45610

    02/22/2024, 4:59 PM
    Thank you, Maxim 🙂 Can you link me to the PR please?
  • c

    calm-dog-24239

    02/23/2024, 12:52 PM
    Hi, @brief-honey-45610 here is link to the pull request: https://github.com/growthbook/growthbook-swift/pull/46
  • c

    calm-dog-24239

    02/23/2024, 1:35 PM
    We have also released the latest version 1.0.45, which fixes this issue.
  • b

    brief-honey-45610

    02/26/2024, 5:14 PM
    Thank you!
    🙌 1
  • b

    bright-pharmacist-73946

    02/29/2024, 6:51 PM
    I am running into an issue using the latest Swift SDK (1.0.46). If I don't have
    backgroundSync
    set to
    true
    when configuring the
    GrowthBookSDK
    no features are returned. Dropping back to version 1.0.44 (after changing my setup code) everything works as expected.
  • c

    calm-dog-24239

    02/29/2024, 7:22 PM
    Hi, @bright-pharmacist-73946 we will check that and write update about that.
    🙏 1
  • c

    calm-dog-24239

    03/01/2024, 4:20 PM
    Hi @bright-pharmacist-73946, could you please provide additional information about this issue? We've conducted multiple tests, and each time we received features whether background sync was set to true or false. Additionally, in this version, we have fixed the issue with the tracking callback, which now runs only once per experiment.
    b
    • 2
    • 4
  • c

    calm-dog-24239

    03/05/2024, 4:15 PM
    Hi, @bright-pharmacist-73946, we also checked these two versions with the team, and we found features in 1.0.44 and in 1.0.46. However, we also identified one thing that could explain why this occurred. In the new version of the iOS GrowthBook SDK, we changed its initializer. Please pay attention to the new way to initialize the SDK. Now you have to add the API key and client key separately, without including “api/features” or “/sub/“. Just input your API host, for example: “https://cdn.growthbook.io”, and your client key, which should resemble this format: “sdk-YUtMizl6frtpEyL”.
  • b

    bright-pharmacist-73946

    03/05/2024, 4:26 PM
    Hey Maxim, thanks for the follow up. I will check this again today, but had the
    1.0.46
    code updated to use the
    apiHost
    and then include the
    clientKey
    separately. As I said, it worked briefly when I had
    backgroundSync
    enabled. In terms of the new initializer, that change came as a bit of a surprise and broke our builds when we did the swift package update since the initializer version used in
    1.0.44
    was completely removed.
    c
    • 2
    • 4
  • q

    quaint-lion-98240

    03/31/2024, 5:18 AM
    Hi All, Was just exploring the swift sdk. Does the SDK support real time updates without manual fetch?
  • c

    calm-dog-24239

    04/01/2024, 7:17 AM
    Hi, @quaint-lion-98240, yes, the Swift SDK supports real-time updates without manual fetching.
  • q

    quaint-lion-98240

    04/01/2024, 4:36 PM
    Thank you for the confirmation @calm-dog-24239.
    👍 1
  • b

    brief-honey-45610

    04/18/2024, 3:40 PM
    Hi @most-spoon-61816, would you be able to take a look at this issue soon? cc @brash-summer-91570 https://github.com/growthbook/growthbook-swift/issues/50
  • m

    most-spoon-61816

    04/18/2024, 3:43 PM
    Hi @brief-honey-45610 Sure, we will take a look
  • c

    calm-dog-24239

    04/19/2024, 1:08 PM
    Hi, @brash-summer-91570. In which version of the SDK did you encounter that issue, and which platform are you using (iPhone, iPad, Mac, Apple Vision)?
    b
    • 2
    • 2
  • m

    mammoth-wolf-34989

    04/28/2024, 4:28 PM
    Hello everyone Is there a way to implement a realtime feature listener? i want to be able to toggle a feature on/off for all users at once, currently iam using the
    refreshHandler
    call back in the GrowthBookBuilder initialiser to listen on changes, whenever it is called i use the
    isOn
    function on all my feature keys that i want, but after some minutes in a session, it stops sending call backs in refreshHandler, why is that and is there a way to implement what i need?
    c
    • 2
    • 8
  • f

    flaky-noon-11399

    09/30/2024, 3:40 PM
    Hey Team, a customer is encountering iOS SDK crashes when starting an experiment, they can't decode the response because the "isActive" parameter has no value (screenshot below). They are using remoteEvaluation. How do they debug these crashes?
    c
    b
    • 3
    • 17
  • f

    fancy-winter-56560

    10/17/2024, 9:25 AM
    Hey folks, I have a question regarding a problem I have faced using Swift SDK. During our experimentation, we realized that some of our users are included in the treatment group using our Java and Kotlin SDKs, but the very same users were NOT assigned to the treatment group on our Swift SDK. During debugging, we realized that our Java and Kotlin SDKs were on latest version but our Swift SDK was on 1.0.42 which is from August 2023. After updating it ot 1.0.62 which is from Sept 2024, we realized that FF values has changed to ‘true’ !! Is this a normal issue? Has there been something changes in between 0.42 to 0.62 ? If so which version exactly? Now, we are sort of afraid to update the SDK because we have other experiements and we don’t want users to lose the feature they have. Anyone faced similar issue? Thanks in advance 😌
    c
    r
    • 3
    • 12
  • c

    creamy-plastic-26432

    01/23/2025, 6:10 PM
    Hi everyone. I've implemented GrowthBook into my tvOS Swift application, and feature flags work perfectly, but I'm having trouble getting experimentation to work. Whenever I create an experiment and do attribute targeting, the
    trackingCallback
    is never called, and the experiment doesn't work. The only way I can get it to work is by using the
    user_uuid
    attribute. Then the callback is called and the experiment works fine. I've tried creating many attribute types and seeing if they will match, but none work. Does anyone have any suggestions on what to do?
    Copy code
    if let growthBook = growthBook {
                self.growthBook = growthBook
            } else {
                let builder = GrowthBookBuilder(
                    apiHost: apiHost,
                    clientKey: clientKey,
                    attributes: [
                        // None of these work
                        "platform": "tvos", // enum attribute type
                        "platform_is_tv_tvos": true, // boolean type
                        "is_tvos": "true" // string type
                        // If I use the user_uuid experimentation works
    //               "user_uuid": "3A662C6E-0A43-4BFB-B691-B25D685CD409"
                    ],
                    trackingCallback: { experiment, result in
                        print("[Debug] Experiment \(experiment.key) assigned variation \(result.variationId) with result \(result.value)")
                    }
                )
                let sdk = builder.initializer()
                self.growthBook = GrowthBookSDKWrapper(sdk: sdk)
            }
    f
    • 2
    • 2
  • s

    strong-mouse-55694

    01/23/2025, 6:29 PM
    Hi Fernando. Awesome that you got feature flags up and running on your tvOS app! For the experimentation part, I think things are working as intended. Experiment assignment, which variation a user sees, depends on the assignment attribute (the
    user_uuid
    ). If that's not present, then the experiment can't run and the CB won't fire. You can change what the assignment attribute is (but it should be something unique).
    c
    c
    • 3
    • 5
  • f

    flaky-noon-11399

    04/16/2025, 11:03 AM
    Hi Team, a customer has asked why dont we add "features: Data?" to initialiser with API key, in that case SDK will start with cached data for the Swift SDK? Attached is their usecase for this feature.
    c
    f
    • 3
    • 9
  • l

    late-ambulance-66508

    04/21/2025, 8:36 PM
    Hi there, I noticed that the SDK sends the request to the
    /sub/sdk-*
    endpoint and the server returns a 401 error:
    Copy code
    {
      "status": 401,
      "message": "No authorization token was found"
    }
    The SDK was initialized with
    backgroundSync: true
    setting. Now we can do a release without this option, but can you help sort out the problem please? SDK: 1.0.62
    Copy code
    apiHost: apiHost, // we use CloudFlare CDN, but see the same error with GB's CDN
    clientKey: clientKey,
    encryptionKey: nil,
    attributes: attributes,
    trackingCallback: { experiment, result in
        trackingCallback?(experiment.key, result.variationId)
    },
    refreshHandler: nil,
    backgroundSync: true,
    remoteEval: false
    c
    • 2
    • 10
  • b

    brave-controller-43565

    05/22/2025, 1:52 PM
    Hi, can anyone tell me ,if when u use
    setForcedVariation
    function, the trackingCallback is called after getting the results of the experimento via forcing the variation?
    c
    f
    • 3
    • 7
  • f

    flaky-noon-11399

    06/20/2025, 8:31 AM
    Hi Team, 2 of our biggest Enterprise customers are requesting error handling and retry logic in the Swift SDK related to this GitHub issue. The customers use case is in the screenshot. Is there a workaround solution that we can provide or is this on the roadmap?
    c
    • 2
    • 7
  • b

    brief-honey-45610

    07/11/2025, 7:30 PM
    Hi Team 👋🏻 We received an issue related to the Swift SDK tht we could use your help looking into. Summary Inconsistent behavior in the iOS (Swift) SDK when evaluating a client-side feature flag with Force Rules. Setup: • Two feature flags: a backend and a client one. • Both had identical Force Rules: a. Force default value for holdout Q2 control group b. Force default value for holdout Q2 test group c. Force test value for specific iOS user ID d. Force test value for specific Android user ID These test user IDs are confirmed to not be in the holdout group, and simulating their assignments using Python and iOS SDKs always returned "General Population." In the iOS app, the backend variation appeared as expected, but the client-side variation did not — it returned the control (False) value: • Backend flag returned expected test value in all cases (Python SDK, Swift SDK, Android app). • Client flag: ◦ ✅ Python SDK: value =
    True
    , source =
    Force
    ◦ ✅ Android app (Java SDK): value =
    True
    ◦ ❌ iOS (Swift SDK): value =
    False
    , source =
    cyclicPrerequisite
    The
    cyclicPrerequisite
    source in GrowthBook means a cycle was detected in feature prerequisites (i.e., a feature depending on itself). Evaluation is halted to avoid infinite loops. However, no prerequisites were defined in this setup. This source value was unexpected and only appeared in the Swift SDK. Can you investigate why the Swift SDK is returning
    cyclicPrerequisite
    for a client feature flag that: • Has no prerequisites • Is correctly forced to a test value via Force Rules • Returns the correct result in other SDKs (Python, Java)? Thanks!
    c
    • 2
    • 4
  • f

    flaky-noon-11399

    07/21/2025, 9:36 AM
    Hi Team, for the bucketing issue that is mentioned here for Android, is the same also happening for iOS?
    c
    • 2
    • 6