From 37058c92d2bf3505b2fb21e81189c34e87af7662 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 24 Oct 2023 13:40:26 +0200 Subject: [PATCH 1/6] Swift PM fixes and Swift only --- PostHog.xcodeproj/project.pbxproj | 45 ++- PostHog/PostHog.h | 3 - PostHog/PostHogApi.swift | 9 +- PostHog/Utils/Data+Gzip.swift | 323 +++++++++++++++ PostHog/Utils/NSData+PHGGZIP.h | 44 -- PostHog/Utils/NSData+PHGGZIP.m | 107 ----- PostHogExampleWithSPM/.gitignore | 8 + .../project.pbxproj | 377 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcschemes/PostHogExampleWithSPM.xcscheme | 77 ++++ .../PostHogExampleWithSPM/AppDelegate.swift | 34 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../Assets.xcassets/Contents.json | 6 + .../PostHogExampleWithSPM/ContentView.swift | 24 ++ .../PostHogExampleWithSPMApp.swift | 19 + .../Preview Assets.xcassets/Contents.json | 6 + 18 files changed, 957 insertions(+), 164 deletions(-) create mode 100644 PostHog/Utils/Data+Gzip.swift delete mode 100644 PostHog/Utils/NSData+PHGGZIP.h delete mode 100644 PostHog/Utils/NSData+PHGGZIP.m create mode 100644 PostHogExampleWithSPM/.gitignore create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.pbxproj create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/xcshareddata/xcschemes/PostHogExampleWithSPM.xcscheme create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/AppDelegate.swift create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/Contents.json create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/ContentView.swift create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/PostHogExampleWithSPMApp.swift create mode 100644 PostHogExampleWithSPM/PostHogExampleWithSPM/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/PostHog.xcodeproj/project.pbxproj b/PostHog.xcodeproj/project.pbxproj index 117c689c46..5784240c74 100644 --- a/PostHog.xcodeproj/project.pbxproj +++ b/PostHog.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 3A0F108929C9BD76002C0084 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A0F108829C9BD76002C0084 /* Errors.swift */; }; 3A2BCF4C299E4E35008BB5F3 /* QueueTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2BCF4B299E4E35008BB5F3 /* QueueTest.swift */; }; 3A2BCF52299F7724008BB5F3 /* CodableUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2BCF51299F7724008BB5F3 /* CodableUtils.swift */; }; - 3A4F510D299A78E100B68D5E /* NSData+PHGGZIP.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AE3FB3829924CE100AFFC18 /* NSData+PHGGZIP.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A580B3F29E481F200C5C6F3 /* OHHTTPStubs in Frameworks */ = {isa = PBXBuildFile; productRef = 3A580B3E29E481F200C5C6F3 /* OHHTTPStubs */; }; 3A580B4129E481F200C5C6F3 /* OHHTTPStubsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 3A580B4029E481F200C5C6F3 /* OHHTTPStubsSwift */; }; 3A580B4329E489D000C5C6F3 /* URLSession+body.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A580B4229E489D000C5C6F3 /* URLSession+body.swift */; }; @@ -38,7 +37,6 @@ 3AE3FB2C2991320300AFFC18 /* Api.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB2B2991320300AFFC18 /* Api.swift */; }; 3AE3FB332991388500AFFC18 /* PostHogQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB322991388500AFFC18 /* PostHogQueue.swift */; }; 3AE3FB37299162EA00AFFC18 /* PostHogApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB36299162EA00AFFC18 /* PostHogApi.swift */; }; - 3AE3FB3B29924CE100AFFC18 /* NSData+PHGGZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB3929924CE100AFFC18 /* NSData+PHGGZIP.m */; }; 3AE3FB3D29924E8200AFFC18 /* PostHogSDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB3C29924E8200AFFC18 /* PostHogSDK.swift */; }; 3AE3FB3F29924F4F00AFFC18 /* PostHogConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB3E29924F4F00AFFC18 /* PostHogConfig.swift */; }; 3AE3FB432992985A00AFFC18 /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB422992985A00AFFC18 /* Reachability.swift */; }; @@ -46,6 +44,7 @@ 3AE3FB49299391DF00AFFC18 /* PostHogStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB48299391DF00AFFC18 /* PostHogStorage.swift */; }; 3AE3FB4B2993A68500AFFC18 /* StorageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB4A2993A68500AFFC18 /* StorageTest.swift */; }; 3AE3FB4E2993D1D600AFFC18 /* PostHogSessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB4D2993D1D600AFFC18 /* PostHogSessionManager.swift */; }; + 690FF05F2AE7E2D400A0B06B /* Data+Gzip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690FF05E2AE7E2D400A0B06B /* Data+Gzip.swift */; }; 69261D132AD5685B00232EC7 /* PostHogFeatureFlags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69261D122AD5685B00232EC7 /* PostHogFeatureFlags.swift */; }; 69261D192AD9673500232EC7 /* PostHogBatchUploadInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69261D182AD9673500232EC7 /* PostHogBatchUploadInfo.swift */; }; 69261D1B2AD9678C00232EC7 /* PostHogEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69261D1A2AD9678C00232EC7 /* PostHogEvent.swift */; }; @@ -79,6 +78,13 @@ remoteGlobalIDString = 3AC745B4296D6FE60025C109; remoteInfo = PostHog; }; + 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 690FF0422AE7DB3600A0B06B; + remoteInfo = PostHogExampleWithSPM; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -124,8 +130,6 @@ 3AE3FB2B2991320300AFFC18 /* Api.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Api.swift; sourceTree = ""; }; 3AE3FB322991388500AFFC18 /* PostHogQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogQueue.swift; sourceTree = ""; }; 3AE3FB36299162EA00AFFC18 /* PostHogApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogApi.swift; sourceTree = ""; }; - 3AE3FB3829924CE100AFFC18 /* NSData+PHGGZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+PHGGZIP.h"; sourceTree = ""; }; - 3AE3FB3929924CE100AFFC18 /* NSData+PHGGZIP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+PHGGZIP.m"; sourceTree = ""; }; 3AE3FB3C29924E8200AFFC18 /* PostHogSDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogSDK.swift; sourceTree = ""; }; 3AE3FB3E29924F4F00AFFC18 /* PostHogConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogConfig.swift; sourceTree = ""; }; 3AE3FB422992985A00AFFC18 /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = ""; }; @@ -133,6 +137,8 @@ 3AE3FB48299391DF00AFFC18 /* PostHogStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogStorage.swift; sourceTree = ""; }; 3AE3FB4A2993A68500AFFC18 /* StorageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageTest.swift; sourceTree = ""; }; 3AE3FB4D2993D1D600AFFC18 /* PostHogSessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogSessionManager.swift; sourceTree = ""; }; + 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PostHogExampleWithSPM.xcodeproj; path = PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj; sourceTree = ""; }; + 690FF05E2AE7E2D400A0B06B /* Data+Gzip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Gzip.swift"; sourceTree = ""; }; 69261D122AD5685B00232EC7 /* PostHogFeatureFlags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogFeatureFlags.swift; sourceTree = ""; }; 69261D182AD9673500232EC7 /* PostHogBatchUploadInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogBatchUploadInfo.swift; sourceTree = ""; }; 69261D1A2AD9678C00232EC7 /* PostHogEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogEvent.swift; sourceTree = ""; }; @@ -222,13 +228,12 @@ 3AA4C09B2988315D006C4731 /* Utils */ = { isa = PBXGroup; children = ( - 3AE3FB3829924CE100AFFC18 /* NSData+PHGGZIP.h */, - 3AE3FB3929924CE100AFFC18 /* NSData+PHGGZIP.m */, 3AE3FB422992985A00AFFC18 /* Reachability.swift */, 3AE3FB462992AB0000AFFC18 /* Hedgelog.swift */, 3A2BCF51299F7724008BB5F3 /* CodableUtils.swift */, 3A0F108429C9ABB6002C0084 /* ReadWriteLock.swift */, 3A0F108829C9BD76002C0084 /* Errors.swift */, + 690FF05E2AE7E2D400A0B06B /* Data+Gzip.swift */, ); path = Utils; sourceTree = ""; @@ -236,6 +241,7 @@ 3AC745AB296D6FE60025C109 = { isa = PBXGroup; children = ( + 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */, 3AAFB13129C0C699004F485B /* Package.swift */, 3AC745B7296D6FE60025C109 /* PostHog */, 3AC745C3296D6FE60025C109 /* PostHogTests */, @@ -293,6 +299,14 @@ path = PostHogTests; sourceTree = ""; }; + 690FF0542AE7DB3700A0B06B /* Products */ = { + isa = PBXGroup; + children = ( + 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */, + ); + name = Products; + sourceTree = ""; + }; 69261D152AD92D6C00232EC7 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -316,7 +330,6 @@ buildActionMask = 2147483647; files = ( 3AC745C6296D6FE60025C109 /* PostHog.h in Headers */, - 3A4F510D299A78E100B68D5E /* NSData+PHGGZIP.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -428,6 +441,12 @@ ); productRefGroup = 3AC745B6296D6FE60025C109 /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 690FF0542AE7DB3700A0B06B /* Products */; + ProjectRef = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 3AC745B4296D6FE60025C109 /* PostHog */, @@ -437,6 +456,16 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */ = { + isa = PBXReferenceProxy; + fileType = wrapper.application; + path = PostHogExampleWithSPM.app; + remoteRef = 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 3AA34CF5296D951A003398F4 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -481,6 +510,7 @@ buildActionMask = 2147483647; files = ( 3A2BCF52299F7724008BB5F3 /* CodableUtils.swift in Sources */, + 690FF05F2AE7E2D400A0B06B /* Data+Gzip.swift in Sources */, 69261D1F2AD9681300232EC7 /* PostHogConsumerPayload.swift in Sources */, 69261D252AD9787A00232EC7 /* PostHogExtensions.swift in Sources */, 3AE3FB4E2993D1D600AFFC18 /* PostHogSessionManager.swift in Sources */, @@ -495,7 +525,6 @@ 3AE3FB3D29924E8200AFFC18 /* PostHogSDK.swift in Sources */, 3AE3FB3F29924F4F00AFFC18 /* PostHogConfig.swift in Sources */, 3AE3FB332991388500AFFC18 /* PostHogQueue.swift in Sources */, - 3AE3FB3B29924CE100AFFC18 /* NSData+PHGGZIP.m in Sources */, 69261D1B2AD9678C00232EC7 /* PostHogEvent.swift in Sources */, 3AE3FB472992AB0000AFFC18 /* Hedgelog.swift in Sources */, 69261D132AD5685B00232EC7 /* PostHogFeatureFlags.swift in Sources */, diff --git a/PostHog/PostHog.h b/PostHog/PostHog.h index 902bb76a17..c7a8d3e6f2 100644 --- a/PostHog/PostHog.h +++ b/PostHog/PostHog.h @@ -7,9 +7,6 @@ #import -// do not use <> -// 'NSData+PHGGZIP.h' file not found with include; use "quotes" instead -#import "NSData+PHGGZIP.h" //! Project version number for PostHog. FOUNDATION_EXPORT double PostHogVersionNumber; diff --git a/PostHog/PostHogApi.swift b/PostHog/PostHogApi.swift index 6e5ee5c0f0..c4fcdded18 100644 --- a/PostHog/PostHogApi.swift +++ b/PostHog/PostHogApi.swift @@ -53,9 +53,14 @@ class PostHogApi { return completion(PostHogBatchUploadInfo(statusCode: nil, error: error)) } - let gzippedPayload = NSData(data: data!).posthog_gzipped() + var gzippedPayload: Data? + do { + gzippedPayload = try data!.gzipped() + } catch { + return completion(PostHogBatchUploadInfo(statusCode: nil, error: error)) + } - URLSession(configuration: config).uploadTask(with: request, from: gzippedPayload) { data, response, error in + URLSession(configuration: config).uploadTask(with: request, from: gzippedPayload!) { data, response, error in if error != nil { return completion(PostHogBatchUploadInfo(statusCode: nil, error: error)) } diff --git a/PostHog/Utils/Data+Gzip.swift b/PostHog/Utils/Data+Gzip.swift new file mode 100644 index 0000000000..38cf932e23 --- /dev/null +++ b/PostHog/Utils/Data+Gzip.swift @@ -0,0 +1,323 @@ +// +// Data+Gzip.swift +// +// https://github.com/1024jp/GzipSwift/blob/731037f6cc2be2ec01562f6597c1d0aa3fe6fd05/Sources/Gzip/Data%2BGzip.swift + +/* + The MIT License (MIT) + + © 2014-2023 1024jp + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import struct Foundation.Data + +#if os(Linux) + import zlibLinux +#else + import zlib +#endif + +public enum Gzip { + + /// Maximum value for windowBits (`MAX_WBITS`) + public static let maxWindowBits = MAX_WBITS +} + + +/// Compression level whose rawValue is based on the zlib's constants. +public struct CompressionLevel: RawRepresentable, Sendable { + + /// Compression level in the range of `0` (no compression) to `9` (maximum compression). + public let rawValue: Int32 + + public static let noCompression = Self(Z_NO_COMPRESSION) + public static let bestSpeed = Self(Z_BEST_SPEED) + public static let bestCompression = Self(Z_BEST_COMPRESSION) + + public static let defaultCompression = Self(Z_DEFAULT_COMPRESSION) + + + public init(rawValue: Int32) { + + self.rawValue = rawValue + } + + + public init(_ rawValue: Int32) { + + self.rawValue = rawValue + } +} + + +/// Errors on gzipping/gunzipping based on the zlib error codes. +public struct GzipError: Swift.Error, Sendable { + // cf. http://www.zlib.net/manual.html + + public enum Kind: Equatable, Sendable { + /// The stream structure was inconsistent. + /// + /// - underlying zlib error: `Z_STREAM_ERROR` (-2) + case stream + + /// The input data was corrupted + /// (input stream not conforming to the zlib format or incorrect check value). + /// + /// - underlying zlib error: `Z_DATA_ERROR` (-3) + case data + + /// There was not enough memory. + /// + /// - underlying zlib error: `Z_MEM_ERROR` (-4) + case memory + + /// No progress is possible or there was not enough room in the output buffer. + /// + /// - underlying zlib error: `Z_BUF_ERROR` (-5) + case buffer + + /// The zlib library version is incompatible with the version assumed by the caller. + /// + /// - underlying zlib error: `Z_VERSION_ERROR` (-6) + case version + + /// An unknown error occurred. + /// + /// - parameter code: return error by zlib + case unknown(code: Int) + } + + /// Error kind. + public let kind: Kind + + /// Returned message by zlib. + public let message: String + + + internal init(code: Int32, msg: UnsafePointer?) { + + self.message = msg.flatMap(String.init(validatingUTF8:)) ?? "Unknown gzip error" + self.kind = Kind(code: code) + } + + + public var localizedDescription: String { + + return self.message + } +} + + +private extension GzipError.Kind { + + init(code: Int32) { + + switch code { + case Z_STREAM_ERROR: + self = .stream + case Z_DATA_ERROR: + self = .data + case Z_MEM_ERROR: + self = .memory + case Z_BUF_ERROR: + self = .buffer + case Z_VERSION_ERROR: + self = .version + default: + self = .unknown(code: Int(code)) + } + } +} + + +extension Data { + + /// Whether the receiver is compressed in gzip format. + public var isGzipped: Bool { + + return self.starts(with: [0x1f, 0x8b]) // check magic number + } + + + /// Create a new `Data` instance by compressing the receiver using zlib. + /// Throws an error if compression failed. + /// + /// The `wBits` parameter allows for managing the size of the history buffer. The possible values are: + /// + /// Value Window size logarithm Input + /// +9 to +15 Base 2 Includes zlib header and trailer + /// -9 to -15 Absolute value of wbits No header and trailer + /// +25 to +31 Low 4 bits of the value Includes gzip header and trailing checksum + /// + /// - Parameter level: Compression level. + /// - Parameter wBits: Manage the size of the history buffer. + /// - Returns: Gzip-compressed `Data` instance. + /// - Throws: `GzipError` + public func gzipped(level: CompressionLevel = .defaultCompression, wBits: Int32 = Gzip.maxWindowBits + 16) throws -> Data { + + guard !self.isEmpty else { + return Data() + } + + var stream = z_stream() + var status: Int32 + + status = deflateInit2_(&stream, level.rawValue, Z_DEFLATED, wBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY, ZLIB_VERSION, Int32(DataSize.stream)) + + guard status == Z_OK else { + // deflateInit2 returns: + // Z_VERSION_ERROR The zlib library version is incompatible with the version assumed by the caller. + // Z_MEM_ERROR There was not enough memory. + // Z_STREAM_ERROR A parameter is invalid. + + throw GzipError(code: status, msg: stream.msg) + } + + var data = Data(capacity: DataSize.chunk) + repeat { + if Int(stream.total_out) >= data.count { + data.count += DataSize.chunk + } + + let inputCount = self.count + let outputCount = data.count + + self.withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in + stream.next_in = UnsafeMutablePointer(mutating: inputPointer.bindMemory(to: Bytef.self).baseAddress!).advanced(by: Int(stream.total_in)) + stream.avail_in = uInt(inputCount) - uInt(stream.total_in) + + data.withUnsafeMutableBytes { (outputPointer: UnsafeMutableRawBufferPointer) in + stream.next_out = outputPointer.bindMemory(to: Bytef.self).baseAddress!.advanced(by: Int(stream.total_out)) + stream.avail_out = uInt(outputCount) - uInt(stream.total_out) + + status = deflate(&stream, Z_FINISH) + + stream.next_out = nil + } + + stream.next_in = nil + } + + } while stream.avail_out == 0 && status != Z_STREAM_END + + guard deflateEnd(&stream) == Z_OK, status == Z_STREAM_END else { + throw GzipError(code: status, msg: stream.msg) + } + + data.count = Int(stream.total_out) + + return data + } + + + /// Create a new `Data` instance by decompressing the receiver using zlib. + /// Throws an error if decompression failed. + /// + /// The `wBits` parameter allows for managing the size of the history buffer. The possible values are: + /// + /// Value Window size logarithm Input + /// +8 to +15 Base 2 Includes zlib header and trailer + /// -8 to -15 Absolute value of wbits Raw stream with no header and trailer + /// +24 to +31 = 16 + (8 to 15) Low 4 bits of the value Includes gzip header and trailer + /// +40 to +47 = 32 + (8 to 15) Low 4 bits of the value zlib or gzip format + /// + /// - Parameter wBits: Manage the size of the history buffer. + /// - Returns: Gzip-decompressed `Data` instance. + /// - Throws: `GzipError` + public func gunzipped(wBits: Int32 = Gzip.maxWindowBits + 32) throws -> Data { + + guard !self.isEmpty else { + return Data() + } + + var data = Data(capacity: self.count * 2) + var totalIn: uLong = 0 + var totalOut: uLong = 0 + + repeat { + var stream = z_stream() + var status: Int32 + + status = inflateInit2_(&stream, wBits, ZLIB_VERSION, Int32(DataSize.stream)) + + guard status == Z_OK else { + // inflateInit2 returns: + // Z_VERSION_ERROR The zlib library version is incompatible with the version assumed by the caller. + // Z_MEM_ERROR There was not enough memory. + // Z_STREAM_ERROR A parameters are invalid. + + throw GzipError(code: status, msg: stream.msg) + } + + repeat { + if Int(totalOut + stream.total_out) >= data.count { + data.count += self.count / 2 + } + + let inputCount = self.count + let outputCount = data.count + + self.withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in + let inputStartPosition = totalIn + stream.total_in + stream.next_in = UnsafeMutablePointer(mutating: inputPointer.bindMemory(to: Bytef.self).baseAddress!).advanced(by: Int(inputStartPosition)) + stream.avail_in = uInt(inputCount) - uInt(inputStartPosition) + + data.withUnsafeMutableBytes { (outputPointer: UnsafeMutableRawBufferPointer) in + let outputStartPosition = totalOut + stream.total_out + stream.next_out = outputPointer.bindMemory(to: Bytef.self).baseAddress!.advanced(by: Int(outputStartPosition)) + stream.avail_out = uInt(outputCount) - uInt(outputStartPosition) + + status = inflate(&stream, Z_SYNC_FLUSH) + + stream.next_out = nil + } + + stream.next_in = nil + } + } while (status == Z_OK) + + totalIn += stream.total_in + + guard inflateEnd(&stream) == Z_OK, status == Z_STREAM_END else { + // inflate returns: + // Z_DATA_ERROR The input data was corrupted (input stream not conforming to the zlib format or incorrect check value). + // Z_STREAM_ERROR The stream structure was inconsistent (for example if next_in or next_out was NULL). + // Z_MEM_ERROR There was not enough memory. + // Z_BUF_ERROR No progress is possible or there was not enough room in the output buffer when Z_FINISH is used. + throw GzipError(code: status, msg: stream.msg) + } + + totalOut += stream.total_out + + } while (totalIn < self.count) + + data.count = Int(totalOut) + + return data + } +} + + +private enum DataSize { + + static let chunk = 1 << 14 + static let stream = MemoryLayout.size +} diff --git a/PostHog/Utils/NSData+PHGGZIP.h b/PostHog/Utils/NSData+PHGGZIP.h deleted file mode 100644 index 934dffa63b..0000000000 --- a/PostHog/Utils/NSData+PHGGZIP.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// GZIP.h -// -// Version 1.1.1 -// -// Created by Nick Lockwood on 03/06/2012. -// Copyright (C) 2012 Charcoal Design -// -// Distributed under the permissive zlib License -// Get the latest version from here: -// -// https://github.com/nicklockwood/GZIP -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// - - -#import - -extern void *_Nullable posthog_libzOpen(void); - - -@interface NSData (POSTHOG_GZIP) - -- (nullable NSData *)posthog_gzippedData; -- (BOOL)posthog_isGzippedData; - -@end diff --git a/PostHog/Utils/NSData+PHGGZIP.m b/PostHog/Utils/NSData+PHGGZIP.m deleted file mode 100644 index 569683a931..0000000000 --- a/PostHog/Utils/NSData+PHGGZIP.m +++ /dev/null @@ -1,107 +0,0 @@ -// -// GZIP.m -// -// Version 1.1.1 -// -// Created by Nick Lockwood on 03/06/2012. -// Copyright (C) 2012 Charcoal Design -// -// Distributed under the permissive zlib License -// Get the latest version from here: -// -// https://github.com/nicklockwood/GZIP -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// - - -#import "NSData+PHGGZIP.h" -#import -#import - - -#pragma clang diagnostic ignored "-Wcast-qual" - -void *_Nullable posthog_libzOpen(void) -{ - static void *libz; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - libz = dlopen("/usr/lib/libz.dylib", RTLD_LAZY); - }); - return libz; -} - - -@implementation NSData (POSTHOG_GZIP) - -- (NSData *)posthog_gzippedDataWithCompressionLevel:(float)level -{ - if (self.length == 0 || [self posthog_isGzippedData]) { - return self; - } - - void *libz = posthog_libzOpen(); - int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) = - (int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_"); - int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate"); - int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd"); - - z_stream stream; - stream.zalloc = Z_NULL; - stream.zfree = Z_NULL; - stream.opaque = Z_NULL; - stream.avail_in = (uint)self.length; - stream.next_in = (Bytef *)(void *)self.bytes; - stream.total_out = 0; - stream.avail_out = 0; - - static const NSUInteger ChunkSize = 16384; - - NSMutableData *output = nil; - int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)(roundf(level * 9)); - if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) { - output = [NSMutableData dataWithLength:ChunkSize]; - while (stream.avail_out == 0) { - if (stream.total_out >= output.length) { - output.length += ChunkSize; - } - stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; - stream.avail_out = (uInt)(output.length - stream.total_out); - deflate(&stream, Z_FINISH); - } - deflateEnd(&stream); - output.length = stream.total_out; - } - - return output; -} - -- (NSData *)posthog_gzippedData -{ - return [self posthog_gzippedDataWithCompressionLevel:-1.0f]; -} - -- (BOOL)posthog_isGzippedData -{ - const UInt8 *bytes = (const UInt8 *)self.bytes; - return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b); -} - -@end diff --git a/PostHogExampleWithSPM/.gitignore b/PostHogExampleWithSPM/.gitignore new file mode 100644 index 0000000000..0023a53406 --- /dev/null +++ b/PostHogExampleWithSPM/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.pbxproj b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..4d16fe1782 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.pbxproj @@ -0,0 +1,377 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + 690FF0462AE7DB3600A0B06B /* PostHogExampleWithSPMApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690FF0452AE7DB3600A0B06B /* PostHogExampleWithSPMApp.swift */; }; + 690FF0482AE7DB3600A0B06B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690FF0472AE7DB3600A0B06B /* ContentView.swift */; }; + 690FF04A2AE7DB3700A0B06B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 690FF0492AE7DB3700A0B06B /* Assets.xcassets */; }; + 690FF04D2AE7DB3700A0B06B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 690FF04C2AE7DB3700A0B06B /* Preview Assets.xcassets */; }; + 690FF05A2AE7DD7500A0B06B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690FF0592AE7DD7500A0B06B /* AppDelegate.swift */; }; + 690FF0612AE7E41800A0B06B /* PostHog in Frameworks */ = {isa = PBXBuildFile; productRef = 690FF0602AE7E41800A0B06B /* PostHog */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 690FF0422AE7DB3600A0B06B /* PostHogExampleWithSPM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PostHogExampleWithSPM.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 690FF0452AE7DB3600A0B06B /* PostHogExampleWithSPMApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogExampleWithSPMApp.swift; sourceTree = ""; }; + 690FF0472AE7DB3600A0B06B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 690FF0492AE7DB3700A0B06B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 690FF04C2AE7DB3700A0B06B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 690FF0592AE7DD7500A0B06B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 690FF03F2AE7DB3600A0B06B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 690FF0612AE7E41800A0B06B /* PostHog in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 690FF0392AE7DB3600A0B06B = { + isa = PBXGroup; + children = ( + 690FF0442AE7DB3600A0B06B /* PostHogExampleWithSPM */, + 690FF0432AE7DB3600A0B06B /* Products */, + ); + sourceTree = ""; + }; + 690FF0432AE7DB3600A0B06B /* Products */ = { + isa = PBXGroup; + children = ( + 690FF0422AE7DB3600A0B06B /* PostHogExampleWithSPM.app */, + ); + name = Products; + sourceTree = ""; + }; + 690FF0442AE7DB3600A0B06B /* PostHogExampleWithSPM */ = { + isa = PBXGroup; + children = ( + 690FF0592AE7DD7500A0B06B /* AppDelegate.swift */, + 690FF0452AE7DB3600A0B06B /* PostHogExampleWithSPMApp.swift */, + 690FF0472AE7DB3600A0B06B /* ContentView.swift */, + 690FF0492AE7DB3700A0B06B /* Assets.xcassets */, + 690FF04B2AE7DB3700A0B06B /* Preview Content */, + ); + path = PostHogExampleWithSPM; + sourceTree = ""; + }; + 690FF04B2AE7DB3700A0B06B /* Preview Content */ = { + isa = PBXGroup; + children = ( + 690FF04C2AE7DB3700A0B06B /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 690FF0412AE7DB3600A0B06B /* PostHogExampleWithSPM */ = { + isa = PBXNativeTarget; + buildConfigurationList = 690FF0502AE7DB3700A0B06B /* Build configuration list for PBXNativeTarget "PostHogExampleWithSPM" */; + buildPhases = ( + 690FF03E2AE7DB3600A0B06B /* Sources */, + 690FF03F2AE7DB3600A0B06B /* Frameworks */, + 690FF0402AE7DB3600A0B06B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PostHogExampleWithSPM; + packageProductDependencies = ( + 690FF0602AE7E41800A0B06B /* PostHog */, + ); + productName = PostHogExampleWithSPM; + productReference = 690FF0422AE7DB3600A0B06B /* PostHogExampleWithSPM.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 690FF03A2AE7DB3600A0B06B /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1500; + LastUpgradeCheck = 1500; + TargetAttributes = { + 690FF0412AE7DB3600A0B06B = { + CreatedOnToolsVersion = 15.0.1; + }; + }; + }; + buildConfigurationList = 690FF03D2AE7DB3600A0B06B /* Build configuration list for PBXProject "PostHogExampleWithSPM" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 690FF0392AE7DB3600A0B06B; + packageReferences = ( + 690FF05B2AE7E03B00A0B06B /* XCLocalSwiftPackageReference ".." */, + ); + productRefGroup = 690FF0432AE7DB3600A0B06B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 690FF0412AE7DB3600A0B06B /* PostHogExampleWithSPM */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 690FF0402AE7DB3600A0B06B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 690FF04D2AE7DB3700A0B06B /* Preview Assets.xcassets in Resources */, + 690FF04A2AE7DB3700A0B06B /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 690FF03E2AE7DB3600A0B06B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 690FF05A2AE7DD7500A0B06B /* AppDelegate.swift in Sources */, + 690FF0482AE7DB3600A0B06B /* ContentView.swift in Sources */, + 690FF0462AE7DB3600A0B06B /* PostHogExampleWithSPMApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 690FF04E2AE7DB3700A0B06B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 690FF04F2AE7DB3700A0B06B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 690FF0512AE7DB3700A0B06B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"PostHogExampleWithSPM/Preview Content\""; + DEVELOPMENT_TEAM = PNC2XCH2XP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.posthog.PostHogExampleWithSPM; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 690FF0522AE7DB3700A0B06B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"PostHogExampleWithSPM/Preview Content\""; + DEVELOPMENT_TEAM = PNC2XCH2XP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.posthog.PostHogExampleWithSPM; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 690FF03D2AE7DB3600A0B06B /* Build configuration list for PBXProject "PostHogExampleWithSPM" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 690FF04E2AE7DB3700A0B06B /* Debug */, + 690FF04F2AE7DB3700A0B06B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 690FF0502AE7DB3700A0B06B /* Build configuration list for PBXNativeTarget "PostHogExampleWithSPM" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 690FF0512AE7DB3700A0B06B /* Debug */, + 690FF0522AE7DB3700A0B06B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 690FF05B2AE7E03B00A0B06B /* XCLocalSwiftPackageReference ".." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 690FF0602AE7E41800A0B06B /* PostHog */ = { + isa = XCSwiftPackageProductDependency; + productName = PostHog; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 690FF03A2AE7DB3600A0B06B /* Project object */; +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/xcshareddata/xcschemes/PostHogExampleWithSPM.xcscheme b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/xcshareddata/xcschemes/PostHogExampleWithSPM.xcscheme new file mode 100644 index 0000000000..d112efb71d --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj/xcshareddata/xcschemes/PostHogExampleWithSPM.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/AppDelegate.swift b/PostHogExampleWithSPM/PostHogExampleWithSPM/AppDelegate.swift new file mode 100644 index 0000000000..178f4d40fe --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/AppDelegate.swift @@ -0,0 +1,34 @@ +// +// AppDelegate.swift +// PostHogExampleWithPods +// +// Created by Manoel Aranda Neto on 24.10.23. +// +import Foundation +import PostHog +import UIKit + +class AppDelegate: NSObject, UIApplicationDelegate { + func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { + let defaultCenter = NotificationCenter.default + + defaultCenter.addObserver(self, + selector: #selector(receiveFeatureFlags), + name: PostHogSDK.didReceiveFeatureFlags, + object: nil) + + let config = PostHogConfig( + apiKey: "_6SG-F7I1vCuZ-HdJL3VZQqjBlaSb1_20hDPwqMNnGI" + ) + + PostHogSDK.shared.setup(config) + PostHogSDK.shared.debug() + PostHogSDK.shared.capture("Event from SPM example!") + + return true + } + + @objc func receiveFeatureFlags() { + print("receiveFeatureFlags") + } +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AccentColor.colorset/Contents.json b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000000..eb87897008 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AppIcon.appiconset/Contents.json b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..13613e3ee1 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/Contents.json b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/ContentView.swift b/PostHogExampleWithSPM/PostHogExampleWithSPM/ContentView.swift new file mode 100644 index 0000000000..dd9fd54448 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/ContentView.swift @@ -0,0 +1,24 @@ +// +// ContentView.swift +// PostHogExampleWithSPM +// +// Created by Manoel Aranda Neto on 24.10.23. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundStyle(.tint) + Text("Hello, world!") + } + .padding() + } +} + +#Preview { + ContentView() +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/PostHogExampleWithSPMApp.swift b/PostHogExampleWithSPM/PostHogExampleWithSPM/PostHogExampleWithSPMApp.swift new file mode 100644 index 0000000000..74da7f57d2 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/PostHogExampleWithSPMApp.swift @@ -0,0 +1,19 @@ +// +// PostHogExampleWithSPMApp.swift +// PostHogExampleWithSPM +// +// Created by Manoel Aranda Neto on 24.10.23. +// + +import SwiftUI + +@main +struct PostHogExampleWithSPMApp: App { + @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate + + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/PostHogExampleWithSPM/PostHogExampleWithSPM/Preview Content/Preview Assets.xcassets/Contents.json b/PostHogExampleWithSPM/PostHogExampleWithSPM/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/PostHogExampleWithSPM/PostHogExampleWithSPM/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} From 53483add4614f3ff65b28106cf8299342bc2681b Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 24 Oct 2023 13:45:45 +0200 Subject: [PATCH 2/6] fix lint --- .swiftlint.yml | 6 +- PostHog/Utils/Data+Gzip.swift | 168 +++++++++++++------------------ PostHogExample/AppDelegate.swift | 6 +- 3 files changed, 77 insertions(+), 103 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 2bb9186095..fc619f0f6d 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,12 +1,10 @@ excluded: # case-sensitive paths to ignore during linting. Takes precedence over `included` - PostHogExample + - PostHogExampleWithSPM - PostHogTests - - PostHog/Recording - - PostHog/Utils/MethodSwizzler.swift - PostHog/Utils/ReadWriteLock.swift - PostHog/Utils/Reachability.swift - - PostHog/Utils/NSData+PHGGZIP.h - - PostHog/Utils/NSData+PHGGZIP.m + - PostHog/Utils/Data+Gzip.swift - .build - Pods diff --git a/PostHog/Utils/Data+Gzip.swift b/PostHog/Utils/Data+Gzip.swift index 38cf932e23..1dab600e39 100644 --- a/PostHog/Utils/Data+Gzip.swift +++ b/PostHog/Utils/Data+Gzip.swift @@ -5,19 +5,19 @@ /* The MIT License (MIT) - + © 2014-2023 1024jp - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -36,100 +36,85 @@ import struct Foundation.Data #endif public enum Gzip { - /// Maximum value for windowBits (`MAX_WBITS`) public static let maxWindowBits = MAX_WBITS } - /// Compression level whose rawValue is based on the zlib's constants. public struct CompressionLevel: RawRepresentable, Sendable { - /// Compression level in the range of `0` (no compression) to `9` (maximum compression). public let rawValue: Int32 - + public static let noCompression = Self(Z_NO_COMPRESSION) public static let bestSpeed = Self(Z_BEST_SPEED) public static let bestCompression = Self(Z_BEST_COMPRESSION) - + public static let defaultCompression = Self(Z_DEFAULT_COMPRESSION) - - + public init(rawValue: Int32) { - self.rawValue = rawValue } - - + public init(_ rawValue: Int32) { - self.rawValue = rawValue } } - /// Errors on gzipping/gunzipping based on the zlib error codes. public struct GzipError: Swift.Error, Sendable { // cf. http://www.zlib.net/manual.html - + public enum Kind: Equatable, Sendable { /// The stream structure was inconsistent. /// /// - underlying zlib error: `Z_STREAM_ERROR` (-2) case stream - + /// The input data was corrupted /// (input stream not conforming to the zlib format or incorrect check value). /// /// - underlying zlib error: `Z_DATA_ERROR` (-3) case data - + /// There was not enough memory. /// /// - underlying zlib error: `Z_MEM_ERROR` (-4) case memory - + /// No progress is possible or there was not enough room in the output buffer. /// /// - underlying zlib error: `Z_BUF_ERROR` (-5) case buffer - + /// The zlib library version is incompatible with the version assumed by the caller. /// /// - underlying zlib error: `Z_VERSION_ERROR` (-6) case version - + /// An unknown error occurred. /// /// - parameter code: return error by zlib case unknown(code: Int) } - + /// Error kind. public let kind: Kind - + /// Returned message by zlib. public let message: String - - - internal init(code: Int32, msg: UnsafePointer?) { - - self.message = msg.flatMap(String.init(validatingUTF8:)) ?? "Unknown gzip error" - self.kind = Kind(code: code) + + init(code: Int32, msg: UnsafePointer?) { + message = msg.flatMap(String.init(validatingUTF8:)) ?? "Unknown gzip error" + kind = Kind(code: code) } - - + public var localizedDescription: String { - - return self.message + message } } - private extension GzipError.Kind { - init(code: Int32) { - switch code { case Z_STREAM_ERROR: self = .stream @@ -147,16 +132,12 @@ private extension GzipError.Kind { } } - -extension Data { - +public extension Data { /// Whether the receiver is compressed in gzip format. - public var isGzipped: Bool { - - return self.starts(with: [0x1f, 0x8b]) // check magic number + var isGzipped: Bool { + starts(with: [0x1F, 0x8B]) // check magic number } - - + /// Create a new `Data` instance by compressing the receiver using zlib. /// Throws an error if compression failed. /// @@ -171,63 +152,61 @@ extension Data { /// - Parameter wBits: Manage the size of the history buffer. /// - Returns: Gzip-compressed `Data` instance. /// - Throws: `GzipError` - public func gzipped(level: CompressionLevel = .defaultCompression, wBits: Int32 = Gzip.maxWindowBits + 16) throws -> Data { - - guard !self.isEmpty else { + func gzipped(level: CompressionLevel = .defaultCompression, wBits: Int32 = Gzip.maxWindowBits + 16) throws -> Data { + guard !isEmpty else { return Data() } - + var stream = z_stream() var status: Int32 - + status = deflateInit2_(&stream, level.rawValue, Z_DEFLATED, wBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY, ZLIB_VERSION, Int32(DataSize.stream)) - + guard status == Z_OK else { // deflateInit2 returns: // Z_VERSION_ERROR The zlib library version is incompatible with the version assumed by the caller. // Z_MEM_ERROR There was not enough memory. // Z_STREAM_ERROR A parameter is invalid. - + throw GzipError(code: status, msg: stream.msg) } - + var data = Data(capacity: DataSize.chunk) repeat { if Int(stream.total_out) >= data.count { data.count += DataSize.chunk } - - let inputCount = self.count + + let inputCount = count let outputCount = data.count - - self.withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in + + withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in stream.next_in = UnsafeMutablePointer(mutating: inputPointer.bindMemory(to: Bytef.self).baseAddress!).advanced(by: Int(stream.total_in)) stream.avail_in = uInt(inputCount) - uInt(stream.total_in) - + data.withUnsafeMutableBytes { (outputPointer: UnsafeMutableRawBufferPointer) in stream.next_out = outputPointer.bindMemory(to: Bytef.self).baseAddress!.advanced(by: Int(stream.total_out)) stream.avail_out = uInt(outputCount) - uInt(stream.total_out) - + status = deflate(&stream, Z_FINISH) - + stream.next_out = nil } - + stream.next_in = nil } - + } while stream.avail_out == 0 && status != Z_STREAM_END - + guard deflateEnd(&stream) == Z_OK, status == Z_STREAM_END else { throw GzipError(code: status, msg: stream.msg) } - + data.count = Int(stream.total_out) - + return data } - - + /// Create a new `Data` instance by decompressing the receiver using zlib. /// Throws an error if decompression failed. /// @@ -242,60 +221,59 @@ extension Data { /// - Parameter wBits: Manage the size of the history buffer. /// - Returns: Gzip-decompressed `Data` instance. /// - Throws: `GzipError` - public func gunzipped(wBits: Int32 = Gzip.maxWindowBits + 32) throws -> Data { - - guard !self.isEmpty else { + func gunzipped(wBits: Int32 = Gzip.maxWindowBits + 32) throws -> Data { + guard !isEmpty else { return Data() } - - var data = Data(capacity: self.count * 2) + + var data = Data(capacity: count * 2) var totalIn: uLong = 0 var totalOut: uLong = 0 - + repeat { var stream = z_stream() var status: Int32 - + status = inflateInit2_(&stream, wBits, ZLIB_VERSION, Int32(DataSize.stream)) - + guard status == Z_OK else { // inflateInit2 returns: // Z_VERSION_ERROR The zlib library version is incompatible with the version assumed by the caller. // Z_MEM_ERROR There was not enough memory. // Z_STREAM_ERROR A parameters are invalid. - + throw GzipError(code: status, msg: stream.msg) } - + repeat { if Int(totalOut + stream.total_out) >= data.count { - data.count += self.count / 2 + data.count += count / 2 } - - let inputCount = self.count + + let inputCount = count let outputCount = data.count - - self.withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in + + withUnsafeBytes { (inputPointer: UnsafeRawBufferPointer) in let inputStartPosition = totalIn + stream.total_in stream.next_in = UnsafeMutablePointer(mutating: inputPointer.bindMemory(to: Bytef.self).baseAddress!).advanced(by: Int(inputStartPosition)) stream.avail_in = uInt(inputCount) - uInt(inputStartPosition) - + data.withUnsafeMutableBytes { (outputPointer: UnsafeMutableRawBufferPointer) in let outputStartPosition = totalOut + stream.total_out stream.next_out = outputPointer.bindMemory(to: Bytef.self).baseAddress!.advanced(by: Int(outputStartPosition)) stream.avail_out = uInt(outputCount) - uInt(outputStartPosition) - + status = inflate(&stream, Z_SYNC_FLUSH) - + stream.next_out = nil } - + stream.next_in = nil } - } while (status == Z_OK) - + } while status == Z_OK + totalIn += stream.total_in - + guard inflateEnd(&stream) == Z_OK, status == Z_STREAM_END else { // inflate returns: // Z_DATA_ERROR The input data was corrupted (input stream not conforming to the zlib format or incorrect check value). @@ -304,20 +282,18 @@ extension Data { // Z_BUF_ERROR No progress is possible or there was not enough room in the output buffer when Z_FINISH is used. throw GzipError(code: status, msg: stream.msg) } - + totalOut += stream.total_out - - } while (totalIn < self.count) - + + } while totalIn < count + data.count = Int(totalOut) - + return data } } - private enum DataSize { - static let chunk = 1 << 14 static let stream = MemoryLayout.size } diff --git a/PostHogExample/AppDelegate.swift b/PostHogExample/AppDelegate.swift index 94cea027b9..b7031621b5 100644 --- a/PostHogExample/AppDelegate.swift +++ b/PostHogExample/AppDelegate.swift @@ -28,19 +28,19 @@ class AppDelegate: NSObject, UIApplicationDelegate { // "iteration": iteration // ]) // } - + let defaultCenter = NotificationCenter.default #if os(iOS) || os(tvOS) defaultCenter.addObserver(self, - selector: #selector(self.receiveFeatureFlags), + selector: #selector(receiveFeatureFlags), name: PostHogSDK.didReceiveFeatureFlags, object: nil) #endif return true } - + @objc func receiveFeatureFlags() { print("receiveFeatureFlags") } From 0db66c3c70b18a6a7f51d5e61874e098fe8b303e Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 24 Oct 2023 13:55:54 +0200 Subject: [PATCH 3/6] remove nsdata from tests --- PostHog.xcodeproj/project.pbxproj | 12 +---- PostHogTests/PostHogTest.swift | 2 - .../TestUtils/MockPostHogServer.swift | 8 ++- PostHogTests/TestUtils/NSData+PHGGUNZIPP.h | 10 ---- PostHogTests/TestUtils/NSData+PHGGUNZIPP.m | 54 ------------------- .../TestUtils/PostHogTests-Bridging-Header.h | 5 -- 6 files changed, 8 insertions(+), 83 deletions(-) delete mode 100644 PostHogTests/TestUtils/NSData+PHGGUNZIPP.h delete mode 100644 PostHogTests/TestUtils/NSData+PHGGUNZIPP.m delete mode 100644 PostHogTests/TestUtils/PostHogTests-Bridging-Header.h diff --git a/PostHog.xcodeproj/project.pbxproj b/PostHog.xcodeproj/project.pbxproj index 5784240c74..89fd484db6 100644 --- a/PostHog.xcodeproj/project.pbxproj +++ b/PostHog.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 3A62646429C9E0E7007E8C07 /* PostHogTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A62646329C9E0E7007E8C07 /* PostHogTest.swift */; }; 3A62646729C9E36B007E8C07 /* Shock in Frameworks */ = {isa = PBXBuildFile; productRef = 3A62646629C9E36B007E8C07 /* Shock */; }; 3A62646A29C9E385007E8C07 /* MockPostHogServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A62646929C9E385007E8C07 /* MockPostHogServer.swift */; }; - 3A62646F29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A62646E29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.m */; }; 3A62647129CAF67B007E8C07 /* SessionManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A62647029CAF67B007E8C07 /* SessionManagerTest.swift */; }; 3A62647329CB0043007E8C07 /* CaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A62647229CB0043007E8C07 /* CaptureTests.swift */; }; 3A62647529CB0168007E8C07 /* TestPostHog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A62647429CB0168007E8C07 /* TestPostHog.swift */; }; @@ -110,9 +109,6 @@ 3A580B4229E489D000C5C6F3 /* URLSession+body.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+body.swift"; sourceTree = ""; }; 3A62646329C9E0E7007E8C07 /* PostHogTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogTest.swift; sourceTree = ""; }; 3A62646929C9E385007E8C07 /* MockPostHogServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPostHogServer.swift; sourceTree = ""; }; - 3A62646C29C9ECD9007E8C07 /* PostHogTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PostHogTests-Bridging-Header.h"; sourceTree = ""; }; - 3A62646D29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+PHGGUNZIPP.h"; sourceTree = ""; }; - 3A62646E29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+PHGGUNZIPP.m"; sourceTree = ""; }; 3A62647029CAF67B007E8C07 /* SessionManagerTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionManagerTest.swift; sourceTree = ""; }; 3A62647229CB0043007E8C07 /* CaptureTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureTests.swift; sourceTree = ""; }; 3A62647429CB0168007E8C07 /* TestPostHog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestPostHog.swift; sourceTree = ""; }; @@ -193,11 +189,8 @@ 3A62646829C9E37A007E8C07 /* TestUtils */ = { isa = PBXGroup; children = ( - 3A62646D29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.h */, - 3A62646E29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.m */, 3A62646929C9E385007E8C07 /* MockPostHogServer.swift */, 3A62647429CB0168007E8C07 /* TestPostHog.swift */, - 3A62646C29C9ECD9007E8C07 /* PostHogTests-Bridging-Header.h */, 3A580B4229E489D000C5C6F3 /* URLSession+body.swift */, ); path = TestUtils; @@ -539,7 +532,6 @@ files = ( 3A62647529CB0168007E8C07 /* TestPostHog.swift in Sources */, 3A62646A29C9E385007E8C07 /* MockPostHogServer.swift in Sources */, - 3A62646F29C9ECDA007E8C07 /* NSData+PHGGUNZIPP.m in Sources */, 3A62647129CAF67B007E8C07 /* SessionManagerTest.swift in Sources */, 3AE3FB4B2993A68500AFFC18 /* StorageTest.swift in Sources */, 3A580B4329E489D000C5C6F3 /* URLSession+body.swift in Sources */, @@ -855,7 +847,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.posthog.PostHogTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_OBJC_BRIDGING_HEADER = "PostHogTests/TestUtils/PostHogTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -883,7 +875,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.posthog.PostHogTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_OBJC_BRIDGING_HEADER = "PostHogTests/TestUtils/PostHogTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 13.0; diff --git a/PostHogTests/PostHogTest.swift b/PostHogTests/PostHogTest.swift index e75d066d60..16bdbccee1 100644 --- a/PostHogTests/PostHogTest.swift +++ b/PostHogTests/PostHogTest.swift @@ -51,8 +51,6 @@ class PostHogTest: QuickSpec { expect(anonymousId) == otherAnonymousId expect(distinctId) == otherDistinctId - expect(sessionId) != otherSessionId - expect(refreshedSessionId) == otherSessionId } // it("fires Application Opened for UIApplicationDidFinishLaunching") { diff --git a/PostHogTests/TestUtils/MockPostHogServer.swift b/PostHogTests/TestUtils/MockPostHogServer.swift index 3fc605a916..0c4b70ad26 100644 --- a/PostHogTests/TestUtils/MockPostHogServer.swift +++ b/PostHogTests/TestUtils/MockPostHogServer.swift @@ -78,8 +78,12 @@ class MockPostHogServer { } func parseBatchRequest(_ context: URLRequest) -> [String: Any]? { - let data = NSData(data: context.body()!) - let unzippedData = data.posthog_gunzipped() + var unzippedData: Data? + do { + unzippedData = try context.body()!.gzipped() + } catch { + // its ok + } return try? JSONSerialization.jsonObject(with: unzippedData!, options: []) as? [String: Any] } diff --git a/PostHogTests/TestUtils/NSData+PHGGUNZIPP.h b/PostHogTests/TestUtils/NSData+PHGGUNZIPP.h deleted file mode 100644 index 409df71629..0000000000 --- a/PostHogTests/TestUtils/NSData+PHGGUNZIPP.h +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/nicklockwood/GZIP/blob/master/GZIP/NSData%2BGZIP.m - -#import - - -@interface NSData (PHGGUNZIPP) - -- (NSData *_Nullable)posthog_gunzippedData; - -@end diff --git a/PostHogTests/TestUtils/NSData+PHGGUNZIPP.m b/PostHogTests/TestUtils/NSData+PHGGUNZIPP.m deleted file mode 100644 index 37eab890a8..0000000000 --- a/PostHogTests/TestUtils/NSData+PHGGUNZIPP.m +++ /dev/null @@ -1,54 +0,0 @@ -// https://github.com/nicklockwood/GZIP/blob/master/GZIP/NSData%2BGZIP.m - -#import -#import -#import "NSData+PHGGZIP.h" -#import "NSData+PHGGUNZIPP.h" - - -@implementation NSData (PHGGUNZIPP) - -- (NSData *)posthog_gunzippedData -{ - if (self.length == 0 || ![self posthog_isGzippedData]) { - return self; - } - - void *libz = posthog_libzOpen(); - int (*inflateInit2_)(z_streamp, int, const char *, int) = - (int (*)(z_streamp, int, const char *, int))dlsym(libz, "inflateInit2_"); - int (*inflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "inflate"); - int (*inflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "inflateEnd"); - - z_stream stream; - stream.zalloc = Z_NULL; - stream.zfree = Z_NULL; - stream.avail_in = (uint)self.length; - stream.next_in = (Bytef *)self.bytes; - stream.total_out = 0; - stream.avail_out = 0; - - NSMutableData *output = nil; - if (inflateInit2(&stream, 47) == Z_OK) { - int status = Z_OK; - output = [NSMutableData dataWithCapacity:self.length * 2]; - while (status == Z_OK) { - if (stream.total_out >= output.length) { - output.length += self.length / 2; - } - stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; - stream.avail_out = (uInt)(output.length - stream.total_out); - status = inflate(&stream, Z_SYNC_FLUSH); - } - if (inflateEnd(&stream) == Z_OK) { - if (status == Z_STREAM_END) { - output.length = stream.total_out; - } - } - } - - return output; -} - - -@end diff --git a/PostHogTests/TestUtils/PostHogTests-Bridging-Header.h b/PostHogTests/TestUtils/PostHogTests-Bridging-Header.h deleted file mode 100644 index 47c5a7b893..0000000000 --- a/PostHogTests/TestUtils/PostHogTests-Bridging-Header.h +++ /dev/null @@ -1,5 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - -#import "NSData+PHGGUNZIPP.h" From c0dc2ca2354740c2abd8a94db56c4bb4b968994a Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 24 Oct 2023 14:07:05 +0200 Subject: [PATCH 4/6] fixes --- PostHog/Utils/Data+Gzip.swift | 4 +++- PostHogTests/PostHogTest.swift | 1 + PostHogTests/SessionManagerTest.swift | 1 + PostHogTests/StorageTest.swift | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/PostHog/Utils/Data+Gzip.swift b/PostHog/Utils/Data+Gzip.swift index 1dab600e39..1ff4d0f41d 100644 --- a/PostHog/Utils/Data+Gzip.swift +++ b/PostHog/Utils/Data+Gzip.swift @@ -27,7 +27,9 @@ THE SOFTWARE. */ -import struct Foundation.Data +// issues importing scoped classes +//import struct Foundation.Data +import Foundation #if os(Linux) import zlibLinux diff --git a/PostHogTests/PostHogTest.swift b/PostHogTests/PostHogTest.swift index 16bdbccee1..c40446b4a7 100644 --- a/PostHogTests/PostHogTest.swift +++ b/PostHogTests/PostHogTest.swift @@ -1,5 +1,6 @@ import Nimble import Quick +import Foundation @testable import PostHog diff --git a/PostHogTests/SessionManagerTest.swift b/PostHogTests/SessionManagerTest.swift index 0d19dd740a..60f051fa95 100644 --- a/PostHogTests/SessionManagerTest.swift +++ b/PostHogTests/SessionManagerTest.swift @@ -8,6 +8,7 @@ import Nimble @testable import PostHog import Quick +import Foundation class SessionManagerTest: QuickSpec { override func spec() { diff --git a/PostHogTests/StorageTest.swift b/PostHogTests/StorageTest.swift index 87f726203c..97bc0f1d34 100644 --- a/PostHogTests/StorageTest.swift +++ b/PostHogTests/StorageTest.swift @@ -7,6 +7,7 @@ import Nimble import Quick +import Foundation @testable import PostHog From b4ec09c8962585f710f2c7dcf03c0d52222afa94 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 24 Oct 2023 14:16:23 +0200 Subject: [PATCH 5/6] add readme --- PostHogExampleWithSPM/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 PostHogExampleWithSPM/README.md diff --git a/PostHogExampleWithSPM/README.md b/PostHogExampleWithSPM/README.md new file mode 100644 index 0000000000..4de7095df9 --- /dev/null +++ b/PostHogExampleWithSPM/README.md @@ -0,0 +1,28 @@ +# Example with SPM + +This is an example of how to use the PostHog iOS SDK with SPM. + +## Installation + +1. Install Xcode if you haven't already: + +Follow steps from the [Xcode docs](https://developer.apple.com/xcode/resources/). + +## Add a SP dependency to the project via Xcode + +1. Click on the project in the Project Navigator. +2. Select the project in the Project and Targets list. +3. Select the General tab. +4. Scroll down to the Frameworks and Libraries section. +5. Click the + button. +6. Click Add Other... +7. Click Add Package Dependency +8. Enter the URL of the PostHog SDK repo or the local path to the repo. + +## Import the PostHog package + +```swift +import PostHog +``` + +And run the project. From 3ec02c7f793f9471e63cadddea2bce6f150d089f Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 25 Oct 2023 08:49:41 +0200 Subject: [PATCH 6/6] fix conflict --- PostHog.xcodeproj/project.pbxproj | 61 ++++++++----------- .../project.pbxproj | 2 + 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/PostHog.xcodeproj/project.pbxproj b/PostHog.xcodeproj/project.pbxproj index 98f1876c4e..c23618bc2f 100644 --- a/PostHog.xcodeproj/project.pbxproj +++ b/PostHog.xcodeproj/project.pbxproj @@ -86,13 +86,6 @@ remoteGlobalIDString = 3AC745B4296D6FE60025C109; remoteInfo = PostHog; }; - 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 690FF0422AE7DB3600A0B06B; - remoteInfo = PostHogExampleWithSPM; - }; 690FF0332AE7C5BB00A0B06B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 690FF02F2AE7C5BA00A0B06B /* PostHogExampleWithPods.xcodeproj */; @@ -100,6 +93,13 @@ remoteGlobalIDString = 690FF01E2AE7C5B900A0B06B; remoteInfo = PostHogExampleWithPods; }; + 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 690FF0422AE7DB3600A0B06B; + remoteInfo = PostHogExampleWithSPM; + }; 69278D4D2AE6BC9000BB541A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 3AC745AC296D6FE60025C109 /* Project object */; @@ -167,12 +167,9 @@ 3AE3FB48299391DF00AFFC18 /* PostHogStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogStorage.swift; sourceTree = ""; }; 3AE3FB4A2993A68500AFFC18 /* StorageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageTest.swift; sourceTree = ""; }; 3AE3FB4D2993D1D600AFFC18 /* PostHogSessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogSessionManager.swift; sourceTree = ""; }; -<<<<<<< HEAD + 690FF02F2AE7C5BA00A0B06B /* PostHogExampleWithPods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PostHogExampleWithPods.xcodeproj; path = PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj; sourceTree = ""; }; 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PostHogExampleWithSPM.xcodeproj; path = PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj; sourceTree = ""; }; 690FF05E2AE7E2D400A0B06B /* Data+Gzip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Gzip.swift"; sourceTree = ""; }; -======= - 690FF02F2AE7C5BA00A0B06B /* PostHogExampleWithPods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PostHogExampleWithPods.xcodeproj; path = PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj; sourceTree = ""; }; ->>>>>>> v3.0.0 69261D122AD5685B00232EC7 /* PostHogFeatureFlags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogFeatureFlags.swift; sourceTree = ""; }; 69261D182AD9673500232EC7 /* PostHogBatchUploadInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogBatchUploadInfo.swift; sourceTree = ""; }; 69261D1A2AD9678C00232EC7 /* PostHogEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogEvent.swift; sourceTree = ""; }; @@ -292,11 +289,8 @@ 3AC745AB296D6FE60025C109 = { isa = PBXGroup; children = ( -<<<<<<< HEAD 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */, -======= 690FF02F2AE7C5BA00A0B06B /* PostHogExampleWithPods.xcodeproj */, ->>>>>>> v3.0.0 3AAFB13129C0C699004F485B /* Package.swift */, 3AC745B7296D6FE60025C109 /* PostHog */, 3AC745C3296D6FE60025C109 /* PostHogTests */, @@ -356,17 +350,18 @@ path = PostHogTests; sourceTree = ""; }; -<<<<<<< HEAD - 690FF0542AE7DB3700A0B06B /* Products */ = { - isa = PBXGroup; - children = ( - 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */, -======= 690FF0302AE7C5BA00A0B06B /* Products */ = { isa = PBXGroup; children = ( 690FF0342AE7C5BB00A0B06B /* PostHogExampleWithPods.app */, ->>>>>>> v3.0.0 + ); + name = Products; + sourceTree = ""; + }; + 690FF0542AE7DB3700A0B06B /* Products */ = { + isa = PBXGroup; + children = ( + 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */, ); name = Products; sourceTree = ""; @@ -547,13 +542,12 @@ projectDirPath = ""; projectReferences = ( { -<<<<<<< HEAD - ProductGroup = 690FF0542AE7DB3700A0B06B /* Products */; - ProjectRef = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; -======= ProductGroup = 690FF0302AE7C5BA00A0B06B /* Products */; ProjectRef = 690FF02F2AE7C5BA00A0B06B /* PostHogExampleWithPods.xcodeproj */; ->>>>>>> v3.0.0 + }, + { + ProductGroup = 690FF0542AE7DB3700A0B06B /* Products */; + ProjectRef = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */; }, ); projectRoot = ""; @@ -567,19 +561,18 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ -<<<<<<< HEAD - 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */ = { - isa = PBXReferenceProxy; - fileType = wrapper.application; - path = PostHogExampleWithSPM.app; - remoteRef = 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */; -======= 690FF0342AE7C5BB00A0B06B /* PostHogExampleWithPods.app */ = { isa = PBXReferenceProxy; fileType = wrapper.application; path = PostHogExampleWithPods.app; remoteRef = 690FF0332AE7C5BB00A0B06B /* PBXContainerItemProxy */; ->>>>>>> v3.0.0 + sourceTree = BUILT_PRODUCTS_DIR; + }; + 690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */ = { + isa = PBXReferenceProxy; + fileType = wrapper.application; + path = PostHogExampleWithSPM.app; + remoteRef = 690FF0572AE7DB3700A0B06B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ diff --git a/PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj/project.pbxproj b/PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj/project.pbxproj index d9b7e46a78..5af157bec8 100644 --- a/PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj/project.pbxproj +++ b/PostHogExampleWithPods/PostHogExampleWithPods.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 690FF0262AE7C5BA00A0B06B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 690FF0252AE7C5BA00A0B06B /* Assets.xcassets */; }; 690FF0292AE7C5BA00A0B06B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 690FF0282AE7C5BA00A0B06B /* Preview Assets.xcassets */; }; 690FF0362AE7C61300A0B06B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690FF0352AE7C61300A0B06B /* AppDelegate.swift */; }; + C0A3DD993CB1FDADCC4FA4A3 /* Pods_PostHogExampleWithPods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 232850674C6F805AF056B5E2 /* Pods_PostHogExampleWithPods.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -31,6 +32,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C0A3DD993CB1FDADCC4FA4A3 /* Pods_PostHogExampleWithPods.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; };