Skip to content

Commit

Permalink
Swift PM fixes and Swift only
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Oct 24, 2023
1 parent 833d074 commit 37058c9
Show file tree
Hide file tree
Showing 18 changed files with 957 additions and 164 deletions.
45 changes: 37 additions & 8 deletions PostHog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -38,14 +37,14 @@
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 */; };
3AE3FB472992AB0000AFFC18 /* Hedgelog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE3FB462992AB0000AFFC18 /* Hedgelog.swift */; };
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 */; };
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -124,15 +130,15 @@
3AE3FB2B2991320300AFFC18 /* Api.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Api.swift; sourceTree = "<group>"; };
3AE3FB322991388500AFFC18 /* PostHogQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogQueue.swift; sourceTree = "<group>"; };
3AE3FB36299162EA00AFFC18 /* PostHogApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogApi.swift; sourceTree = "<group>"; };
3AE3FB3829924CE100AFFC18 /* NSData+PHGGZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+PHGGZIP.h"; sourceTree = "<group>"; };
3AE3FB3929924CE100AFFC18 /* NSData+PHGGZIP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+PHGGZIP.m"; sourceTree = "<group>"; };
3AE3FB3C29924E8200AFFC18 /* PostHogSDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogSDK.swift; sourceTree = "<group>"; };
3AE3FB3E29924F4F00AFFC18 /* PostHogConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogConfig.swift; sourceTree = "<group>"; };
3AE3FB422992985A00AFFC18 /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
3AE3FB462992AB0000AFFC18 /* Hedgelog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hedgelog.swift; sourceTree = "<group>"; };
3AE3FB48299391DF00AFFC18 /* PostHogStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogStorage.swift; sourceTree = "<group>"; };
3AE3FB4A2993A68500AFFC18 /* StorageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageTest.swift; sourceTree = "<group>"; };
3AE3FB4D2993D1D600AFFC18 /* PostHogSessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogSessionManager.swift; sourceTree = "<group>"; };
690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PostHogExampleWithSPM.xcodeproj; path = PostHogExampleWithSPM/PostHogExampleWithSPM.xcodeproj; sourceTree = "<group>"; };
690FF05E2AE7E2D400A0B06B /* Data+Gzip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Gzip.swift"; sourceTree = "<group>"; };
69261D122AD5685B00232EC7 /* PostHogFeatureFlags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogFeatureFlags.swift; sourceTree = "<group>"; };
69261D182AD9673500232EC7 /* PostHogBatchUploadInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogBatchUploadInfo.swift; sourceTree = "<group>"; };
69261D1A2AD9678C00232EC7 /* PostHogEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHogEvent.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -222,20 +228,20 @@
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 = "<group>";
};
3AC745AB296D6FE60025C109 = {
isa = PBXGroup;
children = (
690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */,
3AAFB13129C0C699004F485B /* Package.swift */,
3AC745B7296D6FE60025C109 /* PostHog */,
3AC745C3296D6FE60025C109 /* PostHogTests */,
Expand Down Expand Up @@ -293,6 +299,14 @@
path = PostHogTests;
sourceTree = "<group>";
};
690FF0542AE7DB3700A0B06B /* Products */ = {
isa = PBXGroup;
children = (
690FF0582AE7DB3700A0B06B /* PostHogExampleWithSPM.app */,
);
name = Products;
sourceTree = "<group>";
};
69261D152AD92D6C00232EC7 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand All @@ -316,7 +330,6 @@
buildActionMask = 2147483647;
files = (
3AC745C6296D6FE60025C109 /* PostHog.h in Headers */,
3A4F510D299A78E100B68D5E /* NSData+PHGGZIP.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -428,6 +441,12 @@
);
productRefGroup = 3AC745B6296D6FE60025C109 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 690FF0542AE7DB3700A0B06B /* Products */;
ProjectRef = 690FF0532AE7DB3700A0B06B /* PostHogExampleWithSPM.xcodeproj */;
},
);
projectRoot = "";
targets = (
3AC745B4296D6FE60025C109 /* PostHog */,
Expand All @@ -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;
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down
3 changes: 0 additions & 3 deletions PostHog/PostHog.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@


#import <Foundation/Foundation.h>
// do not use <>
// 'NSData+PHGGZIP.h' file not found with <angled> include; use "quotes" instead
#import "NSData+PHGGZIP.h"

//! Project version number for PostHog.
FOUNDATION_EXPORT double PostHogVersionNumber;
Expand Down
9 changes: 7 additions & 2 deletions PostHog/PostHogApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Loading

0 comments on commit 37058c9

Please sign in to comment.