growthbook / growthbook-swift

GrowthBook iOS (Swift) SDK
MIT License
13 stars 19 forks source link

Quick Start Documentation out of sync with latest build #66

Closed philfi closed 4 months ago

philfi commented 4 months ago

Was looking to update our Swift SDK from 0.42 -> latest (0.57) and encountering an initializer error because the url argument is no longer supported. Checked the documentation and see that it still says the url argument is supported.

Looks like the argument was removed with this change: https://github.com/growthbook/growthbook-swift/commit/5c1f9aae8adba73f39f599fae20db841538532d5#diff-9fb9393d03752436c3248bcd9815cb5b09e5de06d63970e339799c7abbda954c

Seems like just need to rename the arguments but unclear without spelunking into all the changes. What is the correct way to initialize now?

Quick Start Documentation image

Error: image

philfi commented 4 months ago

Hmm actually seems like more to it, made change to update url -> apiHost and am now getting this error at runtime: FeaturesViewModel.swift:96 ERROR: Failed get api URL

vazarkevych commented 4 months ago

Hi, @philfi. Instead of using "url", in current version we use apiHost and clientKey params. It's important to fulfill them both. In your case it'll look like: private lazy var growthBook: GrowthBookSDK = GrowthBookBuilder( apiHost: "https://cdn.growthbook/. io", clientKey: "sdk-abc123", attributes: [:], trackingCallback: { experiment, experimentResult in 10g-debug ("User Viewed Experiment: (experiment.key) and is in variation: (experimentResult.variationId)") AnalyticsService.trackExperimentViewEvent( experimentId: experiment.key, variationId: experimentResult.variationId, inExperiment: experimentResult.inExperiment refreshHandler: { boolValue in 10g debug ("ExperimentService Cache Refreshed: (boolValue)") } ).initializer()

philfi commented 4 months ago

Yep that works thank you. Please update the documentation accordingly 🙏

vazarkevych commented 4 months ago

Yes, we have also uploaded a new PR for the documentation. We are currently waiting for it to be merged. We apologize for the inconvenience.

philfi commented 4 months ago

No worries thank you!