Skip to content

Commit 28acf74

Browse files
authored
[HEAP-44118] Expose SourceInfo to Objective-C in Interfaces (#113)
1 parent fcf4c9e commit 28acf74

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

HeapSwiftCoreInterfaces.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'HeapSwiftCoreInterfaces'
3-
s.version = '0.1.2'
3+
s.version = '0.3.0'
44
s.license = { :type => 'MIT' }
55
s.summary = 'ABI stable interface package for HeapSwiftCore.'
66
s.homepage = 'https://heap.io'

HeapSwiftCoreInterfaces/HeapSwiftCoreInterfaces.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
EB79BE652A144E0600F9EEBD /* HeapProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB79BE5C2A144E0600F9EEBD /* HeapProtocol.swift */; };
1818
EB79BE662A144E0600F9EEBD /* RuntimeBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB79BE5D2A144E0600F9EEBD /* RuntimeBridge.swift */; };
1919
EB79BE672A144E0600F9EEBD /* Interaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB79BE5E2A144E0600F9EEBD /* Interaction.swift */; };
20+
EBF245AB2A327A9600C8296D /* HeapObjcPropertyValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBF245AA2A327A9600C8296D /* HeapObjcPropertyValue.swift */; };
2021
/* End PBXBuildFile section */
2122

2223
/* Begin PBXFileReference section */
@@ -32,6 +33,7 @@
3233
EB79BE5D2A144E0600F9EEBD /* RuntimeBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RuntimeBridge.swift; sourceTree = "<group>"; };
3334
EB79BE5E2A144E0600F9EEBD /* Interaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interaction.swift; sourceTree = "<group>"; };
3435
EB79BE682A14508300F9EEBD /* HeapSwiftCoreInterfaces.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = HeapSwiftCoreInterfaces.modulemap; sourceTree = "<group>"; };
36+
EBF245AA2A327A9600C8296D /* HeapObjcPropertyValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeapObjcPropertyValue.swift; sourceTree = "<group>"; };
3537
/* End PBXFileReference section */
3638

3739
/* Begin PBXFrameworksBuildPhase section */
@@ -68,6 +70,7 @@
6870
EB79BE4F2A144A4000F9EEBD /* HeapSwiftCoreInterfaces.h */,
6971
EB79BE562A144E0600F9EEBD /* HeapLogger.swift */,
7072
EB79BE5A2A144E0600F9EEBD /* HeapPropertyValue.swift */,
73+
EBF245AA2A327A9600C8296D /* HeapObjcPropertyValue.swift */,
7174
EB79BE5C2A144E0600F9EEBD /* HeapProtocol.swift */,
7275
EB79BE5E2A144E0600F9EEBD /* Interaction.swift */,
7376
EB79BE582A144E0600F9EEBD /* Option.swift */,
@@ -187,6 +190,7 @@
187190
EB79BE642A144E0600F9EEBD /* Source.swift in Sources */,
188191
EB79BE612A144E0600F9EEBD /* Option.swift in Sources */,
189192
EB79BE602A144E0600F9EEBD /* Pageview.swift in Sources */,
193+
EBF245AB2A327A9600C8296D /* HeapObjcPropertyValue.swift in Sources */,
190194
EB79BE672A144E0600F9EEBD /* Interaction.swift in Sources */,
191195
EB79BE632A144E0600F9EEBD /* HeapPropertyValue.swift in Sources */,
192196
EB79BE662A144E0600F9EEBD /* RuntimeBridge.swift in Sources */,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Foundation
2+
3+
@objc
4+
public protocol HeapObjcPropertyValue: NSObjectProtocol {
5+
var heapValue: String { get }
6+
}
7+
8+
extension NSString: HeapObjcPropertyValue, HeapPropertyValue {
9+
public var heapValue: String { return self as String }
10+
}
11+
12+
extension NSNumber: HeapObjcPropertyValue, HeapPropertyValue {
13+
public var heapValue: String {
14+
if CFGetTypeID(self) == CFBooleanGetTypeID() {
15+
return self.boolValue ? "true" : "false"
16+
}
17+
return self.stringValue
18+
}
19+
}

HeapSwiftCoreInterfaces/HeapSwiftCoreInterfaces/SourceInfo.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import Foundation
33
@objc(HeapSourceInfo)
44
public class SourceInfo: NSObject {
55

6+
@objc
67
public let name: String
8+
9+
@objc
710
public let version: String
11+
12+
@objc
813
public let platform: String
14+
915
public let properties: [String: HeapPropertyValue]
10-
16+
1117
public init(name: String, version: String, platform: String, properties: [String: HeapPropertyValue] = [:]) {
1218
self.name = name
1319
self.version = version
@@ -16,4 +22,20 @@ public class SourceInfo: NSObject {
1622
}
1723
}
1824

19-
25+
extension SourceInfo {
26+
27+
@objc(sourceInfoWithName:version:platform:properties:)
28+
public static func __sourceInfo(name: String, version: String, platform: String, properties: [String: HeapObjcPropertyValue]) -> SourceInfo {
29+
.init(name: name, version: version, platform: platform, properties: properties.mapValues(\.heapValue))
30+
}
31+
32+
@objc(sourceInfoWithName:version:platform:)
33+
public static func __sourceInfo(name: String, version: String, platform: String) -> SourceInfo {
34+
.init(name: name, version: version, platform: platform)
35+
}
36+
37+
@objc(properties)
38+
public var __objcProperties: [String: String] {
39+
properties.mapValues(\.heapValue)
40+
}
41+
}

0 commit comments

Comments
 (0)