Repository navigation
1.5.0 is source compatible with 1.4.0: code written against 1.4.0 compiles unchanged, with the same
PromiseKit and SwiftyJSON types, minimum platforms and Swift tools-version (5.3). It is the last 1.x
feature release. A 2.0 SDK with a new, async-first API is planned; 1.x will be maintained (bug and
security fixes, from the release/1.x branch) for 12 months after 2.0 ships.
Added
- async/await overloads of every Promise-returning method, in the new
ABSmartlyAsyncmodule
(import ABSmartlyAsync, part of theABSmartlySwift Package Manager product; iOS 13, macOS 10.15,
tvOS 13, watchOS 6):Context.waitUntilReady(),refresh(),publish(),close(),finalize(),
ABSmartlySDK.getContextData(),close(), theClient,ContextDataProvider,
ContextEventHandlerandHTTPClientmethods, andDefaultHTTPClient.request. Each awaits the existing Promise, so behaviour is
unchanged; cancelling the calling task does not cancel the request. They are in a separate module
because, inside anasyncfunction, Swift prefers an async overload, so 1.4.0 code such as
_ = context.publish()there would no longer compile if they were inABSmartly. Once any module
in a build importsABSmartlyAsync, the overloads are visible to all code usingABSmartly, so
such code then needstry await, an explicitPromisetype, or Swift 6.1'sMemberImportVisibility
(see the README). With Swift 6
compilers they run in the caller's isolation (#isolation), so they can be awaited from
@MainActorcode in Swift 6 apps without Sendable diagnostics. Not available through CocoaPods. - Holdouts, matching the JavaScript SDK.
ContextData.holdoutsandExperiment.holdoutIdsare decoded
(withExperiment.holdoutType, informational), and a unit held out by any holdout covering an
experiment gets the control variant and values with no exposure of its own; in a three-arm holdout,
arm 1 holds out only experiments that are not full-on. Each covering holdout publishes an ordinary
exposure (its id, name and the unit's arm) the first time a covered experiment is read. Overrides and
matching assignment rules still win. A payload without holdouts assigns and publishes exactly as
before (v1.4.0 ignored holdouts).ContextData(experiments:holdouts:)is a new initialiser;
ContextData(experiments:)andContextData()are unchanged. A malformed holdout entry is ignored on
its own. - Assignment rules (
Experiment.assignmentRules), matching the JavaScript SDK. The first rule whose
environmentsandconditionsmatch sets the variant:assigngives a fixed variant,split
hashes the unit with the experiment's seed over the rule's percentages (which must sum to 100 within
0.01). A matching rule wins over audience/audienceStrict, traffic eligibility, full-on and custom
assignments; only an override beats it. Exposures carry a newruleOverrideflag. A split matched
before its unit is set gives the experiment's no-unit result (the full-on variant, else 0) and is
re-resolved when the unit is set, unless it was already exposed. Malformed rules are skipped; a split
whose length differs from the variant count, or an out-of-boundsassignvariant, falls back to
normal assignment. semver_eq,semver_gt,semver_gte,semver_ltandsemver_lteJSON-expression operators.- Linux support: the SDK builds and its tests pass with Swift 5.10, 6.1 and 6.4 on Linux (CI runs 5.10 and 6.1).
On LinuxABSmartly.JSONis a vendored copy of SwiftyJSON 5.0.2'sJSONwith the same API (SwiftyJSON
itself does not compile there) and MD5 is computed in the SDK; Apple platforms are unchanged
(SwiftyJSON~> 5.0, CommonCrypto). No new package dependencies. ClientConfig.applicationVersionandClientConfig.init(apiKey:application:endpoint:environment:applicationVersion:).ABSmartlySDK(endpoint:apiKey:application:environment:…)convenience init, withretries
defaulting to 3 likeDefaultHTTPClientConfig.- Cross-SDK spellings, as aliases of the 1.4.0 types (not deprecated):
ABsmartlySDK,
ABsmartlyConfig,ContextPublisher,DefaultContextPublisher,ABSmartlyConfig.contextPublisher
andinit(contextDataProvider:contextPublisher:…). - Numeric unit UIDs:
setUnit(unitType:uid: Int/Double),setUnit(unitType:value: JSON),
getUnitValue/getUnitValueskeep the number type; numbers hash like the JavaScript SDK (rounded
to an integer, so 125.75 hashes as "126"). Like JavaScript numbers, integers above 2^53 lose
precision; pass larger IDs as strings. finalize()/isFinalized()/isFinalizing()aliases,ContextEventLoggerEvent.finalize(an alias
for.close),readyError(),getCustomFieldKeys(experimentName:).Hashingis public, withhash(String),hash(Double),utf8Bytes,base64UrlNoPadding;
ABSmartlyErroris public.- A
v*tag can publish the podspec to the CocoaPods trunk (the tag, podspec and SDK version must
agree). The job is off until the repository variableCOCOAPODS_PUBLISHistrue; see the
CocoaPods note under Compatibility.
Changed (cross-SDK contract)
- Holdouts configured in A/B Smartly take effect (v1.4.0 ignored them; see Added). A unit held out by
a holdout covering an experiment moves to the control variant, and that experiment's exposure is
replaced by the holdout's own exposure. Experiments not covered by a holdout are unchanged; a unit
that is not held out is assigned as before, plus one exposure per covering holdout. - Audiences and assignment-rule conditions see the configured
applicationandenvironmentnames
as attributes, as in the other SDKs. An experiment with a strict audience onenvironmentor
applicationused to give every unit variant 0 (the attribute was never set); it now matches. A
user-set attribute of the same name wins. These are evaluation-only: they are not published and not
returned bygetAttributes().app_versionis never injected. - Audiences are re-evaluated when attributes change, as in the Java SDK (released in 1.9.0) and the
JavaScript SDK. The system-attributes contract requires it: a user-setenvironment/application
wins over the configured value even when set after the context is created, so it has to
invalidate an assignment cached before it was set. AsetAttributeafter a treatment was read can change
that experiment's assignment (and log a new exposure) when the audience result flips. - The
X-Agentheader isabsmartly-swift-sdk/<version>(wasabsmartly-swift-sdk). - The context GET carries the same headers as the publish PUT (
X-API-Key,X-Agent,X-Application,
X-Application-Version,X-Environment), as the JavaScript SDK does. X-Application-VersioncarriesClientConfig.applicationVersionnormalised for the collector, which
only accepts an integer: the trimmed value when it is 1–18 ASCII digits, otherwise"0"(like the
Java SDK). 1.4.0 always sent"0".- Every exposure in the publish payload carries
ruleOverride(falsewhen no assignment rule matched). - A negative
ContextConfig.publishDelaydisables the automatic publish, matching the Java and
JavaScript SDKs andmain: exposures and goals stay queued untilpublish()orclose(), which
still send them. 1.4.0 scheduled the publish with the negative delay, so it published right after
the first event of each batch (events arriving while that publish was pending joined it). Apps on
1.4.0 that setpublishDelayto-1now callpublish()themselves.
Fixed
-
Variable keys shared by several experiments. This affects anyone running two or more experiments
whose variants define the same variable key. Unreleased builds ofmainafter 1.4.0 exposed every
experiment they checked for a key, recording users in experiments they never saw. They also took the
value from a later experiment when the winner's variant lacked the key, which biases the winner's
results. 1.4.0 itself exposed only the winner and did neither. The rule now applied, matching the
Java SDK:- A key's candidates are the experiments whose variants define it, in ascending id order.
- The winner is the first candidate the user is in: assigned, overridden or selected by an
assignment rule. When no candidate qualifies, the first held-out candidate supplies its control
value (see Holdouts). OtherwisegetVariableValuereturns the default. - When the winner's variant does not define the key, the default is returned. A later candidate is
never used because of the variant the user got. - Only the winner is exposed. Candidates that were checked but did not win get no exposure; a later
getTreatmenton one still exposes it once. Each holdout covering a checked candidate publishes
its own exposure, as in Java.peekVariableValueexposes nothing. - As in Java, a refresh that changes only variant configs (same experiment iteration) keeps an
assignment already resolved in the context, including its variables. If that winner's variant
did not define the key before the refresh,getVariableValuestill returns the default.
Compared with 1.4.0, a candidate won by an assignment rule now counts as the winner, and holdouts
apply. -
setOverridewith a negative variant no longer crashesgetTreatmentorgetVariableValue
(1.4.0 trapped with an index out of range). The override is returned and exposed; a variable read
gives the default. -
A
jsoncustom field holding valid non-object JSON (array, number, string, boolean) is returned as
JSONbygetCustomFieldValue; 1.4.0 returnednilbecause theVariableParseronly accepts objects.
nullreturnsnil. Objects and invalid JSON still go through the configuredVariableParser, and
the field gets whatever it returns (the default parser returnsnilfor invalid JSON, which is now
also logged with the field and experiment name). A customVariableParseris no longer called for
non-object ornullJSON custom fields.
Abooleancustom field keeps 1.4.0's coercion (Bool(value): only"true"/"false"). -
Contextmethods no longer crash the app on misuse (reading before ready, writing after close, a
blank or changed unit): 1.4.0 hit aprecondition. Reads return a default (0,nil, the
defaultValue, empty collections), writes are ignored, and an.errorevent with the 1.4.0 message
is logged.setOverride(s)/setCustomAssignment(s)are accepted after close, as before. -
publish()andclose()reject when the collector answers with a non-2xx status; 1.4.0 reported the
failed publish as success and dropped its events. Failed events are re-queued, and a failedclose()
leaves the context open with one automatic publish scheduled for them (a single attempt; after
thatpublish(),close()or the next event retries) (1.4.0 marked it closed with the events
lost). With a negativepublishDelaynothing is retried automatically, neither on the failed
close()nor on the next event: callpublish()orclose()again. A failedclose()does not itself restart the refresh timer. A refresh already in flight
can restart it if it succeeds after the close rejects, and a later successful explicit refresh
can restart it too.
getContextData()rejects a non-2xx response with an HTTP error instead of a decoding error. -
MurmurHash3 read past the end of a key with a 3-byte tail (an out-of-bounds read). The SDK only
hashes 22- and 12-byte keys, so variant assignment is unchanged. -
ABSmartlyConfig.contextEventLoggeris used for every context whoseContextConfig.eventLoggeris
unset, as documented in 1.4.0's README; 1.4.0 stored it but never used it. -
DefaultSchedulerruns its callbacks on a private utility queue instead of the main queue, so
timers no longer block or wait for the main thread. -
A context whose first load failed recovers when a later
refresh()succeeds (isFailed()false,
readyError()nil); 1.4.0 installed the refreshed data but kept the context failed and silently
discarded every exposure and goal. Exposures made while it was failed (without experiment data)
are dropped on recovery and the next read exposes the user's actual variant once, so a logger can
see an.exposureevent that is never published. Goals tracked or re-queued while it is failed
are kept for recovery: no automatic publish is scheduled for a failed context (in 1.4.0 any event
on it started one that discarded the queue). An explicitpublish()orclose()of a failed
context still discards the queue, as in 1.4.0. Until the context recovers or the queue is
discarded, those events stay in memory and are counted bygetPendingCount().
A refresh that completes while the initial load is still pending makes the context ready,
settlingwaitUntilReady()and logging.readyonce.
Swift-specific: the JavaScript SDK does not refresh a failed context at all. -
No exposures after close;
refresh()joins an in-flight refresh;close()waits for in-flight
publishes; a pending automatic publish keeps the context alive until it is sent. -
A refresh whose fetch completes after
close()has started is discarded: it installs no data, does
not make a failed context ready, and logs no.refreshor.errorevent, so its result cannot
change the context afterclose()has resolved. A refresh that installed its data beforeclose()
started is not undone, and its.refreshevent may still reach the logger after.close. -
Work no longer runs on the main queue (timers, HTTP retries, publish recovery);
ready,refresh,
publish,closeanderrorevents from asynchronously completed work still reach the
ContextEventLoggeron the main thread on Apple platforms, as in 1.4.0. As in 1.4.0, events raised
synchronously by a call (exposure,goal, misuse errors,closeof an idle context, and the
events of a context created with data that was already loaded or failed) reach the logger on the
calling thread. -
An audience of
nullor{}is treated as no audience without logging an error. -
matchgives up after 100ms (returning null) on patterns that backtrack exponentially. -
A failed automatic refresh reports one
.errorevent (it was reported twice on main). -
A request keeps its
DefaultHTTPClientalive until it settles, as in 1.4.0, so dropping the client
mid-request no longer leaves the Promise pending forever (main-era regression). -
The HTTP request timeout uses
connectionRequestTimeout; data races and crashes under concurrent
use. -
No compiler warnings in the SDK with Swift 5.10–6.4 toolchains.
Compatibility notes
- Checked on Linux before release: the 1.4.0 test suite and an app written against the 1.4.0 README
compile unchanged against 1.5.0 (the 1.4.0 tests that fail are the contract changes above), and
swift-api-digesterfound no source-breaking change in 1.4.0's public API and no ABI break,
comparing library-evolution builds of 1.4.0 and 1.5.0. Building 1.4.0 on Linux needed local shims
(CommonCrypto, OSLog, FoundationNetworking, the vendored JSON) that are not in the repository, so
this is not reproducible from the repo alone. Apple ABI was not measured. - On Linux,
ABSmartlyErrorsubclassesNSError, because Foundation in Swift 6.0 and 6.1 crashes
whenlocalizedDescriptionis read on a class-based error that is not anNSError
(swift-corelibs-foundation#5221). - The declared minimum platforms are unchanged (iOS 10, macOS 10.14 for Swift Package Manager / 10.10
for CocoaPods, tvOS 10, watchOS 3). Current Xcode cannot build for watchOS below 5, so CI builds
watchOS at 5.0 and iOS/tvOS at the package minimums. - CocoaPods:
pod lib lint/pod trunk pushcurrently fail on Xcode 16.3 and 26 while building
the dependency pods, before the SDK is compiled: SwiftyJSON 5 declares macOS 10.9 (availability
errors) and, on Xcode 26, PromiseKit 6's iOS 8 target needs the removedlibarclite. The SDK
itself builds for every Apple platform with Swift Package Manager. So thev1.5.0tag does not
publish 1.5.0 to the CocoaPods trunk: the publish job's trunk push is off (COCOAPODS_PUBLISH),
and that switch only affects tags pushed after it is set. A 1.5.x pod needs the dependency pods to
validate on the publishing Xcode; raising this podspec's own targets does not change theirs. - Toolchains 5.9 and later read
Package@swift-5.9.swift, which is identical toPackage.swiftexcept
that the SwiftyJSON dependency also names Mac Catalyst and visionOS.