react-native-candle 0.1.1 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-candle",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Candle SDK for React Native",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -1,45 +1,64 @@
1
- const { withDangerousMod } = require("@expo/config-plugins");
1
+ const {
2
+ withDangerousMod,
3
+ withXcodeProject,
4
+ withPlugins,
5
+ } = require("@expo/config-plugins");
2
6
  const {
3
7
  mergeContents,
4
8
  } = require("@expo/config-plugins/build/utils/generateCode");
5
9
  const fs = require("fs");
6
10
  const path = require("path");
7
11
 
8
- const withIosDeploymentTarget = (config) => {
9
- return withDangerousMod(config, [
10
- "ios",
11
- async (config) => {
12
- // Find the Podfile
13
- const podfile = path.join(
14
- config.modRequest.platformProjectRoot,
15
- "Podfile"
16
- );
17
- // Read the Podfile
18
- const podfileContents = fs.readFileSync(podfile, "utf8");
19
- // Merge the contents of the Podfile with the new content setting
20
- // the deployment target of all targets to 17.0
21
- const setDeploymentTarget = mergeContents({
22
- tag: "ios-deployment-target",
23
- src: podfileContents,
24
- newSrc: ` installer.pods_project.targets.each do |target|
12
+ const plugin = (config, options = {}) => {
13
+ return withPlugins(config, [
14
+ [
15
+ withDangerousMod,
16
+ [
17
+ "ios",
18
+ async (config) => {
19
+ return withIosDeploymentTarget(config);
20
+ },
21
+ ],
22
+ ],
23
+ [
24
+ withXcodeProject,
25
+ async (config) => {
26
+ return withMyCustomBuildPhase(config);
27
+ },
28
+ ],
29
+ ]);
30
+ };
31
+
32
+ // This function sets the iOS deployment target to 17.0
33
+ const withIosDeploymentTarget = async (config) => {
34
+ // Find the Podfile
35
+ const podfile = path.join(config.modRequest.platformProjectRoot, "Podfile");
36
+ // Read the Podfile
37
+ const podfileContents = fs.readFileSync(podfile, "utf8");
38
+ // Merge the contents of the Podfile with the new content setting
39
+ // the deployment target of all targets to 17.0
40
+ const setDeploymentTarget = mergeContents({
41
+ tag: "ios-deployment-target",
42
+ src: podfileContents,
43
+ newSrc: ` installer.pods_project.targets.each do |target|
25
44
  target.build_configurations.each do |config|
26
45
  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.0'
27
46
  end
28
47
  end`,
29
- anchor: /post_install do \|installer\|/i,
30
- offset: 1,
31
- comment: "#",
32
- });
33
-
34
- if (!setDeploymentTarget.didMerge) {
35
- console.log("Failed to set iOS deployment target");
36
- return config;
37
- }
38
-
39
- const setPreInstallHook = mergeContents({
40
- tag: "rnreanimated-preinstall",
41
- src: setDeploymentTarget.contents,
42
- newSrc: ` pre_install do |installer|
48
+ anchor: /post_install do \|installer\|/i,
49
+ offset: 1,
50
+ comment: "#",
51
+ });
52
+
53
+ if (!setDeploymentTarget.didMerge) {
54
+ console.log("Failed to set iOS deployment target");
55
+ return config;
56
+ }
57
+
58
+ const setPreInstallHook = mergeContents({
59
+ tag: "rnreanimated-preinstall",
60
+ src: setDeploymentTarget.contents,
61
+ newSrc: ` pre_install do |installer|
43
62
  installer.pod_targets.each do |pod|
44
63
  if pod.name.eql?('RNReanimated')
45
64
  def pod.build_type;
@@ -49,21 +68,154 @@ const withIosDeploymentTarget = (config) => {
49
68
  end
50
69
  end
51
70
  end`,
52
- anchor: /post_install do \|installer\|/i,
53
- offset: 0,
54
- comment: "#",
55
- });
71
+ anchor: /post_install do \|installer\|/i,
72
+ offset: 0,
73
+ comment: "#",
74
+ });
75
+
76
+ if (!setPreInstallHook.didMerge) {
77
+ console.log("Failed to insert RNReanimated pre_install hook");
78
+ return config;
79
+ }
80
+
81
+ fs.writeFileSync(podfile, setPreInstallHook.contents);
56
82
 
57
- if (!setPreInstallHook.didMerge) {
58
- console.log("Failed to insert RNReanimated pre_install hook");
59
- return config;
60
- }
83
+ return config;
84
+ };
85
+
86
+ // This function adds a custom build phase to the Xcode project
87
+ // that removes signature files from the build directory
88
+ // for Xcode 15 and 16. This is a workaround for a known issue
89
+ // with these versions of Xcode.
90
+ // I think it's because of the duplicate symbol issue.
91
+ const withMyCustomBuildPhase = async (config) => {
92
+ // Duplicate symbols issue
93
+ const xcodeProject = config.modResults;
94
+ const shellScript = `if { [ "$XCODE_VERSION_MAJOR" = "1500" ] || [ "$XCODE_VERSION_MAJOR" = "1600" ]; } && [ "$CONFIGURATION" = "Release" ]; then
95
+ echo "Remove signature files (Xcode 15/16 workaround, only in Release)"
96
+ find "$BUILD_DIR/\${CONFIGURATION}-iphoneos" -name "*.signature" -type f | xargs -r rm
97
+ fi`;
61
98
 
62
- fs.writeFileSync(podfile, setPreInstallHook.contents);
99
+ xcodeProject.addBuildPhase(
100
+ [],
101
+ "PBXShellScriptBuildPhase",
102
+ "Remove Framework signature files (Xcode 15/16 workaround)",
103
+ null,
104
+ {
105
+ shellPath: "/bin/sh",
106
+ shellScript,
107
+ runOnlyForDeploymentPostprocessing: 1,
108
+ }
109
+ );
63
110
 
64
- return config;
111
+ // reference the "props"
112
+ const { version, repositoryUrl, repoName, productName } = {
113
+ repositoryUrl: "https://github.com/candlefinance/candle-swift.git",
114
+ repoName: "candle-swift",
115
+ productName: "Candle",
116
+ version: "fa0db96e9a73740bbd4977160894a45c6db96f51",
117
+ };
118
+ // get XCRemoteSwiftPackageReference section
119
+ const spmReferences =
120
+ xcodeProject.hash.project.objects["XCRemoteSwiftPackageReference"];
121
+ // if doesn't exist (this is our first SPM package) create empty object
122
+ if (!spmReferences) {
123
+ xcodeProject.hash.project.objects["XCRemoteSwiftPackageReference"] = {};
124
+ }
125
+ // generate new ID
126
+ const packageReferenceUUID = xcodeProject.generateUuid();
127
+ // add XCRemoteSwiftPackageReference section
128
+ xcodeProject.hash.project.objects["XCRemoteSwiftPackageReference"][
129
+ `${packageReferenceUUID} /* XCRemoteSwiftPackageReference "${repoName}" */`
130
+ ] = {
131
+ isa: "XCRemoteSwiftPackageReference",
132
+ repositoryURL: repositoryUrl,
133
+ requirement: {
134
+ kind: "revision",
135
+ revision: version,
65
136
  },
66
- ]);
137
+ };
138
+
139
+ // get XCSwiftPackageProductDependency section
140
+ const spmProducts =
141
+ xcodeProject.hash.project.objects["XCSwiftPackageProductDependency"];
142
+ // if doesn't exist (this is our first SPM package) create empty object
143
+ if (!spmProducts) {
144
+ xcodeProject.hash.project.objects["XCSwiftPackageProductDependency"] = {};
145
+ }
146
+ // generate new ID
147
+ const packageUUID = xcodeProject.generateUuid();
148
+ // add XCSwiftPackageProductDependency section
149
+ xcodeProject.hash.project.objects["XCSwiftPackageProductDependency"][
150
+ `${packageUUID} /* ${productName} */`
151
+ ] = {
152
+ isa: "XCSwiftPackageProductDependency",
153
+ // from step before
154
+ package: `${packageReferenceUUID} /* XCRemoteSwiftPackageReference "${repoName}" */`,
155
+ productName: productName,
156
+ };
157
+
158
+ // get main project ID
159
+ const projectId = Object.keys(
160
+ xcodeProject.hash.project.objects["PBXProject"]
161
+ ).at(0);
162
+ // create empty array for package references if it doesn't exist
163
+ if (
164
+ !xcodeProject.hash.project.objects["PBXProject"][projectId][
165
+ "packageReferences"
166
+ ]
167
+ ) {
168
+ xcodeProject.hash.project.objects["PBXProject"][projectId][
169
+ "packageReferences"
170
+ ] = [];
171
+ }
172
+ // add our package reference (use ID from first step)
173
+ xcodeProject.hash.project.objects["PBXProject"][projectId][
174
+ "packageReferences"
175
+ ] = [
176
+ ...xcodeProject.hash.project.objects["PBXProject"][projectId][
177
+ "packageReferences"
178
+ ],
179
+ `${packageReferenceUUID} /* XCRemoteSwiftPackageReference "${repoName}" */`,
180
+ ];
181
+
182
+ // generate new ID
183
+ const frameworkUUID = xcodeProject.generateUuid();
184
+ // add comment and reference to our framework in PBXBuildFile section
185
+ xcodeProject.hash.project.objects["PBXBuildFile"][
186
+ `${frameworkUUID}_comment`
187
+ ] = `${productName} in Frameworks`;
188
+ xcodeProject.hash.project.objects["PBXBuildFile"][frameworkUUID] = {
189
+ isa: "PBXBuildFile",
190
+ productRef: packageUUID,
191
+ productRef_comment: productName,
192
+ };
193
+
194
+ // get first build phase
195
+ const buildPhaseId = Object.keys(
196
+ xcodeProject.hash.project.objects["PBXFrameworksBuildPhase"]
197
+ ).at(0);
198
+ // create empty array for files if it doesn't exist
199
+ if (
200
+ !xcodeProject.hash.project.objects["PBXFrameworksBuildPhase"][buildPhaseId][
201
+ "files"
202
+ ]
203
+ ) {
204
+ xcodeProject.hash.project.objects["PBXFrameworksBuildPhase"][buildPhaseId][
205
+ "files"
206
+ ] = [];
207
+ }
208
+ // add our framework reference (use ID from step 4)
209
+ xcodeProject.hash.project.objects["PBXFrameworksBuildPhase"][buildPhaseId][
210
+ "files"
211
+ ] = [
212
+ ...xcodeProject.hash.project.objects["PBXFrameworksBuildPhase"][
213
+ buildPhaseId
214
+ ]["files"],
215
+ `${frameworkUUID} /* ${productName} in Frameworks */`,
216
+ ];
217
+
218
+ return config;
67
219
  };
68
220
 
69
- module.exports = withIosDeploymentTarget;
221
+ module.exports = plugin;