@dolami-inc/react-native-expo-unity 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.plugin.js +34 -19
- package/package.json +1 -1
package/app.plugin.js
CHANGED
|
@@ -6,8 +6,8 @@ const fs = require('fs');
|
|
|
6
6
|
* Expo Config Plugin for @dolami-inc/react-native-expo-unity.
|
|
7
7
|
*
|
|
8
8
|
* - Injects required Xcode build settings (bitcode, C++17)
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
9
|
+
* - Adds a build phase that embeds UnityFramework.framework into the app
|
|
10
|
+
* bundle at build time (device builds only)
|
|
11
11
|
*
|
|
12
12
|
* @param {object} config - Expo config
|
|
13
13
|
* @param {{ unityPath?: string }} options
|
|
@@ -20,7 +20,6 @@ const withExpoUnity = (config, options = {}) => {
|
|
|
20
20
|
const xcodeProject = config.modResults;
|
|
21
21
|
const projectRoot = config.modRequest.projectRoot;
|
|
22
22
|
|
|
23
|
-
// Resolve actual filesystem path for the Unity build artifacts.
|
|
24
23
|
const unityPath =
|
|
25
24
|
options.unityPath ||
|
|
26
25
|
process.env.EXPO_UNITY_PATH ||
|
|
@@ -33,27 +32,43 @@ const withExpoUnity = (config, options = {}) => {
|
|
|
33
32
|
if (typeof configuration !== 'object' || !configuration.buildSettings) {
|
|
34
33
|
continue;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
const settings = configuration.buildSettings;
|
|
38
|
-
|
|
39
|
-
// Unity as a Library does not support bitcode.
|
|
40
36
|
settings['ENABLE_BITCODE'] = 'NO';
|
|
41
|
-
|
|
42
|
-
// Unity headers require C++17.
|
|
43
|
-
// Must be quoted — '+' causes CocoaPods' plist parser to fail if unquoted.
|
|
44
37
|
settings['CLANG_CXX_LANGUAGE_STANDARD'] = '"c++17"';
|
|
45
38
|
}
|
|
46
39
|
|
|
47
|
-
// -- Embed UnityFramework --
|
|
48
|
-
// UnityFramework is a dynamic framework
|
|
49
|
-
// the app bundle's Frameworks/ directory, otherwise dyld fails at
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
// -- Embed UnityFramework via build script phase --
|
|
41
|
+
// UnityFramework is a dynamic framework that must be embedded (copied)
|
|
42
|
+
// into the app bundle's Frameworks/ directory, otherwise dyld fails at
|
|
43
|
+
// launch. We use a shell script build phase instead of vendored_frameworks
|
|
44
|
+
// because the pod source may live in a read-only package manager cache.
|
|
45
|
+
const frameworkSrc = path.join(unityPath, 'UnityFramework.framework');
|
|
46
|
+
if (fs.existsSync(frameworkSrc)) {
|
|
47
|
+
const target = xcodeProject.getFirstTarget();
|
|
48
|
+
|
|
49
|
+
// Shell script that copies and codesigns the framework (device only).
|
|
50
|
+
const script = [
|
|
51
|
+
'if [ "${PLATFORM_NAME}" = "iphoneos" ]; then',
|
|
52
|
+
' FRAMEWORK_SRC="' + frameworkSrc + '"',
|
|
53
|
+
' DEST="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"',
|
|
54
|
+
' mkdir -p "${DEST}"',
|
|
55
|
+
' rsync -av --delete "${FRAMEWORK_SRC}" "${DEST}/"',
|
|
56
|
+
' if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" ]; then',
|
|
57
|
+
' codesign --force --sign "${EXPANDED_CODE_SIGN_IDENTITY}" "${DEST}/UnityFramework.framework"',
|
|
58
|
+
' fi',
|
|
59
|
+
'fi',
|
|
60
|
+
].join('\n');
|
|
61
|
+
|
|
62
|
+
xcodeProject.addBuildPhase(
|
|
63
|
+
[],
|
|
64
|
+
'PBXShellScriptBuildPhase',
|
|
65
|
+
'Embed UnityFramework',
|
|
66
|
+
target.uuid,
|
|
67
|
+
{
|
|
68
|
+
shellPath: '/bin/sh',
|
|
69
|
+
shellScript: script,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
57
72
|
}
|
|
58
73
|
|
|
59
74
|
return config;
|