expo-beacon 0.7.13 → 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"}
|
|
@@ -139,55 +139,76 @@ function removePBXFileReferences(xcodeProject, fileReferences) {
|
|
|
139
139
|
delete refs[`${key}_comment`];
|
|
140
140
|
}
|
|
141
141
|
}
|
|
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) {
|
|
147
|
+
var _a;
|
|
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
|
+
}
|
|
142
158
|
function ensureIOSPluginSourceFile(xcodeProject, projectName) {
|
|
143
159
|
var _a, _b, _c;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
// its `path` actually equals the project name.
|
|
150
|
-
const pbxGroups = (_b = xcodeProject.hash.project.objects['PBXGroup']) !== null && _b !== void 0 ? _b : {};
|
|
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/).
|
|
151
165
|
const groupHasPhysicalPath = groupKey != null &&
|
|
152
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);
|
|
153
178
|
const existingFileReferences = findPBXFileReferences(xcodeProject, IOS_PLUGIN_FILENAME);
|
|
154
179
|
const existingBuildFileKeys = findPBXBuildFileKeys(xcodeProject, existingFileReferences.map(({ key }) => key), IOS_PLUGIN_FILENAME);
|
|
155
180
|
if (existingFileReferences.length === 1 &&
|
|
156
181
|
existingBuildFileKeys.length === 1) {
|
|
182
|
+
// Repair the single existing entry in-place.
|
|
157
183
|
const [existingFileReference] = existingFileReferences;
|
|
158
184
|
existingFileReference.ref.name = `"${IOS_PLUGIN_FILENAME}"`;
|
|
159
185
|
existingFileReference.ref.sourceTree = '"<group>"';
|
|
160
|
-
|
|
186
|
+
existingFileReference.ref.path = `"${fileRefPath}"`;
|
|
187
|
+
if (effectiveGroupKey) {
|
|
161
188
|
removeFileReferenceFromAllGroups(xcodeProject, [existingFileReference.key]);
|
|
162
|
-
xcodeProject.addToPbxGroup({
|
|
163
|
-
fileRef: existingFileReference.key,
|
|
164
|
-
basename: IOS_PLUGIN_FILENAME,
|
|
165
|
-
}, groupKey);
|
|
166
|
-
// If the group is virtual (no path), the file reference path must include
|
|
167
|
-
// the project name so Xcode resolves it to ios/<AppName>/BeaconGeoPlugin.swift.
|
|
168
|
-
existingFileReference.ref.path = groupHasPhysicalPath
|
|
169
|
-
? `"${IOS_PLUGIN_FILENAME}"`
|
|
170
|
-
: `"${projectName}/${IOS_PLUGIN_FILENAME}"`;
|
|
171
|
-
return;
|
|
189
|
+
xcodeProject.addToPbxGroup({ fileRef: existingFileReference.key, basename: IOS_PLUGIN_FILENAME }, effectiveGroupKey);
|
|
172
190
|
}
|
|
173
|
-
existingFileReference.ref.path = `"${projectName}/${IOS_PLUGIN_FILENAME}"`;
|
|
174
191
|
return;
|
|
175
192
|
}
|
|
193
|
+
// Remove any stale/duplicate entries before re-adding.
|
|
176
194
|
if (existingFileReferences.length > 0 || existingBuildFileKeys.length > 0) {
|
|
177
195
|
removePBXSourcesBuildPhaseEntries(xcodeProject, existingBuildFileKeys, IOS_PLUGIN_FILENAME);
|
|
178
196
|
removePBXBuildFiles(xcodeProject, existingBuildFileKeys);
|
|
179
197
|
removeFileReferenceFromAllGroups(xcodeProject, existingFileReferences.map(({ key }) => key));
|
|
180
198
|
removePBXFileReferences(xcodeProject, existingFileReferences);
|
|
181
199
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
+
}
|
|
187
211
|
}
|
|
188
|
-
// Virtual group (name-only, no path) or no group found: use an explicit
|
|
189
|
-
// SOURCE_ROOT-relative path so Xcode always finds ios/<AppName>/file.
|
|
190
|
-
xcodeProject.addSourceFile(`${projectName}/${IOS_PLUGIN_FILENAME}`);
|
|
191
212
|
}
|
|
192
213
|
function modifySwiftAppDelegate(contents) {
|
|
193
214
|
// Insert `import ExpoBeacon` after the last existing import line.
|