Skip to content

Commit ee0aff1

Browse files
authored
Merge pull request adobe#605 from adobe/staging
3.1.1 release
2 parents 6e8c146 + 6eb99ca commit ee0aff1

21 files changed

+151
-69
lines changed

AEPCore.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "AEPCore"
3-
s.version = "3.1.0"
3+
s.version = "3.1.1"
44
s.summary = "Core library for Adobe Experience Platform Mobile SDK. Written and maintained by Adobe."
55
s.description = <<-DESC
66
The core library provides the foundation for the Adobe Experience Platform SDK. Having the core library installed is a pre-requisite for any other Adobe Experience Platform SDK extension to work.
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
1818

1919
s.dependency 'AEPRulesEngine', '1.0.0'
20-
s.dependency 'AEPServices', '3.1.0'
20+
s.dependency 'AEPServices', '3.1.1'
2121

2222
s.source_files = 'AEPCore/Sources/**/*.swift'
2323

AEPCore.xcodeproj/project.pbxproj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,7 @@
34783478
"@executable_path/Frameworks",
34793479
"@loader_path/Frameworks",
34803480
);
3481-
MARKETING_VERSION = 3.1.0;
3481+
MARKETING_VERSION = 3.1.1;
34823482
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.core;
34833483
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
34843484
SKIP_INSTALL = YES;
@@ -3508,7 +3508,7 @@
35083508
"@executable_path/Frameworks",
35093509
"@loader_path/Frameworks",
35103510
);
3511-
MARKETING_VERSION = 3.1.0;
3511+
MARKETING_VERSION = 3.1.1;
35123512
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.core;
35133513
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
35143514
SKIP_INSTALL = YES;
@@ -3582,7 +3582,7 @@
35823582
"@executable_path/Frameworks",
35833583
"@loader_path/Frameworks",
35843584
);
3585-
MARKETING_VERSION = 3.1.0;
3585+
MARKETING_VERSION = 3.1.1;
35863586
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.signal;
35873587
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
35883588
SKIP_INSTALL = YES;
@@ -3610,7 +3610,7 @@
36103610
"@executable_path/Frameworks",
36113611
"@loader_path/Frameworks",
36123612
);
3613-
MARKETING_VERSION = 3.1.0;
3613+
MARKETING_VERSION = 3.1.1;
36143614
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.signal;
36153615
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
36163616
SKIP_INSTALL = YES;
@@ -3677,7 +3677,7 @@
36773677
"@executable_path/Frameworks",
36783678
"@loader_path/Frameworks",
36793679
);
3680-
MARKETING_VERSION = 3.1.0;
3680+
MARKETING_VERSION = 3.1.1;
36813681
PRODUCT_BUNDLE_IDENTIFIER = come.adobe.aep.services;
36823682
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
36833683
SKIP_INSTALL = YES;
@@ -3704,7 +3704,7 @@
37043704
"@executable_path/Frameworks",
37053705
"@loader_path/Frameworks",
37063706
);
3707-
MARKETING_VERSION = 3.1.0;
3707+
MARKETING_VERSION = 3.1.1;
37083708
PRODUCT_BUNDLE_IDENTIFIER = come.adobe.aep.services;
37093709
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
37103710
SKIP_INSTALL = YES;
@@ -3824,7 +3824,7 @@
38243824
"@executable_path/Frameworks",
38253825
"@loader_path/Frameworks",
38263826
);
3827-
MARKETING_VERSION = 3.1.0;
3827+
MARKETING_VERSION = 3.1.1;
38283828
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPServicesMocks;
38293829
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
38303830
SKIP_INSTALL = YES;
@@ -3851,7 +3851,7 @@
38513851
"@executable_path/Frameworks",
38523852
"@loader_path/Frameworks",
38533853
);
3854-
MARKETING_VERSION = 3.1.0;
3854+
MARKETING_VERSION = 3.1.1;
38553855
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPServicesMocks;
38563856
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
38573857
SKIP_INSTALL = YES;
@@ -3877,7 +3877,7 @@
38773877
"@executable_path/Frameworks",
38783878
"@loader_path/Frameworks",
38793879
);
3880-
MARKETING_VERSION = 3.1.0;
3880+
MARKETING_VERSION = 3.1.1;
38813881
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.lifecycle;
38823882
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
38833883
SKIP_INSTALL = YES;
@@ -3904,7 +3904,7 @@
39043904
"@executable_path/Frameworks",
39053905
"@loader_path/Frameworks",
39063906
);
3907-
MARKETING_VERSION = 3.1.0;
3907+
MARKETING_VERSION = 3.1.1;
39083908
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.lifecycle;
39093909
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
39103910
SKIP_INSTALL = YES;
@@ -3973,7 +3973,7 @@
39733973
"@executable_path/Frameworks",
39743974
"@loader_path/Frameworks",
39753975
);
3976-
MARKETING_VERSION = 3.1.0;
3976+
MARKETING_VERSION = 3.1.1;
39773977
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.identity;
39783978
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
39793979
SKIP_INSTALL = YES;
@@ -4000,7 +4000,7 @@
40004000
"@executable_path/Frameworks",
40014001
"@loader_path/Frameworks",
40024002
);
4003-
MARKETING_VERSION = 3.1.0;
4003+
MARKETING_VERSION = 3.1.1;
40044004
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.identity;
40054005
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
40064006
SKIP_INSTALL = YES;
@@ -4069,7 +4069,7 @@
40694069
"@executable_path/Frameworks",
40704070
"@loader_path/Frameworks",
40714071
);
4072-
MARKETING_VERSION = 3.1.0;
4072+
MARKETING_VERSION = 3.1.1;
40734073
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPCoreMocks;
40744074
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
40754075
SKIP_INSTALL = YES;
@@ -4096,7 +4096,7 @@
40964096
"@executable_path/Frameworks",
40974097
"@loader_path/Frameworks",
40984098
);
4099-
MARKETING_VERSION = 3.1.0;
4099+
MARKETING_VERSION = 3.1.1;
41004100
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPCoreMocks;
41014101
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
41024102
SKIP_INSTALL = YES;

AEPCore/Sources/configuration/ConfigurationConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
struct ConfigurationConstants {
1616
static let EXTENSION_NAME = "com.adobe.module.configuration"
1717
static let FRIENDLY_NAME = "Configuration"
18-
static let EXTENSION_VERSION = "3.1.0"
18+
static let EXTENSION_VERSION = "3.1.1"
1919
static let DATA_STORE_NAME = EXTENSION_NAME
2020

2121
static let CONFIG_URL_BASE = "https://assets.adobedtm.com/"

AEPCore/Sources/core/CoreConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Foundation
1313

1414
enum CoreConstants {
1515
static let EXTENSION_NAME = "com.adobe.module.configuration"
16-
static let EXTENSION_VERSION = "3.1.0"
16+
static let EXTENSION_VERSION = "3.1.1"
1717
static let DATA_STORE_NAME = EXTENSION_NAME
1818

1919
static let CONFIG_URL_BASE = "https://assets.adobedtm.com/"

AEPCore/Sources/eventhub/EventHub.swift

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ final class EventHub {
2929
private var eventNumberCounter = AtomicCounter()
3030
private let eventQueue = OperationOrderer<Event>("EventHub")
3131
private var preprocessors = ThreadSafeArray<EventPreprocessor>(identifier: "com.adobe.eventHub.preprocessors.queue")
32+
private var started = false // true if the `EventHub` is started, false otherwise. Should only be accessed from within the `eventHubQueue`
3233

3334
#if DEBUG
3435
public internal(set) static var shared = EventHub()
@@ -72,6 +73,7 @@ final class EventHub {
7273
/// When this API is invoked the `EventHub` will begin processing `Event`s
7374
func start() {
7475
eventHubQueue.async {
76+
self.started = true
7577
self.eventQueue.start()
7678
self.shareEventHubSharedState() // share state of all registered extensions
7779
Log.debug(label: self.LOG_TAG, "Event Hub successfully started")
@@ -259,33 +261,36 @@ final class EventHub {
259261

260262
/// Shares a shared state for the `EventHub` with data containing all the registered extensions
261263
func shareEventHubSharedState() {
262-
var extensionsInfo = [String: [String: Any]]()
263-
for (_, val) in registeredExtensions.shallowCopy
264-
where val.sharedStateName != EventHubConstants.NAME {
265-
if let exten = val.exten {
266-
let version = type(of: exten).extensionVersion
267-
extensionsInfo[exten.name] = [EventHubConstants.EventDataKeys.VERSION: version,
268-
EventHubConstants.EventDataKeys.FRIENDLY_NAME: exten.friendlyName]
269-
if let metadata = exten.metadata, !metadata.isEmpty {
264+
eventHubQueue.async {
265+
guard self.started else { return } // only publish shared state if `EventHub` is started
266+
var extensionsInfo = [String: [String: Any]]()
267+
for (_, val) in self.registeredExtensions.shallowCopy
268+
where val.sharedStateName != EventHubConstants.NAME {
269+
if let exten = val.exten {
270+
let version = type(of: exten).extensionVersion
270271
extensionsInfo[exten.name] = [EventHubConstants.EventDataKeys.VERSION: version,
271-
EventHubConstants.EventDataKeys.METADATA: metadata,
272272
EventHubConstants.EventDataKeys.FRIENDLY_NAME: exten.friendlyName]
273+
if let metadata = exten.metadata, !metadata.isEmpty {
274+
extensionsInfo[exten.name] = [EventHubConstants.EventDataKeys.VERSION: version,
275+
EventHubConstants.EventDataKeys.METADATA: metadata,
276+
EventHubConstants.EventDataKeys.FRIENDLY_NAME: exten.friendlyName]
277+
}
273278
}
274279
}
275-
}
276280

277-
let data: [String: Any] = [EventHubConstants.EventDataKeys.VERSION: EventHubConstants.VERSION_NUMBER,
278-
EventHubConstants.EventDataKeys.EXTENSIONS: extensionsInfo]
281+
let data: [String: Any] = [EventHubConstants.EventDataKeys.VERSION: EventHubConstants.VERSION_NUMBER,
282+
EventHubConstants.EventDataKeys.EXTENSIONS: extensionsInfo]
279283

280-
guard let sharedState = registeredExtensions.first(where: { $1.sharedStateName.caseInsensitiveCompare(EventHubConstants.NAME) == .orderedSame })?.value.sharedState else {
281-
Log.warning(label: LOG_TAG, "Extension not registered with EventHub")
282-
return
283-
}
284+
guard let sharedState = self.registeredExtensions.first(where: { $1.sharedStateName.caseInsensitiveCompare(EventHubConstants.NAME) == .orderedSame })?.value.sharedState else {
285+
Log.warning(label: self.LOG_TAG, "Extension not registered with EventHub")
286+
return
287+
}
284288

285-
let version = sharedState.resolve(version: 0).value == nil ? 0 : eventNumberCounter.incrementAndGet()
286-
sharedState.set(version: version, data: data)
287-
dispatch(event: createSharedStateEvent(extensionName: EventHubConstants.NAME, sharedStatetype: .standard))
288-
Log.debug(label: LOG_TAG, "Shared state created for \(EventHubConstants.NAME) with version \(version) and data: \n\(PrettyDictionary.prettify(data))")
289+
let version = sharedState.resolve(version: 0).value == nil ? 0 : self.eventNumberCounter.incrementAndGet()
290+
sharedState.set(version: version, data: data)
291+
self.dispatch(event: self.createSharedStateEvent(extensionName: EventHubConstants.NAME, sharedStatetype: .standard))
292+
Log.debug(label: self.LOG_TAG, "Shared state created for \(EventHubConstants.NAME) with version \(version) and data: \n\(PrettyDictionary.prettify(data))")
293+
}
289294
}
290295

291296
// MARK: - Private

AEPCore/Sources/eventhub/EventHubConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum EventHubConstants {
1717
static let XDM_STATE_CHANGE = "Shared state change (XDM)"
1818
static let NAME = "com.adobe.module.eventhub"
1919
static let FRIENDLY_NAME = "EventHub"
20-
static let VERSION_NUMBER = "3.1.0"
20+
static let VERSION_NUMBER = "3.1.1"
2121

2222
enum EventDataKeys {
2323
static let VERSION = "version"

AEPCore/Sources/eventhub/EventHubPlaceholderExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Foundation
1414

1515
/// An `Extension` for `EventHub`. This serves no purpose other than to allow `EventHub` to share state.
16-
class EventHubPlaceholderExtension: Extension {
16+
class EventHubPlaceholderExtension: NSObject, Extension {
1717
let name = EventHubConstants.NAME
1818
let friendlyName = EventHubConstants.FRIENDLY_NAME
1919
static let extensionVersion = EventHubConstants.VERSION_NUMBER

AEPCore/Sources/eventhub/Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
// MARK: - Extension protocol
1616
/// An object which can be registered with the `EventHub`
1717
@objc(AEPExtension)
18-
public protocol Extension {
18+
public protocol Extension where Self: NSObject {
1919
/// Name of the extension
2020
var name: String { get }
2121

AEPCore/Tests/EventHubTests/EventHubTests.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,40 @@ class EventHubTests: XCTestCase {
608608
XCTAssertEqual(mockExtensionTwo.metadata, mockDetailsTwo?[EventHubConstants.EventDataKeys.METADATA] as? [String: String])
609609
}
610610

611+
func testEventHubShareEventHubStateBeforeStart() {
612+
// setup
613+
let sharedStateExpectation = XCTestExpectation(description: "Shared state should NOT be shared by event hub")
614+
sharedStateExpectation.isInverted = true // shared state should not be published by event hub before start
615+
616+
eventHub.getExtensionContainer(MockExtension.self)?.registerListener(type: EventType.hub, source: EventSource.sharedState) { event in
617+
if event.data?[EventHubConstants.EventDataKeys.Configuration.EVENT_STATE_OWNER] as? String == EventHubConstants.NAME { sharedStateExpectation.fulfill() }
618+
}
619+
620+
// test
621+
eventHub.shareEventHubSharedState()
622+
623+
// verify
624+
wait(for: [sharedStateExpectation], timeout: 1)
625+
}
626+
627+
func testEventHubShareEventHubStateAfterStart() {
628+
// setup
629+
let sharedStateExpectation = XCTestExpectation(description: "Shared state should be shared by event hub")
630+
sharedStateExpectation.assertForOverFulfill = true
631+
sharedStateExpectation.expectedFulfillmentCount = 2 // one from the start call and one from shareEventHubSharedState
632+
633+
eventHub.getExtensionContainer(MockExtension.self)?.registerListener(type: EventType.hub, source: EventSource.sharedState) { event in
634+
if event.data?[EventHubConstants.EventDataKeys.Configuration.EVENT_STATE_OWNER] as? String == EventHubConstants.NAME { sharedStateExpectation.fulfill() }
635+
}
636+
637+
// test
638+
eventHub.start()
639+
eventHub.shareEventHubSharedState()
640+
641+
// verify
642+
wait(for: [sharedStateExpectation], timeout: 1)
643+
}
644+
611645
func testEventHubRegisterAndUnregisterExtensionSharesState() {
612646
// setup
613647
let sharedStateExpectation = XCTestExpectation(description: "Shared state should be shared by event hub once")

AEPCore/Tests/MobileCoreTests.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class MobileCoreTests: XCTestCase {
207207
"friendlyName" : "mockExtension"
208208
},
209209
"com.adobe.module.configuration" : {
210-
"version" : "3.1.0",
210+
"version" : "3.1.1",
211211
"friendlyName" : "Configuration"
212212
},
213213
"com.adobe.mockExtensionTwo" : {
@@ -223,15 +223,20 @@ class MobileCoreTests: XCTestCase {
223223

224224
// test
225225
MobileCore.registerExtensions([MockExtension.self, MockExtensionTwo.self], {
226-
let registered = MobileCore.getRegisteredExtensions()
227-
let registeredDict = self.jsonStrToDict(jsonStr: registered)?["extensions"] as? Dictionary<String, Any>
228-
let equal = NSDictionary(dictionary: registeredDict!).isEqual(to: expectedDict!)
229-
XCTAssertTrue(equal)
230-
expectation.fulfill()
226+
EventHub.shared.getExtensionContainer(MockExtension.self)?.registerListener(type: EventType.hub, source: EventSource.sharedState) { event in
227+
if event.data?[EventHubConstants.EventDataKeys.Configuration.EVENT_STATE_OWNER] as? String == EventHubConstants.NAME {
228+
let registered = MobileCore.getRegisteredExtensions()
229+
let registeredDict = self.jsonStrToDict(jsonStr: registered)?["extensions"] as? Dictionary<String, Any>
230+
let equal = NSDictionary(dictionary: registeredDict!).isEqual(to: expectedDict!)
231+
XCTAssertTrue(equal)
232+
expectation.fulfill()
233+
234+
}
235+
}
231236
})
232237

233238
// verify
234-
wait(for: [expectation], timeout: 0.25)
239+
wait(for: [expectation], timeout: 1)
235240
}
236241

237242
private func jsonStrToDict(jsonStr: String) -> [String: Any]? {

0 commit comments

Comments
 (0)