Skip to content

Commit

Permalink
fix: iOS build issues (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
einsteinx2 authored Apr 1, 2022
1 parent 58c73b6 commit f0981c6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 107 deletions.
34 changes: 34 additions & 0 deletions Assets/Editor/MParticleBuildPostprocessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;

namespace mParticle {
public class BuildPostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if (target == BuildTarget.iOS)
{
// Get project into C#
var projectPath = PBXProject.GetPBXProjectPath(path);
var project = new PBXProject();
project.ReadFromFile(projectPath);

// Fix Xcode build settings
var projectGUID = project.ProjectGuid();
project.SetBuildProperty(projectGUID, "VALIDATE_WORKSPACE", "YES");
project.SetBuildProperty(projectGUID, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

// Embed mParticle framework
var mainTargetGUID = project.GetUnityMainTargetGuid();
var frameworkFileGUID = project.FindFileGuidByProjectPath("Frameworks/Plugins/iOS/mParticle_Apple_SDK.framework");
project.AddFileToEmbedFrameworks(mainTargetGUID, frameworkFileGUID);

// Overwrite
project.WriteToFile(projectPath);
}
}
}
}
49 changes: 0 additions & 49 deletions Assets/Editor/PostprocessBuildPlayer_mParticle

This file was deleted.

47 changes: 0 additions & 47 deletions Assets/Editor/mParticleBuildPostprocessor.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Plugins/iOS/mParticleUnity.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void _SetUploadInterval(int uploadInterval);
void _LogEvent(const char *mpEvent);
void _LogCommerceEvent(const char *commerceEventJSON);
void _LogScreen(const char *screenName);
void _SetATTStatus(int status, double timestamp)
void _SetATTStatus(int status, double timestamp);

void _LeaveBreadcrumb(const char *breadcrumbName);

Expand Down
10 changes: 1 addition & 9 deletions Assets/Plugins/iOS/mParticleUnity.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void _LogScreen(const char *screenName) {
}

void _SetATTStatus(int status, double timestamp) {
[[MParticle sharedInstance] setATTStatus:status withATTStatusTimestampMillis:timestamp];
[[MParticle sharedInstance] setATTStatus:status withATTStatusTimestampMillis:@(timestamp)];
}

void _LeaveBreadcrumb(const char *breadcrumbName) {
Expand Down Expand Up @@ -540,14 +540,6 @@ + (MPIdentityApiRequest *) MPIdentityApiRequest:(NSDictionary *)identityRequestD
[identityRequest setIdentity:identities[key] identityType:(MPIdentity)[key integerValue]];
}
}
if ([[identityRequestDict allKeys]containsObject:@"UserAliasUUID"]) {
identityRequest.onUserAlias = ^(MParticleUser * _Nonnull previousUser, MParticleUser * _Nonnull newUser) {
NSDictionary<NSString *, NSString *> *aliasDictionary = @{@"CallbackUuid": identityRequestDict[@"UserAliasUUID"],
@"PreviousMpid": [previousUser.userId stringValue],
@"NewMpid": [newUser.userId stringValue]};
UnitySendMessage("MParticle", "OnUserAlias", toChar(jsonWithDictionary(aliasDictionary)));
};
}
return identityRequest;
}

Expand Down
2 changes: 1 addition & 1 deletion buildscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ project_dir=${PWD}
Assets/Plugins/iOS/MParticleUnity.h \
Assets/Plugins/iOS/MParticleUnity.m \
Assets/Plugins/iOS/mParticle_Apple_SDK.framework \
Assets/Editor/PostprocessBuildPlayer_mParticle \
Assets/Editor/MParticleBuildPostprocessor.cs \
mParticle.unitypackage -nographics -batchmode -quit;

0 comments on commit f0981c6

Please sign in to comment.