Skip to content

Commit 17e3149

Browse files
authored
Merge pull request #76 from lupidan/canary
2 parents 38da711 + 1168f4d commit 17e3149

13 files changed

Lines changed: 145 additions & 36 deletions

File tree

AppleAuth/AppleAuthManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class AppleAuthManager : IAppleAuthManager
1212
{
1313
static AppleAuthManager()
1414
{
15-
const string versionMessage = "Using Sign in with Apple Unity Plugin - v1.3.0";
15+
const string versionMessage = "Using Sign in with Apple Unity Plugin - v1.4.0";
1616
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
1717
PInvoke.AppleAuth_LogMessage(versionMessage);
1818
#else
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.IO;
3+
using System.Text.RegularExpressions;
4+
using UnityEditor;
5+
using UnityEngine;
6+
7+
namespace AppleAuth.Editor
8+
{
9+
public static class AppleAuthMacosPostprocessorHelper
10+
{
11+
/// <summary>
12+
/// Use this script to change the bundle identifier of the plugin's library bundle to replace it with a personalized one for your product.
13+
/// This should avoid CFBundleIdentifier Collision errors when uploading the app to the macOS App Store
14+
/// </summary>
15+
/// <remarks>Basically this should replace the plugin's bundle identifier from "com.lupidan.MacOSAppleAuthManager" to "{your.project.application.identifier}.MacOSAppleAuthManager"</remarks>
16+
/// <param name="target">The current build target, so it's only executed when building for MacOS</param>
17+
/// <param name="path">The path of the built .app file</param>
18+
public static void FixManagerBundleIdentifier(BuildTarget target, string path)
19+
{
20+
if (target != BuildTarget.StandaloneOSX)
21+
{
22+
Debug.LogError("AppleAuthMacosPostprocessorHelper: FixManagerBundleIdentifier should only be called when building for macOS");
23+
return;
24+
}
25+
26+
const string bundleIdentifierPattern = @"(\<key\>CFBundleIdentifier\<\/key\>\s*\<string\>)(com\.lupidan)(\.MacOSAppleAuthManager\<\/string\>)";
27+
const string macOSAppleAuthManagerInfoPlistRelativePath = "/Contents/Plugins/MacOSAppleAuthManager.bundle/Contents/Info.plist";
28+
29+
try
30+
{
31+
var macosAppleAuthManagerInfoPlistPath = path + macOSAppleAuthManagerInfoPlistRelativePath;
32+
var macosAppleAuthManagerInfoPlist = File.ReadAllText(macosAppleAuthManagerInfoPlistPath);
33+
var modifiedMacosAppleAuthManagerInfoPlist = Regex.Replace(
34+
macosAppleAuthManagerInfoPlist,
35+
bundleIdentifierPattern,
36+
"$1" + PlayerSettings.applicationIdentifier + "$3");
37+
38+
File.WriteAllText(macosAppleAuthManagerInfoPlistPath, modifiedMacosAppleAuthManagerInfoPlist);
39+
Debug.Log("AppleAuthMacosPostprocessorHelper: Renamed MacOSAppleAuthManager.bundle bundle identifier from \"com.lupidan.MacOSAppleAuthManager\" -> \"" + PlayerSettings.applicationIdentifier + ".MacOSAppleAuthManager\"");
40+
}
41+
catch (Exception exception)
42+
{
43+
Debug.LogError("AppleAuthMacosPostprocessorHelper: Error while fixing MacOSAppleAuthManager.bundle bundle identifier :: " + exception.Message);
44+
}
45+
}
46+
}
47+
}

AppleAuth/Editor/AppleAuthMacosPostprocessorHelper.cs.meta

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

AppleAuth/Enums/LoginOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace AppleAuth.Enums
55
[Flags]
66
public enum LoginOptions
77
{
8+
/// <summary>
9+
/// Empty scope. No full name or email
10+
/// </summary>
11+
None = 0,
12+
813
/// <summary>
914
/// A scope that includes the user’s full name.
1015
/// </summary>

AppleAuth/Native/macOS/MacOSAppleAuthManager.bundle/Contents/Info.plist

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>BuildMachineOSBuild</key>
6-
<string>19G73</string>
6+
<string>19H2</string>
77
<key>CFBundleDevelopmentRegion</key>
88
<string>en</string>
99
<key>CFBundleExecutable</key>
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>BNDL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.3.0</string>
20+
<string>1.4.0</string>
2121
<key>CFBundleSupportedPlatforms</key>
2222
<array>
2323
<string>MacOSX</string>
@@ -27,17 +27,19 @@
2727
<key>DTCompiler</key>
2828
<string>com.apple.compilers.llvm.clang.1_0</string>
2929
<key>DTPlatformBuild</key>
30-
<string>11E608c</string>
30+
<string>12A7300</string>
31+
<key>DTPlatformName</key>
32+
<string>macosx</string>
3133
<key>DTPlatformVersion</key>
32-
<string>GM</string>
34+
<string>10.15.6</string>
3335
<key>DTSDKBuild</key>
34-
<string>19E258</string>
36+
<string>19G68</string>
3537
<key>DTSDKName</key>
3638
<string>macosx10.15</string>
3739
<key>DTXcode</key>
38-
<string>1150</string>
40+
<string>1201</string>
3941
<key>DTXcodeBuild</key>
40-
<string>11E608c</string>
42+
<string>12A7300</string>
4143
<key>LSMinimumSystemVersion</key>
4244
<string>10.9</string>
4345
<key>NSHumanReadableCopyright</key>
Binary file not shown.

AppleAuth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.lupidan.apple-signin-unity-src",
33
"displayName": "Sign in with Apple [Local Source]",
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"unity": "2018.3",
66
"description": "[Local Source]\nProvides a Unity bridge to use the native Sign In With Apple method on iOS/iPadOS/tvOS/macOS devices",
77
"author": {

AppleAuthSampleProject/Assets/AppleAuthSample/Editor/SignInWithApplePostprocessor.cs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#if UNITY_IOS || UNITY_TVOS
2+
#define UNITY_XCODE_EXTENSIONS_AVAILABLE
3+
#endif
24

35
using AppleAuth.Editor;
46
using UnityEditor;
57
using UnityEditor.Callbacks;
8+
#if UNITY_XCODE_EXTENSIONS_AVAILABLE
69
using UnityEditor.iOS.Xcode;
10+
#endif
711

812
namespace AppleAuthSample.Editor
913
{
@@ -14,23 +18,27 @@ public static class SignInWithApplePostprocessor
1418
[PostProcessBuild(CallOrder)]
1519
public static void OnPostProcessBuild(BuildTarget target, string path)
1620
{
17-
if (target != BuildTarget.iOS && target != BuildTarget.tvOS)
18-
return;
19-
20-
var projectPath = PBXProject.GetPBXProjectPath(path);
21-
#if UNITY_2019_3_OR_NEWER
22-
var project = new PBXProject();
23-
project.ReadFromString(System.IO.File.ReadAllText(projectPath));
24-
var manager = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", null, project.GetUnityMainTargetGuid());
25-
manager.AddSignInWithAppleWithCompatibility(project.GetUnityFrameworkTargetGuid());
26-
manager.WriteToFile();
27-
#else
28-
var manager = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", PBXProject.GetUnityTargetName());
29-
manager.AddSignInWithAppleWithCompatibility();
30-
manager.WriteToFile();
31-
#endif
21+
if (target == BuildTarget.iOS || target == BuildTarget.tvOS)
22+
{
23+
#if UNITY_XCODE_EXTENSIONS_AVAILABLE
24+
var projectPath = PBXProject.GetPBXProjectPath(path);
25+
#if UNITY_2019_3_OR_NEWER
26+
var project = new PBXProject();
27+
project.ReadFromString(System.IO.File.ReadAllText(projectPath));
28+
var manager = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", null, project.GetUnityMainTargetGuid());
29+
manager.AddSignInWithAppleWithCompatibility(project.GetUnityFrameworkTargetGuid());
30+
manager.WriteToFile();
31+
#else
32+
var manager = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", PBXProject.GetUnityTargetName());
33+
manager.AddSignInWithAppleWithCompatibility();
34+
manager.WriteToFile();
35+
#endif
36+
#endif
37+
}
38+
else if (target == BuildTarget.StandaloneOSX)
39+
{
40+
AppleAuthMacosPostprocessorHelper.FixManagerBundleIdentifier(target, path);
41+
}
3242
}
3343
}
3444
}
35-
36-
#endif

AppleAuthSampleProject/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ PlayerSettings:
118118
16:10: 1
119119
16:9: 1
120120
Others: 1
121-
bundleVersion: 1.3.0
121+
bundleVersion: 1.4.0
122122
preloadedAssets: []
123123
metroInputSource: 0
124124
wsaTransparentSwapchain: 0

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.4.0] - 2020-10-18
4+
### Added
5+
- Adds static class `AppleAuthMacosPostprocessorHelper`, so now there should always be an AppleAuth.Editor namespace independent of the current platform.
6+
- Adds static method to `AppleAuthMacosPostprocessorHelper`, `FixManagerBundleIdentifier` is a method to change the plugin's bundle identifier to a custom one based on the current project's application identifier. This should avoid CFBundleIdentifier collision errors when uploading to the MacOS App Store.
7+
- Adds enum value for `LoginOptions` to not request full name or email, `LoginOptions.None`.
8+
9+
### Changed
10+
- Updates sample code Postprocessor script to support the new recommended post processing for macOS builds
11+
312
## [1.3.0] - 2020-07-18
413
### Added
514
- Adds support to set the `State` when making a Login or a Quick Login request to sign in with Apple.
@@ -77,7 +86,8 @@
7786
- Added support to listen to Revoked Credentials notifications
7887
- Solved possible crashes that could happen when trying to execute a callback in the Native Message Handler, if the callback was to throw an exception, the application would crash.
7988

80-
[Unreleased]: https://github.com/lupidan/apple-signin-unity/compare/v1.3.0...HEAD
89+
[Unreleased]: https://github.com/lupidan/apple-signin-unity/compare/v1.4.0...HEAD
90+
[1.4.0]: https://github.com/lupidan/apple-signin-unity/compare/v1.3.0...v1.4.0
8191
[1.3.0]: https://github.com/lupidan/apple-signin-unity/compare/v1.2.0...v1.3.0
8292
[1.2.0]: https://github.com/lupidan/apple-signin-unity/compare/v1.1.0...v1.2.0
8393
[1.1.0]: https://github.com/lupidan/apple-signin-unity/compare/v1.0.0...v1.1.0

0 commit comments

Comments
 (0)