customerio-expo-plugin 0.0.4 → 1.0.0-alpha.1

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.
Files changed (143) hide show
  1. package/lib/commonjs/android/withAppGoogleServices.js +16 -0
  2. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  3. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  4. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  5. package/lib/commonjs/android/withGistMavenRepository.js +16 -0
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +30 -0
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  9. package/lib/commonjs/android/withProjectGoogleServices.js +16 -0
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  11. package/lib/commonjs/helpers/constants/android.js +19 -0
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  14. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/ios.js +138 -0
  16. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  17. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService-Info.plist +0 -0
  18. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.h +0 -0
  19. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.m +0 -0
  20. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.swift +0 -0
  21. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +0 -0
  22. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  23. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  24. package/lib/commonjs/helpers/utils/fileManagement.js +44 -0
  25. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +32 -0
  27. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  28. package/lib/commonjs/index.js +17 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/ios/withAppDelegateModifications.js +76 -0
  31. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +96 -0
  33. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  34. package/lib/commonjs/ios/withCIOIos.js +18 -0
  35. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  36. package/lib/commonjs/ios/withNotificationsXcodeProject.js +157 -0
  37. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  38. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  39. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  40. package/lib/commonjs/types/cio-types.js +15 -0
  41. package/lib/commonjs/types/cio-types.js.map +1 -0
  42. package/lib/module/android/withAppGoogleServices.js +9 -0
  43. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  44. package/lib/module/android/withCIOAndroid.js +12 -0
  45. package/lib/module/android/withCIOAndroid.js.map +1 -0
  46. package/lib/module/android/withGistMavenRepository.js +9 -0
  47. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  48. package/lib/module/android/withGoogleServicesJSON.js +23 -0
  49. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  50. package/lib/module/android/withProjectGoogleServices.js +9 -0
  51. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  52. package/lib/module/helpers/constants/android.js +7 -0
  53. package/lib/module/helpers/constants/android.js.map +1 -0
  54. package/lib/module/helpers/constants/globals.d.js +2 -0
  55. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  56. package/lib/module/helpers/constants/ios.js +102 -0
  57. package/lib/module/helpers/constants/ios.js.map +1 -0
  58. package/lib/module/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  59. package/lib/module/helpers/native-files/ios/CIONotificationService.h +5 -0
  60. package/lib/module/helpers/native-files/ios/CIONotificationService.m +30 -0
  61. package/lib/module/helpers/native-files/ios/CIONotificationService.swift +21 -0
  62. package/lib/module/helpers/native-files/ios/PushNotification.swift +56 -0
  63. package/lib/module/helpers/utils/codeInjection.js +24 -0
  64. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  65. package/lib/module/helpers/utils/fileManagement.js +37 -0
  66. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  67. package/lib/module/helpers/utils/injectCIOPodfileCode.js +25 -0
  68. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  69. package/lib/module/index.js +10 -0
  70. package/lib/module/index.js.map +1 -0
  71. package/lib/module/ios/withAppDelegateModifications.js +69 -0
  72. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  73. package/lib/module/ios/withAppDelegateXcodeProject.js +88 -0
  74. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  75. package/lib/module/ios/withCIOIos.js +12 -0
  76. package/lib/module/ios/withCIOIos.js.map +1 -0
  77. package/lib/module/ios/withNotificationsXcodeProject.js +149 -0
  78. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  79. package/lib/module/ios/withXcodeProject.js +21 -0
  80. package/lib/module/ios/withXcodeProject.js.map +1 -0
  81. package/lib/module/types/cio-types.js +10 -0
  82. package/lib/module/types/cio-types.js.map +1 -0
  83. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  84. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  85. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  86. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  87. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  88. package/lib/typescript/helpers/constants/android.d.ts +6 -0
  89. package/lib/typescript/helpers/constants/ios.d.ts +30 -0
  90. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  91. package/lib/typescript/helpers/utils/fileManagement.d.ts +5 -0
  92. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  93. package/lib/typescript/index.d.ts +4 -0
  94. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  95. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  96. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  97. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  98. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  99. package/lib/typescript/types/cio-types.d.ts +22 -0
  100. package/package.json +87 -13
  101. package/src/android/withAppGoogleServices.ts +19 -0
  102. package/src/android/withCIOAndroid.ts +19 -0
  103. package/src/android/withGistMavenRepository.ts +19 -0
  104. package/src/android/withGoogleServicesJSON.ts +30 -0
  105. package/src/android/withProjectGoogleServices.ts +19 -0
  106. package/src/helpers/constants/android.ts +12 -0
  107. package/src/helpers/constants/globals.d.ts +8 -0
  108. package/src/helpers/constants/ios.ts +116 -0
  109. package/src/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  110. package/src/helpers/native-files/ios/CIONotificationService.h +5 -0
  111. package/src/helpers/native-files/ios/CIONotificationService.m +30 -0
  112. package/src/helpers/native-files/ios/CIONotificationService.swift +21 -0
  113. package/src/helpers/native-files/ios/PushNotification.swift +56 -0
  114. package/src/helpers/utils/codeInjection.ts +46 -0
  115. package/src/helpers/utils/fileManagement.ts +39 -0
  116. package/src/helpers/utils/injectCIOPodfileCode.ts +47 -0
  117. package/src/index.ts +21 -0
  118. package/src/ios/withAppDelegateModifications.ts +150 -0
  119. package/src/ios/withAppDelegateXcodeProject.ts +110 -0
  120. package/src/ios/withCIOIos.ts +19 -0
  121. package/src/ios/withNotificationsXcodeProject.ts +231 -0
  122. package/src/ios/withXcodeProject.ts +25 -0
  123. package/src/types/cio-types.ts +28 -0
  124. package/build/helpers/.DS_Store +0 -0
  125. package/build/helpers/ios/.DS_Store +0 -0
  126. package/build/package.json +0 -36
  127. package/build/src/android/withAppGoogleServices.js +0 -12
  128. package/build/src/android/withCIOAndroid.js +0 -15
  129. package/build/src/android/withGistMavenRepository.js +0 -12
  130. package/build/src/android/withGoogleServicesJSON.js +0 -24
  131. package/build/src/android/withProjectGoogleServices.js +0 -12
  132. package/build/src/helpers/constants/android.js +0 -9
  133. package/build/src/helpers/constants/ios.js +0 -102
  134. package/build/src/helpers/utils/codeInjection.js +0 -30
  135. package/build/src/helpers/utils/fileManagement.js +0 -40
  136. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  137. package/build/src/index.js +0 -11
  138. package/build/src/ios/withAppDelegateModifications.js +0 -77
  139. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  140. package/build/src/ios/withCIOIos.js +0 -15
  141. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  142. package/build/src/ios/withXcodeProject.js +0 -22
  143. package/build/src/types/cio-types.js +0 -8
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAppDelegateModifications = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const Paths_1 = require("@expo/config-plugins/build/ios/Paths");
6
- const ios_1 = require("../helpers/constants/ios");
7
- const codeInjection_1 = require("../helpers/utils/codeInjection");
8
- const fileManagement_1 = require("../helpers/utils/fileManagement");
9
- const pushCodeSnippets = [
10
- ios_1.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,
11
- ios_1.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,
12
- ];
13
- const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join w/ newlines and ensure a newline at the end.
14
- const addImport = (stringContents) => {
15
- const importRegex = /^(#import .*)\n/gm;
16
- const addedImport = `
17
- // Add swift bridge imports
18
- #import <ExpoModulesCore-Swift.h>
19
- #import <testiosapp-Swift.h>
20
- `;
21
- const match = stringContents.match(importRegex);
22
- let endOfMatchIndex;
23
- if (!match || match.index === undefined) {
24
- // No imports found, just add to start of file:
25
- endOfMatchIndex = 0;
26
- }
27
- else {
28
- // Add after first import:
29
- endOfMatchIndex = match.index + match[0].length;
30
- }
31
- stringContents = (0, codeInjection_1.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport).join('\n');
32
- return stringContents;
33
- };
34
- const addNotificationHandlerDeclaration = (stringContents) => {
35
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_APPDELEGATEDECLARATION_REGEX, ios_1.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
36
- return stringContents;
37
- };
38
- const addNotificationConfiguration = (stringContents) => {
39
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, ios_1.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
40
- return stringContents;
41
- };
42
- const addDidFailToRegisterForRemoteNotificationsWithError = (stringContents) => {
43
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
44
- return stringContents;
45
- };
46
- const AddDidRegisterForRemoteNotificationsWithDeviceToken = (stringContents) => {
47
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, ios_1.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
48
- return stringContents;
49
- };
50
- const addAdditionalMethodsForPushNotifications = (stringContents) => {
51
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, additionalMethodsForPushNotifications);
52
- return stringContents;
53
- };
54
- const addAppdelegateHeaderModification = (stringContents) => {
55
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_APPDELEGATEHEADER_REGEX, ios_1.CIO_APPDELEGATEHEADER_SNIPPET);
56
- return stringContents;
57
- };
58
- const withAppDelegateModifications = (configOuter) => {
59
- return (0, config_plugins_1.withAppDelegate)(configOuter, async (config) => {
60
- let stringContents = config.modResults.contents;
61
- const headerPath = (0, Paths_1.getAppDelegateHeaderFilePath)(config.modRequest.projectRoot);
62
- let headerContent = await fileManagement_1.FileManagement.read(headerPath);
63
- headerContent = addAppdelegateHeaderModification(headerContent);
64
- fileManagement_1.FileManagement.write(headerPath, headerContent);
65
- stringContents = addImport(stringContents);
66
- stringContents = addNotificationHandlerDeclaration(stringContents);
67
- stringContents = addNotificationConfiguration(stringContents);
68
- stringContents = addAdditionalMethodsForPushNotifications(stringContents);
69
- stringContents =
70
- addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
71
- stringContents =
72
- AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
73
- config.modResults.contents = stringContents;
74
- return config;
75
- });
76
- };
77
- exports.withAppDelegateModifications = withAppDelegateModifications;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withCioAppdelegateXcodeProject = void 0;
7
- const config_plugins_1 = require("@expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const xcode_1 = __importDefault(require("xcode"));
10
- const ios_1 = require("../helpers/constants/ios");
11
- const addNotificationServiceExtensionFile = async (options) => {
12
- const { iosPath, appName } = options;
13
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
14
- const xcodeProject = xcode_1.default.project(projPath);
15
- xcodeProject.parse(async function (err) {
16
- if (err) {
17
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
18
- }
19
- fs_1.default.mkdirSync(`${iosPath}/${appName}`, {
20
- recursive: true,
21
- });
22
- const file = 'PushNotification.swift';
23
- const getTargetFile = (filename) => `${iosPath}/${appName}/${filename}`;
24
- const targetFile = getTargetFile(file);
25
- fs_1.default.copyFileSync(`${ios_1.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
26
- // Create new PBXGroup for the extension
27
- const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
28
- // Add the new PBXGroup to the top level group. This makes the
29
- // files / folder appear in the file explorer in Xcode.
30
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
31
- Object.keys(groups).forEach((key) => {
32
- if (groups[key].name === undefined) {
33
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
34
- }
35
- });
36
- // WORK AROUND for codeProject.addTarget BUG
37
- // Xcode projects don't contain these if there is only one target
38
- // An upstream fix should be made to the code referenced in this link:
39
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
40
- const projObjects = xcodeProject.hash.project.objects;
41
- projObjects['PBXTargetDependency'] =
42
- projObjects['PBXTargetDependency'] || {};
43
- projObjects['PBXContainerItemProxy'] =
44
- projObjects['PBXTargetDependency'] || {};
45
- fs_1.default.writeFileSync(projPath, xcodeProject.writeSync());
46
- });
47
- };
48
- const withCioAppdelegateXcodeProject = (configOuter, props) => {
49
- return (0, config_plugins_1.withXcodeProject)(configOuter, async (config) => {
50
- const { modRequest, ios, version: bundleShortVersion } = config;
51
- const { appleTeamId, iosDeploymentTarget } = props;
52
- if (ios === undefined)
53
- throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
54
- const { projectName, platformProjectRoot } = modRequest;
55
- const { bundleIdentifier, buildNumber } = ios;
56
- if (bundleShortVersion === undefined) {
57
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
58
- }
59
- if (bundleIdentifier === undefined) {
60
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
61
- }
62
- if (projectName === undefined) {
63
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
64
- }
65
- const options = {
66
- appleTeamId,
67
- bundleIdentifier,
68
- bundleShortVersion,
69
- bundleVersion: buildNumber !== null && buildNumber !== void 0 ? buildNumber : ios_1.DEFAULT_BUNDLE_VERSION,
70
- iosPath: platformProjectRoot,
71
- appName: projectName,
72
- iosDeploymentTarget,
73
- };
74
- await addNotificationServiceExtensionFile(options);
75
- return config;
76
- });
77
- };
78
- exports.withCioAppdelegateXcodeProject = withCioAppdelegateXcodeProject;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withCIOIos = void 0;
4
- const withAppDelegateModifications_1 = require("./withAppDelegateModifications");
5
- const withAppDelegateXcodeProject_1 = require("./withAppDelegateXcodeProject");
6
- const withNotificationsXcodeProject_1 = require("./withNotificationsXcodeProject");
7
- const withXcodeProject_1 = require("./withXcodeProject");
8
- function withCIOIos(config, props) {
9
- config = (0, withNotificationsXcodeProject_1.withCioNotificationsXcodeProject)(config, props);
10
- config = (0, withAppDelegateModifications_1.withAppDelegateModifications)(config, props);
11
- config = (0, withXcodeProject_1.withCioXcodeProject)(config, props);
12
- config = (0, withAppDelegateXcodeProject_1.withCioAppdelegateXcodeProject)(config, props);
13
- return config;
14
- }
15
- exports.withCIOIos = withCIOIos;
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withCioNotificationsXcodeProject = void 0;
7
- const config_plugins_1 = require("@expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const xcode_1 = __importDefault(require("xcode"));
10
- const ios_1 = require("../helpers/constants/ios");
11
- const injectCIOPodfileCode_1 = require("../helpers/utils/injectCIOPodfileCode");
12
- const PLIST_FILENAME = `${ios_1.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
13
- const TARGETED_DEVICE_FAMILY = `"1,2"`;
14
- const addNotificationServiceExtension = async (options) => {
15
- const { appleTeamId, bundleIdentifier, bundleShortVersion, bundleVersion, iosPath, appName, iosDeploymentTarget, } = options;
16
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
17
- const xcodeProject = xcode_1.default.project(projPath);
18
- xcodeProject.parse(async function (err) {
19
- if (err) {
20
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
21
- }
22
- await (0, injectCIOPodfileCode_1.injectCIONotificationPodfileCode)(iosPath);
23
- fs_1.default.mkdirSync(`${iosPath}/${ios_1.CIO_NOTIFICATION_TARGET_NAME}`, {
24
- recursive: true,
25
- });
26
- const files = [
27
- PLIST_FILENAME,
28
- 'CIONotificationService.h',
29
- 'CIONotificationService.swift',
30
- 'CIONotificationService.m',
31
- ];
32
- const getTargetFile = (filename) => `${iosPath}/${ios_1.CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
33
- files.forEach((filename) => {
34
- const targetFile = getTargetFile(filename);
35
- fs_1.default.copyFileSync(`${ios_1.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
36
- });
37
- /* MODIFY COPIED EXTENSION FILES */
38
- const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
39
- updateNseInfoPlist({
40
- bundleVersion,
41
- bundleShortVersion,
42
- infoPlistTargetFile,
43
- });
44
- // Create new PBXGroup for the extension
45
- const extGroup = xcodeProject.addPbxGroup(files, ios_1.CIO_NOTIFICATION_TARGET_NAME, ios_1.CIO_NOTIFICATION_TARGET_NAME);
46
- // Add the new PBXGroup to the top level group. This makes the
47
- // files / folder appear in the file explorer in Xcode.
48
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
49
- Object.keys(groups).forEach((key) => {
50
- if (groups[key].name === undefined) {
51
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
52
- }
53
- });
54
- // WORK AROUND for codeProject.addTarget BUG
55
- // Xcode projects don't contain these if there is only one target
56
- // An upstream fix should be made to the code referenced in this link:
57
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
58
- const projObjects = xcodeProject.hash.project.objects;
59
- projObjects['PBXTargetDependency'] =
60
- projObjects['PBXTargetDependency'] || {};
61
- projObjects['PBXContainerItemProxy'] =
62
- projObjects['PBXTargetDependency'] || {};
63
- if (xcodeProject.pbxTargetByName(ios_1.CIO_NOTIFICATION_TARGET_NAME)) {
64
- console.warn(`${ios_1.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
65
- return;
66
- }
67
- // Add the NSE target
68
- // This also adds PBXTargetDependency and PBXContainerItemProxy
69
- const nseTarget = xcodeProject.addTarget(ios_1.CIO_NOTIFICATION_TARGET_NAME, 'app_extension', ios_1.CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
70
- // Add build phases to the new target
71
- xcodeProject.addBuildPhase(['CIONotificationService.m', 'CIONotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
72
- xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
73
- xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
74
- // Edit the Deployment info of the target
75
- const configurations = xcodeProject.pbxXCBuildConfigurationSection();
76
- for (const key in configurations) {
77
- if (typeof configurations[key].buildSettings !== 'undefined' &&
78
- configurations[key].buildSettings.PRODUCT_NAME ===
79
- `"${ios_1.CIO_NOTIFICATION_TARGET_NAME}"`) {
80
- const buildSettingsObj = configurations[key].buildSettings;
81
- buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
82
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
83
- iosDeploymentTarget !== null && iosDeploymentTarget !== void 0 ? iosDeploymentTarget : '13.0';
84
- buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
85
- buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
86
- buildSettingsObj.SWIFT_VERSION = 4.2;
87
- }
88
- }
89
- // Add development team to the target & the main
90
- xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
91
- xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
92
- fs_1.default.writeFileSync(projPath, xcodeProject.writeSync());
93
- });
94
- };
95
- const withCioNotificationsXcodeProject = (configOuter, props) => {
96
- return (0, config_plugins_1.withXcodeProject)(configOuter, async (config) => {
97
- const { modRequest, ios, version: bundleShortVersion } = config;
98
- const { appleTeamId, iosDeploymentTarget } = props;
99
- if (ios === undefined)
100
- throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
101
- const { projectName, platformProjectRoot } = modRequest;
102
- const { bundleIdentifier, buildNumber } = ios;
103
- if (bundleShortVersion === undefined) {
104
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
105
- }
106
- if (bundleIdentifier === undefined) {
107
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
108
- }
109
- if (projectName === undefined) {
110
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
111
- }
112
- const options = {
113
- appleTeamId,
114
- bundleIdentifier,
115
- bundleShortVersion,
116
- bundleVersion: buildNumber !== null && buildNumber !== void 0 ? buildNumber : ios_1.DEFAULT_BUNDLE_VERSION,
117
- iosPath: platformProjectRoot,
118
- appName: projectName,
119
- iosDeploymentTarget,
120
- };
121
- await addNotificationServiceExtension(options);
122
- return config;
123
- });
124
- };
125
- exports.withCioNotificationsXcodeProject = withCioNotificationsXcodeProject;
126
- const updateNseInfoPlist = ({ bundleVersion, bundleShortVersion, infoPlistTargetFile, }) => {
127
- const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
128
- const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
129
- let plistFileString = fs_1.default.readFileSync(infoPlistTargetFile, 'utf-8');
130
- plistFileString = plistFileString.replace(BUNDLE_VERSION_RE, bundleVersion);
131
- plistFileString = plistFileString.replace(BUNDLE_SHORT_VERSION_RE, bundleShortVersion);
132
- fs_1.default.writeFileSync(infoPlistTargetFile, plistFileString);
133
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withCioXcodeProject = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const injectCIOPodfileCode_1 = require("../helpers/utils/injectCIOPodfileCode");
6
- const withCioXcodeProject = (config, cioProps) => {
7
- return (0, config_plugins_1.withXcodeProject)(config, async (props) => {
8
- var _a, _b;
9
- const options = {
10
- iosPath: props.modRequest.platformProjectRoot,
11
- bundleIdentifier: (_a = props.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier,
12
- devTeam: cioProps === null || cioProps === void 0 ? void 0 : cioProps.devTeam,
13
- bundleVersion: (_b = props.ios) === null || _b === void 0 ? void 0 : _b.buildNumber,
14
- bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
15
- iosDeploymentTarget: cioProps === null || cioProps === void 0 ? void 0 : cioProps.iosDeploymentTarget,
16
- };
17
- const { iosPath } = options;
18
- await (0, injectCIOPodfileCode_1.injectCIOPodfileCode)(iosPath);
19
- return props;
20
- });
21
- };
22
- exports.withCioXcodeProject = withCioXcodeProject;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Mode = void 0;
4
- var Mode;
5
- (function (Mode) {
6
- Mode["Dev"] = "development";
7
- Mode["Prod"] = "production";
8
- })(Mode = exports.Mode || (exports.Mode = {}));