expo-beacon 0.7.13 → 0.7.15

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": "expo-beacon",
3
- "version": "0.7.13",
3
+ "version": "0.7.15",
4
4
  "description": "Expo module for scanning, pairing, and monitoring iBeacons on Android and iOS",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -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(null)
20
+ bgGeo.start()
21
21
  override fun onBeaconExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
22
- bgGeo.stop(null)
22
+ bgGeo.stop()
23
23
  override fun onEddystoneEnter(identifier: String, namespace: String, instance: String, distance: Double) =
24
- bgGeo.start(null)
24
+ bgGeo.start()
25
25
  override fun onEddystoneExit(identifier: String, namespace: String, instance: String, distance: Double) =
26
- bgGeo.stop(null)
26
+ bgGeo.stop()
27
27
  }
28
28
  `;
29
29
  }
@@ -1,5 +1,5 @@
1
1
  import { ConfigPlugin } from '@expo/config-plugins';
2
- export declare const IOS_PLUGIN_SWIFT = "import ExpoBeacon\nimport TSLocationManager\n\nfinal class BeaconGeoPlugin: BeaconLifecycleDelegate {\n func beaconDidEnter(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {\n TSLocationManager.sharedManager().start()\n }\n func beaconDidExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {\n TSLocationManager.sharedManager().stop()\n }\n func eddystoneDidEnter(identifier: String, namespace: String, instance: String, distance: Double) {\n TSLocationManager.sharedManager().start()\n }\n func eddystoneDidExit(identifier: String, namespace: String, instance: String, distance: Double) {\n TSLocationManager.sharedManager().stop()\n }\n}\n";
2
+ export declare const IOS_PLUGIN_SWIFT = "import ExpoBeacon\nimport TSLocationManager\n\nfinal class BeaconGeoPlugin: BeaconLifecycleDelegate {\n func beaconDidEnter(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {\n TSLocationManager.sharedInstance().start()\n }\n func beaconDidExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {\n TSLocationManager.sharedInstance().stop()\n }\n func eddystoneDidEnter(identifier: String, namespace: String, instance: String, distance: Double) {\n TSLocationManager.sharedInstance().start()\n }\n func eddystoneDidExit(identifier: String, namespace: String, instance: String, distance: Double) {\n TSLocationManager.sharedInstance().stop()\n }\n}\n";
3
3
  declare const withBeaconIOS: ConfigPlugin;
4
4
  export default withBeaconIOS;
5
5
  //# sourceMappingURL=withBeaconIOS.d.ts.map
@@ -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;AAoQF,QAAA,MAAM,aAAa,EAAE,YAkCpB,CAAC;AAEF,eAAe,aAAa,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,uvBAkB5B,CAAC;AA2RF,QAAA,MAAM,aAAa,EAAE,YAkCpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -11,16 +11,16 @@ import TSLocationManager
11
11
 
12
12
  final class BeaconGeoPlugin: BeaconLifecycleDelegate {
13
13
  func beaconDidEnter(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {
14
- TSLocationManager.sharedManager().start()
14
+ TSLocationManager.sharedInstance().start()
15
15
  }
16
16
  func beaconDidExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) {
17
- TSLocationManager.sharedManager().stop()
17
+ TSLocationManager.sharedInstance().stop()
18
18
  }
19
19
  func eddystoneDidEnter(identifier: String, namespace: String, instance: String, distance: Double) {
20
- TSLocationManager.sharedManager().start()
20
+ TSLocationManager.sharedInstance().start()
21
21
  }
22
22
  func eddystoneDidExit(identifier: String, namespace: String, instance: String, distance: Double) {
23
- TSLocationManager.sharedManager().stop()
23
+ TSLocationManager.sharedInstance().stop()
24
24
  }
25
25
  }
26
26
  `;
@@ -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 groupKey = (_a = findPBXGroupKeyByName(xcodeProject, projectName)) !== null && _a !== void 0 ? _a : undefined;
145
- // A virtual (name-only) PBXGroup has no `path`. Files added to it with
146
- // `<group>` sourceTree resolve relative to the group's *parent*, not the
147
- // group itself, so `BeaconGeoPlugin.swift` would land at `ios/` not
148
- // `ios/<AppName>/`. Only treat the group as a physical directory group when
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
- if (groupKey) {
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
- if (groupKey && groupHasPhysicalPath) {
183
- // Physical group (path = projectName): add with just the filename; Xcode
184
- // resolves it through the group's directory chain to ios/<AppName>/file.
185
- xcodeProject.addSourceFile(IOS_PLUGIN_FILENAME, null, groupKey);
186
- return;
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.