Skip to content

Commit 584bc15

Browse files
authored
Merge pull request #85 from OneSignal/fix_ios
Fix Cloud Build Issue
2 parents a680ab9 + 8df5cae commit 584bc15

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using UnityEditor.Callbacks;
4+
using System.Collections;
5+
using System.IO;
6+
7+
#if UNITY_IPHONE && UNITY_EDITOR
8+
9+
public struct framework {
10+
public string name;
11+
public string id;
12+
public string fileId;
13+
14+
public framework(string fName, string fId, string fFileid) {
15+
name = fName;
16+
id = fId;
17+
fileId = fFileid;
18+
}
19+
}
20+
21+
/*
22+
Adds required frameworks (currently just UserNotifications.framework) to the iOS project
23+
To add further frameworks in the build process, just add a new framework to the Frameworks array
24+
*/
25+
26+
public class PostBuildTrigger {
27+
28+
[PostProcessBuild]
29+
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) {
30+
LinkLibraries(target, pathToBuiltProject);
31+
}
32+
33+
public static void LinkLibraries(BuildTarget target, string pathToBuiltProject) {
34+
framework[] frameworksToAdd = new framework[1];
35+
36+
frameworksToAdd[0] = new framework("UserNotifications", "CAF63D112040CD8E00A651DC", "CAF63D102040CD8E00A651DC");
37+
38+
string projectFile = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
39+
string contents = File.ReadAllText(projectFile);
40+
41+
foreach (framework framework in frameworksToAdd) {
42+
AddFrameworkToProject(framework, ref contents);
43+
}
44+
45+
File.WriteAllText(projectFile, contents);
46+
}
47+
48+
public static void AddFrameworkToProject(framework framework, ref string contents) {
49+
string orientationSupport = "Ref = 8AC71EC319E7FBA90027502F /* OrientationSupport.mm */; };";
50+
string pbxFileReference = "wnFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };";
51+
string pbsFrameworksBuildPhase = "1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,";
52+
string frameworksSection = "1D30AB110D05D00D00671497 /* Foundation.framework */,";
53+
54+
contents = contents.Replace(orientationSupport, orientationSupport + "\n\t\t" + framework.id + " /* " + framework.name + ".framework in Frameworks */ = {isa = PBXBuildFile; fileRef = " + framework.fileId + " /* " + framework.name + ".framework */; };");
55+
contents = contents.Replace(pbxFileReference, pbxFileReference + "\n\t\t" + framework.fileId + " /* " + framework.name + ".framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = " + framework.name + ".framework; path = System/Library/Frameworks/" + framework.name + ".framework; sourceTree = SDKROOT; };");
56+
contents = contents.Replace(pbsFrameworksBuildPhase, framework.id + " /* " + framework.name + ".framework in Frameworks */,\n\t\t\t\t" + pbsFrameworksBuildPhase);
57+
contents = contents.Replace(frameworksSection, framework.fileId + " /* " + framework.name + ".framework */,\n\t\t\t\t" + frameworksSection);
58+
}
59+
}
60+
61+
#endif

OneSignalExample/Assets/OneSignal/Editor/PostProcessBuildPlayer_iOS.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OneSignalExample/Assets/OneSignal/src/OneSignalIOS.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public class OneSignalIOS : OneSignalPlatform {
9090

9191
[System.Runtime.InteropServices.DllImport("__Internal")]
9292
extern static public void _addEmailSubscriptionObserver();
93-
94-
[System.Runtime.InteropServices.DllImport("__Internal")];
93+
94+
[System.Runtime.InteropServices.DllImport("__Internal")]
9595
extern static public void _removeEmailSubscriptionObserver();
9696

9797
[System.Runtime.InteropServices.DllImport("__Internal")]
@@ -215,6 +215,10 @@ public OSPermissionStateChanges parseOSPermissionStateChanges(string jsonStat) {
215215
return OneSignalPlatformHelper.parseOSPermissionStateChanges(this, jsonStat);
216216
}
217217

218+
public OSEmailSubscriptionStateChanges parseOSEmailSubscriptionStateChanges(string jsonState) {
219+
return OneSignalPlatformHelper.parseOSEmailSubscriptionStateChanges (this, jsonState);
220+
}
221+
218222
public OSSubscriptionStateChanges parseOSSubscriptionStateChanges(string jsonStat) {
219223
return OneSignalPlatformHelper.parseOSSubscriptionStateChanges(this, jsonStat);
220224
}
@@ -252,4 +256,4 @@ public OSEmailSubscriptionState parseOSEmailSubscriptionState(object stateDict)
252256
return state;
253257
}
254258
}
255-
#endif
259+
#endif

OneSignalExample/ProjectSettings/ProjectSettings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ PlayerSettings:
183183
serializedVersion: 2
184184
m_Bits: 238
185185
iPhoneSdkVersion: 988
186-
iOSTargetOSVersionString: 7.0
186+
iOSTargetOSVersionString: 9.0
187187
tvOSSdkVersion: 0
188188
tvOSRequireExtendedGameController: 0
189189
tvOSTargetOSVersionString: 9.0
@@ -703,7 +703,7 @@ PlayerSettings:
703703
webGLCompressionFormat: 1
704704
scriptingDefineSymbols: {}
705705
platformArchitecture:
706-
iOS: 0
706+
iOS: 2
707707
scriptingBackend:
708708
Android: 0
709709
Metro: 2

0 commit comments

Comments
 (0)