Skip to content

Commit

Permalink
Merge pull request #339 from Countly/fix-ios-sdk
Browse files Browse the repository at this point in the history
Added iOS sdk missing changes
  • Loading branch information
turtledreams authored Apr 17, 2024
2 parents 06a5083 + c4baabc commit 5ac8bf1
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 5 deletions.
181 changes: 178 additions & 3 deletions ios/src/Countly.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions ios/src/CountlyTests/CountlyBaseTestCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// CountlyBaseTestCase.swift
// CountlyTests
//
// Created by Muhammad Junaid Akram on 27/12/2023.
// Copyright © 2023 Alin Radut. All rights reserved.
//

import XCTest
@testable import Countly

class CountlyBaseTestCase: XCTestCase {
var countly: Countly!
var deviceID: String = ""
let appKey: String = "appkey"
var host: String = "https://test.count.ly/"

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
cleanupState()
}

func createBaseConfig() -> CountlyConfig {
let config: CountlyConfig = CountlyConfig()
config.appKey = appKey
config.host = host
config.enableDebug = true
config.features = [CLYFeature.crashReporting];
return config
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func cleanupState() {
Countly.sharedInstance().halt(true)
}

}


1 change: 1 addition & 0 deletions ios/src/CountlyTests/CountlyTests-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import "CountlyCommon.h"
67 changes: 67 additions & 0 deletions ios/src/CountlyTests/CountlyTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// CountlyTests.swift
// CountlyTests
//
// Created by Muhammad Junaid Akram on 22/12/2023.
// Copyright © 2023 Alin Radut. All rights reserved.
//

import XCTest
@testable import Countly


class CountlyTests: CountlyBaseTestCase {

// MARK: - Configuration Tests

func testReInitWithDeviceId() throws {
let config = createBaseConfig()
// No Device ID provided during init
Countly.sharedInstance().start(with: config);

let sdkGeneratedDeviceID = Countly.sharedInstance().deviceID()
XCTAssertTrue(CountlyCommon.sharedInstance().hasStarted, "Countly initialization failed.")
XCTAssertTrue(Countly.sharedInstance().deviceIDType() == CLYDeviceIDType.IDFV, "Countly deviced id type should be IDFV when no device id is provided during init.")
Countly.sharedInstance().halt(false)
XCTAssertTrue(!CountlyCommon.sharedInstance().hasStarted, "Countly halt failed.")

let deviceID = String(Int.random(in: 0..<100))

let newConfig = createBaseConfig()
newConfig.deviceID = deviceID
Countly.sharedInstance().start(with: newConfig);

XCTAssertTrue(CountlyCommon.sharedInstance().hasStarted, "Countly initialization failed.")
XCTAssertTrue(Countly.sharedInstance().deviceID() == sdkGeneratedDeviceID, "Countly device id not match with provided device id.")
XCTAssertTrue(Countly.sharedInstance().deviceIDType() == CLYDeviceIDType.IDFV, "Countly deviced id type should be custom when device id is provided during init.")
}

func testPerformanceExample() async throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
}
}


func checkPersistentValues() {
let countlyPersistency = CountlyPersistency.sharedInstance()
if(countlyPersistency != nil) {
if let queuedRequests = CountlyPersistency.sharedInstance().value(forKey: "queuedRequests") as? NSMutableArray,
let recordedEvents = CountlyPersistency.sharedInstance().value(forKey: "recordedEvents") as? NSMutableArray,
let startedEvents = CountlyPersistency.sharedInstance().value(forKey: "startedEvents") as? NSMutableDictionary,
let isQueueBeingModified = CountlyPersistency.sharedInstance().value(forKey: "isQueueBeingModified") as? Bool {
print("Successfully access private properties.")


}
else {
print("Failed to access private properties.")
}
}

}
}



9 changes: 7 additions & 2 deletions ios/src/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ let package = Package(
"Info.plist",
"Countly.podspec",
"Countly-PL.podspec",
"LICENSE.md",
"LICENSE",
"README.md",
"countly_dsym_uploader.sh",
"CHANGELOG.md",
"SECURITY.md"
"SECURITY.md",
"CountlyTests/"
],

linkerSettings:
Expand All @@ -53,5 +54,9 @@ let package = Package(
.linkedFramework("WebKit", .when(platforms: [.iOS])),
.linkedFramework("CoreTelephony", .when(platforms: [.iOS])),
]),
.testTarget(
name: "CountlyTests",
dependencies: ["Countly"]
),
]
)
1 change: 0 additions & 1 deletion ios/src/include/CountlySDKLimitsConfig.h

This file was deleted.

1 change: 1 addition & 0 deletions ios/src/include/CountlySDKLimitsConfig.h
1 change: 0 additions & 1 deletion ios/src/include/Resettable.h

This file was deleted.

1 change: 1 addition & 0 deletions ios/src/include/Resettable.h

0 comments on commit 5ac8bf1

Please sign in to comment.