expo-beacon 0.7.12 → 0.7.14
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
|
@@ -17,13 +17,13 @@ class BeaconGeoPlugin(ctx: Context) : BeaconEventPlugin {
|
|
|
17
17
|
private val bgGeo = BackgroundGeolocation.getInstance(ctx, null)
|
|
18
18
|
|
|
19
19
|
override fun onBeaconEnter(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
|
|
20
|
-
bgGeo.start(
|
|
20
|
+
bgGeo.start()
|
|
21
21
|
override fun onBeaconExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
|
|
22
|
-
bgGeo.stop(
|
|
22
|
+
bgGeo.stop()
|
|
23
23
|
override fun onEddystoneEnter(identifier: String, namespace: String, instance: String, distance: Double) =
|
|
24
|
-
bgGeo.start(
|
|
24
|
+
bgGeo.start()
|
|
25
25
|
override fun onEddystoneExit(identifier: String, namespace: String, instance: String, distance: Double) =
|
|
26
|
-
bgGeo.stop(
|
|
26
|
+
bgGeo.stop()
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withBeaconIOS.d.ts","sourceRoot":"","sources":["../src/withBeaconIOS.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAM9B,eAAO,MAAM,gBAAgB,mvBAkB5B,CAAC;
|
|
1
|
+
{"version":3,"file":"withBeaconIOS.d.ts","sourceRoot":"","sources":["../src/withBeaconIOS.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAM9B,eAAO,MAAM,gBAAgB,mvBAkB5B,CAAC;AA2RF,QAAA,MAAM,aAAa,EAAE,YAkCpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -36,16 +36,21 @@ function normalizePBXValue(value) {
|
|
|
36
36
|
function findPBXGroupKeyByName(xcodeProject, name) {
|
|
37
37
|
var _a;
|
|
38
38
|
const pbxGroups = (_a = xcodeProject.hash.project.objects['PBXGroup']) !== null && _a !== void 0 ? _a : {};
|
|
39
|
+
// Prefer a group whose `path` equals the name — that group IS the filesystem
|
|
40
|
+
// directory. A group matched only by `name` may be a virtual (path-less)
|
|
41
|
+
// container whose children resolve relative to its parent, not itself.
|
|
42
|
+
let nameMatch = null;
|
|
39
43
|
for (const key of Object.keys(pbxGroups)) {
|
|
40
44
|
if (key.endsWith('_comment'))
|
|
41
45
|
continue;
|
|
42
46
|
const group = pbxGroups[key];
|
|
43
|
-
if (normalizePBXValue(group.
|
|
44
|
-
normalizePBXValue(group.path) === name) {
|
|
47
|
+
if (normalizePBXValue(group.path) === name)
|
|
45
48
|
return key;
|
|
49
|
+
if (normalizePBXValue(group.name) === name && nameMatch === null) {
|
|
50
|
+
nameMatch = key;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
|
-
return
|
|
53
|
+
return nameMatch;
|
|
49
54
|
}
|
|
50
55
|
function findPBXFileReferences(xcodeProject, filename) {
|
|
51
56
|
var _a;
|
|
@@ -134,39 +139,76 @@ function removePBXFileReferences(xcodeProject, fileReferences) {
|
|
|
134
139
|
delete refs[`${key}_comment`];
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Returns the key of the project's mainGroup — the root PBXGroup that is
|
|
144
|
+
* always present in every Xcode project.
|
|
145
|
+
*/
|
|
146
|
+
function getMainGroupKey(xcodeProject) {
|
|
138
147
|
var _a;
|
|
139
|
-
const
|
|
148
|
+
const pbxProjects = (_a = xcodeProject.hash.project.objects['PBXProject']) !== null && _a !== void 0 ? _a : {};
|
|
149
|
+
for (const key of Object.keys(pbxProjects)) {
|
|
150
|
+
if (key.endsWith('_comment'))
|
|
151
|
+
continue;
|
|
152
|
+
const proj = pbxProjects[key];
|
|
153
|
+
if (proj === null || proj === void 0 ? void 0 : proj.mainGroup)
|
|
154
|
+
return proj.mainGroup;
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
function ensureIOSPluginSourceFile(xcodeProject, projectName) {
|
|
159
|
+
var _a, _b, _c;
|
|
160
|
+
const pbxGroups = (_a = xcodeProject.hash.project.objects['PBXGroup']) !== null && _a !== void 0 ? _a : {};
|
|
161
|
+
const groupKey = (_b = findPBXGroupKeyByName(xcodeProject, projectName)) !== null && _b !== void 0 ? _b : undefined;
|
|
162
|
+
// A physical group has `path` equal to the project name; its children resolve
|
|
163
|
+
// relative to ios/<AppName>/. A virtual (name-only) group has no `path`, so
|
|
164
|
+
// its children resolve relative to its parent — typically SOURCE_ROOT (ios/).
|
|
165
|
+
const groupHasPhysicalPath = groupKey != null &&
|
|
166
|
+
normalizePBXValue((_c = pbxGroups[groupKey]) === null || _c === void 0 ? void 0 : _c.path) === projectName;
|
|
167
|
+
// The PBXFileReference `path` that makes Xcode resolve ios/<AppName>/file:
|
|
168
|
+
// • physical group → just the basename (the group chain supplies the dir)
|
|
169
|
+
// • virtual / no group → SOURCE_ROOT-relative path
|
|
170
|
+
const fileRefPath = groupHasPhysicalPath
|
|
171
|
+
? IOS_PLUGIN_FILENAME
|
|
172
|
+
: `${projectName}/${IOS_PLUGIN_FILENAME}`;
|
|
173
|
+
// IMPORTANT: xcodeProject.addSourceFile() MUST always receive a group key.
|
|
174
|
+
// Without one it calls addPluginFile() which looks up a "Plugins" PBXGroup
|
|
175
|
+
// that may not exist, dereferencing null and crashing prebuild.
|
|
176
|
+
// Fall back to the project's mainGroup, which is guaranteed to be present.
|
|
177
|
+
const effectiveGroupKey = groupKey !== null && groupKey !== void 0 ? groupKey : getMainGroupKey(xcodeProject);
|
|
140
178
|
const existingFileReferences = findPBXFileReferences(xcodeProject, IOS_PLUGIN_FILENAME);
|
|
141
179
|
const existingBuildFileKeys = findPBXBuildFileKeys(xcodeProject, existingFileReferences.map(({ key }) => key), IOS_PLUGIN_FILENAME);
|
|
142
180
|
if (existingFileReferences.length === 1 &&
|
|
143
181
|
existingBuildFileKeys.length === 1) {
|
|
182
|
+
// Repair the single existing entry in-place.
|
|
144
183
|
const [existingFileReference] = existingFileReferences;
|
|
145
184
|
existingFileReference.ref.name = `"${IOS_PLUGIN_FILENAME}"`;
|
|
146
185
|
existingFileReference.ref.sourceTree = '"<group>"';
|
|
147
|
-
|
|
186
|
+
existingFileReference.ref.path = `"${fileRefPath}"`;
|
|
187
|
+
if (effectiveGroupKey) {
|
|
148
188
|
removeFileReferenceFromAllGroups(xcodeProject, [existingFileReference.key]);
|
|
149
|
-
xcodeProject.addToPbxGroup({
|
|
150
|
-
fileRef: existingFileReference.key,
|
|
151
|
-
basename: IOS_PLUGIN_FILENAME,
|
|
152
|
-
}, groupKey);
|
|
153
|
-
existingFileReference.ref.path = `"${IOS_PLUGIN_FILENAME}"`;
|
|
154
|
-
return;
|
|
189
|
+
xcodeProject.addToPbxGroup({ fileRef: existingFileReference.key, basename: IOS_PLUGIN_FILENAME }, effectiveGroupKey);
|
|
155
190
|
}
|
|
156
|
-
existingFileReference.ref.path = `"${projectName}/${IOS_PLUGIN_FILENAME}"`;
|
|
157
191
|
return;
|
|
158
192
|
}
|
|
193
|
+
// Remove any stale/duplicate entries before re-adding.
|
|
159
194
|
if (existingFileReferences.length > 0 || existingBuildFileKeys.length > 0) {
|
|
160
195
|
removePBXSourcesBuildPhaseEntries(xcodeProject, existingBuildFileKeys, IOS_PLUGIN_FILENAME);
|
|
161
196
|
removePBXBuildFiles(xcodeProject, existingBuildFileKeys);
|
|
162
197
|
removeFileReferenceFromAllGroups(xcodeProject, existingFileReferences.map(({ key }) => key));
|
|
163
198
|
removePBXFileReferences(xcodeProject, existingFileReferences);
|
|
164
199
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
// Always pass effectiveGroupKey so the xcode library never falls through to
|
|
201
|
+
// its addPluginFile / Plugins-group lookup path.
|
|
202
|
+
xcodeProject.addSourceFile(IOS_PLUGIN_FILENAME, null, effectiveGroupKey);
|
|
203
|
+
// For non-physical groups the file reference path defaults to the bare
|
|
204
|
+
// filename; patch it to the SOURCE_ROOT-relative path so Xcode finds the
|
|
205
|
+
// file at ios/<AppName>/BeaconGeoPlugin.swift.
|
|
206
|
+
if (!groupHasPhysicalPath) {
|
|
207
|
+
const newRefs = findPBXFileReferences(xcodeProject, IOS_PLUGIN_FILENAME);
|
|
208
|
+
for (const { ref } of newRefs) {
|
|
209
|
+
ref.path = `"${fileRefPath}"`;
|
|
210
|
+
}
|
|
168
211
|
}
|
|
169
|
-
xcodeProject.addSourceFile(`${projectName}/${IOS_PLUGIN_FILENAME}`);
|
|
170
212
|
}
|
|
171
213
|
function modifySwiftAppDelegate(contents) {
|
|
172
214
|
// Insert `import ExpoBeacon` after the last existing import line.
|