Hi Team, a customer is facing an issue where users...
# sdk-swift
f
Hi Team, a customer is facing an issue where users are not being served the forced rule but the experiment rule. They have confirmed that in their workflow "init must be done with empty/dummy parameters, but we are updating them later when we know user's details" which would lead to the user not matching the force rule’s targeting at evaluation time. To debug this I thought loggingGrowthBook.getAttributes() immediately before evaluating the feature to confirm the attributes satisfy the force rule condition and if not setting them earlier would resolve this, but just found that getAttributes() does not exist on this SDK, is that true? Is there are alternate solution in swift equivalent to getAttributes() ? Also are there any methods for them to force re-evaluation once the attributes are set?
They're open to a web-approach approach and then reevaluate later once they have the attributes set if that will help here
c
Hi @flaky-noon-11399. Let us check that and we will write to you.
thankyou 1
f
Hello, it's our issue. We have 2 connected environments. The first one is dev, the second is prod. We are running some experiment. The result from experiment in the dev app is as expected, rules such as email with some regex pattern are working and we get the correct result. But on the prod app in the Appstore or Testflight it seems that the rules don't work and we get default values. The only difference in the code between the dev and prod apps is clientKey. Could you please tell us where the problem might be, whether in the code or in the GrowthBook settings? Thank you.
thankyou 1
c
Please let us check that more detail and I will write to you.
Hi @fierce-finland-25232 @flaky-noon-11399. You're correct. The Swift SDK doesn't have a getAttributes() method. However, you can access the current attributes via growthbook.context.attributes (In new release we will add getter for it). Simply calling evalFeature() again isn't the complete solution. The evalFeature() method only evaluates a feature based on the current state of the SDK. If the attributes have been updated but the SDK hasn't been notified, it won't apply the new values. The issue is a timing problem. The SDK evaluates the forced rule when it's initialized with empty attributes, causing it to fail the targeting. To fix this, you needs to manually trigger a re-evaluation after the attributes are set. The recommended solution for you is to implement this two-step process: Call growthbook.setAttributes(attributes: userDetails) to update the user attributes. Then, call growthbook.evalFeature() to force the SDK to re-run the evaluation with the correct data. This will ensure the forced rule is applied correctly. The same logic applies to the dev vs. prod issue; you must ensure the correct attributes are being passed at the correct time in the production environment.
f
Thank you for answer, I applied the changes you wrote about, the problem is still there, dev app still takes values ​​from experiments, and prod app still does not accept rules. I checked the settings of dev and prod environments in GrowthBook, they seem to be the same, the flag is enabled on all environments. encrypted payload is disabled, client keys are correct.
c
Hi @fierce-finland-25232. Are the prod and dev apps getting the same features response from GrowthBook?