react-native-acoustic-connect-beta 18.0.37 → 18.0.39

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/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## [18.0.39](https://github.com/aipoweredmarketer/react-native-acoustic-connect-beta/compare/18.0.38...18.0.39) (2026-06-23)
2
+ ## [18.0.38](https://github.com/aipoweredmarketer/react-native-acoustic-connect-beta/compare/18.0.37...18.0.38) (2026-06-22)
1
3
  ## [18.0.37](https://github.com/aipoweredmarketer/react-native-acoustic-connect-beta/compare/18.0.36...18.0.37) (2026-06-22)
2
4
  ## [18.0.35](https://github.com/aipoweredmarketer/react-native-acoustic-connect-beta/compare/18.0.34...18.0.35) (2026-06-15)
3
5
  ## [18.0.34](https://github.com/aipoweredmarketer/react-native-acoustic-connect-beta/compare/18.0.33...18.0.34) (2026-06-15)
@@ -1,4 +1,4 @@
1
- #Mon Jun 22 05:14:55 PDT 2026
1
+ #Tue Jun 23 01:25:25 PDT 2026
2
2
  UseWhiteList=true
3
3
  PrintScreen=3
4
4
  UseRandomSample=false
package/cli/doctor.mjs ADDED
@@ -0,0 +1,314 @@
1
+ // `acoustic-connect doctor [dir]` — pre-build doctor + config scaffolder.
2
+ //
3
+ // One command that checks the prerequisites and validates the bits of Acoustic
4
+ // Connect integration that otherwise fail late and confusingly at build time:
5
+ // the App Group format, a Java-safe Android package, and the
6
+ // google-services.json package match. It also scaffolds the gitignored
7
+ // ConnectConfig.json from the committed example so a fresh clone has something
8
+ // to edit.
9
+ //
10
+ // Auto-detects the project shape:
11
+ // - Expo : a root app.json with an `expo` block (identifiers live there;
12
+ // google-services.json sits at the project root).
13
+ // - bare : an android/app/build.gradle (identifiers come from
14
+ // applicationId; google-services.json sits under android/app/).
15
+ //
16
+ // It is read-mostly: the only thing it writes is a missing ConnectConfig.json
17
+ // (copied from the example). It never touches native projects, installs
18
+ // dependencies, or creates Apple/Firebase resources — those are owned by the
19
+ // platform tooling and the developer's accounts.
20
+
21
+ import fs from 'node:fs'
22
+ import path from 'node:path'
23
+
24
+ import {
25
+ Reporter,
26
+ color,
27
+ copyIfMissing,
28
+ fileExists,
29
+ readJson,
30
+ readText,
31
+ section,
32
+ } from './lib.mjs'
33
+
34
+ // App Group format per Apple + the Config Plugin's own validator
35
+ // (plugin/src/withConnectNSE.ts: APP_GROUP_PATTERN).
36
+ const APP_GROUP_PATTERN = /^group\.[A-Za-z0-9.-]+$/
37
+
38
+ // The committed sample ships placeholder identifiers (com.example.*) that the
39
+ // consumer is expected to replace with their own — setting app.json identity is
40
+ // the normal Expo workflow, not something the SDK rewrites for you. Flag a value
41
+ // still on the placeholder so it isn't shipped by accident.
42
+ const PLACEHOLDER_ID_PREFIX = 'com.example.'
43
+
44
+ // Java reserved words (+ literals) that cannot appear as a package segment.
45
+ // Expo uses android.package as the Java/Kotlin namespace, so any segment that
46
+ // is a keyword breaks the Gradle build ("not a valid Java package name").
47
+ const JAVA_KEYWORDS = new Set([
48
+ 'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char',
49
+ 'class', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum',
50
+ 'extends', 'final', 'finally', 'float', 'for', 'goto', 'if', 'implements',
51
+ 'import', 'instanceof', 'int', 'interface', 'long', 'native', 'new',
52
+ 'package', 'private', 'protected', 'public', 'return', 'short', 'static',
53
+ 'strictfp', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws',
54
+ 'transient', 'try', 'void', 'volatile', 'while', 'true', 'false', 'null',
55
+ ])
56
+
57
+ // Decide whether `dir` is an Expo or a bare React Native project.
58
+ export function detectProjectType(dir) {
59
+ const appJson = readJson(path.join(dir, 'app.json'))
60
+ if (appJson && appJson.expo) return 'expo'
61
+ // A bare RN app always declares `react-native` in its manifest. Use that as
62
+ // the discriminator rather than a bare `android/` directory — any Flutter or
63
+ // native-Android project also has one, and would be misclassified as bare.
64
+ const pkg = readJson(path.join(dir, 'package.json'))
65
+ const deps = {...pkg?.dependencies, ...pkg?.devDependencies}
66
+ if (deps['react-native']) return 'bare'
67
+ return 'unknown'
68
+ }
69
+
70
+ function checkNode(reporter) {
71
+ const major = Number(process.versions.node.split('.')[0])
72
+ if (major >= 20) reporter.pass(`Node ${process.versions.node}`)
73
+ else
74
+ reporter.fail(
75
+ `Node ${process.versions.node}`,
76
+ 'Node >= 20 is required — upgrade Node and re-run',
77
+ )
78
+ }
79
+
80
+ // Scaffold the per-developer ConnectConfig.json from the committed example.
81
+ function ensureConnectConfig(reporter, dir) {
82
+ const dest = path.join(dir, 'ConnectConfig.json')
83
+ const src = path.join(dir, 'ConnectConfig.example.json')
84
+ const result = copyIfMissing(src, dest)
85
+ if (result === 'created')
86
+ reporter.warn(
87
+ 'ConnectConfig.json',
88
+ 'created from example — EDIT it: set AppKey + collector URLs (PostMessageUrl/KillSwitchUrl), and iOSAppGroupIdentifier for push',
89
+ )
90
+ else if (result === 'exists') reporter.pass('ConnectConfig.json present')
91
+ else reporter.fail('ConnectConfig.json', 'ConnectConfig.example.json missing')
92
+ }
93
+
94
+ // Validate the App Group identifier (when set). A bad value fails the Config
95
+ // Plugin during `expo prebuild` / the iOS extensions at build time, not here,
96
+ // so catch it early. Returns { appGroup, pushEnabled } for downstream checks.
97
+ function checkConnectConfigValues(reporter, dir) {
98
+ const cfg = readJson(path.join(dir, 'ConnectConfig.json'))
99
+ if (cfg === undefined) {
100
+ // Missing/failed was already reported by ensureConnectConfig; only flag a
101
+ // present-but-broken file here.
102
+ if (fileExists(path.join(dir, 'ConnectConfig.json')))
103
+ reporter.fail('ConnectConfig.json', 'present but not valid JSON')
104
+ return {}
105
+ }
106
+ const connect = (cfg && cfg.Connect) || {}
107
+ const appGroup = connect.iOSAppGroupIdentifier
108
+ const pushEnabled = connect.PushEnabled === true
109
+
110
+ if (appGroup) {
111
+ if (APP_GROUP_PATTERN.test(appGroup))
112
+ reporter.pass('iOSAppGroupIdentifier', appGroup)
113
+ else
114
+ reporter.fail(
115
+ 'iOSAppGroupIdentifier',
116
+ `"${appGroup}" is invalid — must match group.<reverse-dns> (letters/digits/dots/hyphens)`,
117
+ )
118
+ } else if (pushEnabled) {
119
+ reporter.warn(
120
+ 'iOSAppGroupIdentifier',
121
+ 'PushEnabled is true but no App Group set — required for the NSE/NCE rich-push extensions',
122
+ )
123
+ }
124
+ return {appGroup, pushEnabled}
125
+ }
126
+
127
+ function validateAndroidPackage(reporter, label, pkg) {
128
+ if (!pkg) {
129
+ reporter.warn(label, 'not set')
130
+ return
131
+ }
132
+ const badSegment = pkg.split('.').find((seg) => JAVA_KEYWORDS.has(seg))
133
+ if (badSegment)
134
+ reporter.fail(
135
+ label,
136
+ `"${pkg}" — segment "${badSegment}" is a Java keyword; the Android build will fail. Use a Java-safe package (the iOS bundle id may keep it).`,
137
+ )
138
+ else reporter.pass(label, pkg)
139
+ }
140
+
141
+ // Expo: identifiers live in app.json's expo block.
142
+ function checkAppJson(reporter, dir) {
143
+ const appJson = readJson(path.join(dir, 'app.json'))
144
+ if (!appJson || !appJson.expo) {
145
+ reporter.fail('app.json', 'missing or has no "expo" block')
146
+ return {}
147
+ }
148
+ const expo = appJson.expo
149
+ const androidPackage = expo.android && expo.android.package
150
+ const iosBundleId = expo.ios && expo.ios.bundleIdentifier
151
+ validateAndroidPackage(reporter, 'android.package', androidPackage)
152
+ if (iosBundleId) reporter.pass('ios.bundleIdentifier', iosBundleId)
153
+ else reporter.warn('ios.bundleIdentifier', 'not set in app.json')
154
+
155
+ // The sample ships placeholder ids; warn if they haven't been replaced. We
156
+ // only flag — setting them is the standard Expo step, owned by the developer
157
+ // (or injected by the test-automation pipeline), not rewritten by the SDK.
158
+ for (const [label, value] of [
159
+ ['ios.bundleIdentifier', iosBundleId],
160
+ ['android.package', androidPackage],
161
+ ]) {
162
+ if (value && value.startsWith(PLACEHOLDER_ID_PREFIX))
163
+ reporter.warn(
164
+ label,
165
+ `still the sample placeholder "${value}" — set your own in app.json before building (standard Expo step)`,
166
+ )
167
+ }
168
+ return {androidPackage, iosBundleId}
169
+ }
170
+
171
+ // Bare: read identifiers from android/app/build.gradle. Two distinct fields:
172
+ // - `namespace` → the R-class / Java package; MUST be a valid Java
173
+ // package (keyword check applies here).
174
+ // - `applicationId` → the published app id; may contain segments that are
175
+ // not valid Java identifiers (e.g. `new`), so it is NOT
176
+ // keyword-checked. It is what FCM matches in
177
+ // google-services.json, so it's returned for that check.
178
+ // (Expo collapses both into android.package, which is why checkAppJson
179
+ // keyword-checks that single field.)
180
+ function checkBareAndroidId(reporter, dir) {
181
+ const gradle = readText(path.join(dir, 'android', 'app', 'build.gradle'))
182
+ const namespace = gradle?.match(/namespace\s+["']([^"']+)["']/)?.[1] || null
183
+ const appId = gradle?.match(/applicationId\s+["']([^"']+)["']/)?.[1] || null
184
+ validateAndroidPackage(reporter, 'namespace', namespace)
185
+ if (appId) reporter.pass('applicationId', appId)
186
+ else reporter.warn('applicationId', 'not set')
187
+ return {androidPackage: appId}
188
+ }
189
+
190
+ // google-services.json must contain a client whose package_name matches the
191
+ // Android package (FCM matches by package); the gradle plugin fails otherwise
192
+ // ("No matching client found for package name").
193
+ function checkGoogleServices(reporter, {gsPath, androidPackage, pushEnabled}) {
194
+ if (!fileExists(gsPath)) {
195
+ if (pushEnabled)
196
+ reporter.warn(
197
+ 'google-services.json',
198
+ 'missing — required for Android FCM builds (add the Firebase Android app, then download it here)',
199
+ )
200
+ else reporter.pass('google-services.json', 'not present (push disabled)')
201
+ return
202
+ }
203
+ const gs = readJson(gsPath)
204
+ if (gs === undefined) {
205
+ reporter.fail('google-services.json', 'present but not valid JSON')
206
+ return
207
+ }
208
+ const isPlaceholder =
209
+ gs.project_info?.project_id === 'your-firebase-project-id' ||
210
+ JSON.stringify(gs).includes('REPLACE_WITH_YOUR_FIREBASE')
211
+ const packages = (gs.client || [])
212
+ .map((c) => c.client_info?.android_client_info?.package_name)
213
+ .filter(Boolean)
214
+ if (isPlaceholder)
215
+ reporter.warn(
216
+ 'google-services.json',
217
+ `placeholder values — replace with your real Firebase config (register package '${androidPackage}')`,
218
+ )
219
+ else if (androidPackage && !packages.includes(androidPackage))
220
+ reporter.fail(
221
+ 'google-services.json',
222
+ `no client matches '${androidPackage}' (has: ${packages.join(', ') || 'none'}). Register that package in Firebase and re-download.`,
223
+ )
224
+ else reporter.pass('google-services.json', 'package match')
225
+ }
226
+
227
+ // Collect *.entitlements files at most one level deep under iosDir (host +
228
+ // extension target folders), skipping Pods/build.
229
+ function findEntitlements(iosDir) {
230
+ const out = []
231
+ let entries
232
+ try {
233
+ entries = fs.readdirSync(iosDir, {withFileTypes: true})
234
+ } catch {
235
+ return out
236
+ }
237
+ for (const e of entries) {
238
+ const p = path.join(iosDir, e.name)
239
+ if (e.isFile() && e.name.endsWith('.entitlements')) out.push(p)
240
+ else if (e.isDirectory() && e.name !== 'Pods' && e.name !== 'build') {
241
+ try {
242
+ for (const f of fs.readdirSync(p))
243
+ if (f.endsWith('.entitlements')) out.push(path.join(p, f))
244
+ } catch {
245
+ /* ignore unreadable subdir */
246
+ }
247
+ }
248
+ }
249
+ return out
250
+ }
251
+
252
+ // Bare iOS only: the host entitlements must declare aps-environment + an App
253
+ // Group (the Config Plugin generates these for Expo).
254
+ function checkBareIosEntitlements(reporter, dir) {
255
+ const iosDir = path.join(dir, 'ios')
256
+ if (!fileExists(iosDir)) {
257
+ reporter.warn('ios/', 'no ios/ directory found')
258
+ return
259
+ }
260
+ const hasBoth = findEntitlements(iosDir).some((p) => {
261
+ const t = readText(p) || ''
262
+ return t.includes('aps-environment') && t.includes('application-groups')
263
+ })
264
+ if (hasBoth) reporter.pass('App entitlements (aps-environment + App Group)')
265
+ else
266
+ reporter.warn(
267
+ 'App entitlements',
268
+ 'no *.entitlements with both aps-environment and application-groups — run `acoustic-connect setup-ios-push`',
269
+ )
270
+ }
271
+
272
+ // Run all relevant checks for `dir`. Returns the Reporter (caller decides how
273
+ // to print the summary / exit).
274
+ export function runDoctor(dir, {reporter = new Reporter()} = {}) {
275
+ const type = detectProjectType(dir)
276
+ console.log(
277
+ color.bold('\nAcoustic Connect doctor') +
278
+ color.dim(` (${type} project — ${dir})`),
279
+ )
280
+
281
+ section('Prerequisites')
282
+ checkNode(reporter)
283
+
284
+ section('Configuration')
285
+ ensureConnectConfig(reporter, dir)
286
+ const {pushEnabled} = checkConnectConfigValues(reporter, dir)
287
+
288
+ section('Identifiers')
289
+ let androidPackage
290
+ if (type === 'expo') {
291
+ ;({androidPackage} = checkAppJson(reporter, dir))
292
+ } else if (type === 'bare') {
293
+ ;({androidPackage} = checkBareAndroidId(reporter, dir))
294
+ } else {
295
+ reporter.warn(
296
+ 'project type',
297
+ 'could not detect Expo or bare RN layout — skipping identifier checks',
298
+ )
299
+ }
300
+
301
+ section('Android push (FCM)')
302
+ const gsPath =
303
+ type === 'expo'
304
+ ? path.join(dir, 'google-services.json')
305
+ : path.join(dir, 'android', 'app', 'google-services.json')
306
+ checkGoogleServices(reporter, {gsPath, androidPackage, pushEnabled})
307
+
308
+ if (type === 'bare') {
309
+ section('iOS push')
310
+ checkBareIosEntitlements(reporter, dir)
311
+ }
312
+
313
+ return reporter
314
+ }
package/cli/index.mjs ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ // `acoustic-connect` — setup CLI for the React Native Acoustic Connect SDK.
3
+ //
4
+ // Ships in the published package so client apps don't have to re-implement the
5
+ // integration plumbing our own sample apps used to carry. Subcommands:
6
+ //
7
+ // acoustic-connect doctor [dir] Validate config + scaffold ConnectConfig.json
8
+ // acoustic-connect setup-ios-push [dir] Create/repair the iOS NSE + NCE push extensions
9
+ //
10
+ // `dir` defaults to the current working directory (npm passes $INIT_CWD when
11
+ // run as a script). All commands are idempotent and safe to re-run.
12
+
13
+ import path from 'node:path'
14
+
15
+ import {runDoctor} from './doctor.mjs'
16
+ import {setupIosPush} from './ios/setup-push.mjs'
17
+ import {Reporter, color} from './lib.mjs'
18
+
19
+ const USAGE = `acoustic-connect — React Native Acoustic Connect SDK setup
20
+
21
+ Usage:
22
+ acoustic-connect doctor [dir] Validate config + scaffold ConnectConfig.json
23
+ acoustic-connect setup-ios-push [dir] Create/repair the iOS NSE + NCE push extensions
24
+
25
+ dir defaults to the current directory.`
26
+
27
+ // Resolve the target directory: explicit arg > $INIT_CWD (npm) > cwd.
28
+ function targetDir(arg) {
29
+ if (arg && !arg.startsWith('-')) return path.resolve(arg)
30
+ if (process.env.INIT_CWD) return path.resolve(process.env.INIT_CWD)
31
+ return process.cwd()
32
+ }
33
+
34
+ async function main() {
35
+ const [command, maybeDir] = process.argv.slice(2)
36
+
37
+ if (!command || command === '--help' || command === '-h' || command === 'help') {
38
+ console.log(USAGE)
39
+ process.exit(command ? 0 : 1)
40
+ }
41
+
42
+ const dir = targetDir(maybeDir)
43
+
44
+ switch (command) {
45
+ case 'doctor': {
46
+ const reporter = runDoctor(dir)
47
+ process.exit(reporter.summary())
48
+ }
49
+ case 'setup-ios-push': {
50
+ const reporter = new Reporter()
51
+ await setupIosPush(dir, {reporter})
52
+ process.exit(reporter.summary())
53
+ }
54
+ default:
55
+ console.error(color.red(`Unknown command: ${command}\n`))
56
+ console.log(USAGE)
57
+ process.exit(1)
58
+ }
59
+ }
60
+
61
+ main().catch((err) => {
62
+ console.error(color.red('\nacoustic-connect crashed:'), err)
63
+ process.exit(1)
64
+ })
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # add_push_extensions.rb (SDK-shipped, parameterized)
5
+ #
6
+ # Idempotently adds the two Acoustic Connect push extensions to a host app's
7
+ # Xcode project:
8
+ #
9
+ # * ConnectNSE — Notification Service Extension (rich-media download +
10
+ # PushReceived signal logging via the App Group pending store)
11
+ # * ConnectNCE — Notification Content Extension (rich expansion UI)
12
+ #
13
+ # Both subclass the Connect SDK base classes and share the host app's App
14
+ # Group. This is the MANUAL setup path for bare React Native projects; the Expo
15
+ # Config Plugin performs the equivalent target surgery automatically for Expo
16
+ # projects.
17
+ #
18
+ # This is the generalized version that ships inside the SDK package. It is
19
+ # normally invoked by `acoustic-connect setup-ios-push` (cli/ios/setup-push.mjs),
20
+ # which derives the parameters from the project and creates the per-extension
21
+ # source/plist/entitlements files from templates BEFORE running this — this
22
+ # script only performs the pbxproj surgery and assumes those files exist.
23
+ #
24
+ # Parameters come from the environment (the Node wrapper sets them):
25
+ # ACOUSTIC_PROJECT_PATH absolute path to the .xcodeproj (required)
26
+ # ACOUSTIC_APP_TARGET host app target name (required)
27
+ # ACOUSTIC_APP_BUNDLE_ID host app bundle identifier (optional —
28
+ # falls back to the app target's
29
+ # PRODUCT_BUNDLE_IDENTIFIER)
30
+ # ACOUSTIC_DEPLOYMENT_TARGET iOS deployment target (default 15.1)
31
+ # ACOUSTIC_SWIFT_VERSION Swift version (default 5.0)
32
+ #
33
+ # Requires the `xcodeproj` gem (ships with CocoaPods).
34
+
35
+ require 'xcodeproj'
36
+
37
+ def env!(key)
38
+ value = ENV[key]
39
+ raise "#{key} is required" if value.nil? || value.empty?
40
+
41
+ value
42
+ end
43
+
44
+ PROJECT_PATH = env!('ACOUSTIC_PROJECT_PATH')
45
+ APP_TARGET_NAME = env!('ACOUSTIC_APP_TARGET')
46
+ DEPLOYMENT_TARGET = ENV.fetch('ACOUSTIC_DEPLOYMENT_TARGET', '15.1')
47
+ SWIFT_VERSION = ENV.fetch('ACOUSTIC_SWIFT_VERSION', '5.0')
48
+
49
+ EXTENSIONS = [
50
+ {
51
+ name: 'ConnectNSE',
52
+ source: 'NotificationService.swift',
53
+ suffix: 'ConnectNSE',
54
+ # UserNotifications declares the service-extension point
55
+ # (com.apple.usernotifications.service / UNNotificationServiceExtension).
56
+ frameworks: %w[UserNotifications],
57
+ },
58
+ {
59
+ name: 'ConnectNCE',
60
+ source: 'NotificationViewController.swift',
61
+ suffix: 'ConnectNCE',
62
+ # UserNotificationsUI declares the content-extension point
63
+ # (com.apple.usernotifications.content-extension) and provides the
64
+ # UNNotificationContentExtension context class. WITHOUT it the extension
65
+ # traps on first connection — "Unable to find NSExtensionContextClass
66
+ # (_UNNotificationContentExtensionVendorContext) … did you link the
67
+ # framework that declares the extension point?" — and no custom rich UI
68
+ # renders. UIKit + UserNotifications back the view controller. The Xcode
69
+ # template links these automatically; this scaffolder must do the same.
70
+ frameworks: %w[UserNotificationsUI UserNotifications UIKit],
71
+ },
72
+ ].freeze
73
+
74
+ project = Xcodeproj::Project.open(PROJECT_PATH)
75
+ app_target = project.targets.find { |t| t.name == APP_TARGET_NAME }
76
+ raise "App target #{APP_TARGET_NAME} not found in #{PROJECT_PATH}" unless app_target
77
+
78
+ # Bundle id: explicit override, else read it off the host app target so the
79
+ # extension ids (<bundle>.ConnectNSE / .ConnectNCE) match the real app.
80
+ def resolve_bundle_id(app_target)
81
+ explicit = ENV['ACOUSTIC_APP_BUNDLE_ID']
82
+ return explicit unless explicit.nil? || explicit.empty?
83
+
84
+ app_target.build_configurations
85
+ .map { |c| c.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] }
86
+ .compact
87
+ .find { |v| !v.include?('$(') }
88
+ end
89
+
90
+ APP_BUNDLE_ID = resolve_bundle_id(app_target)
91
+ raise 'Could not determine the host bundle id; pass ACOUSTIC_APP_BUNDLE_ID' unless APP_BUNDLE_ID
92
+
93
+ # 1. Wire the host app's entitlements (App Group + aps-environment) onto both
94
+ # build configurations. Safe to re-run.
95
+ app_target.build_configurations.each do |config|
96
+ config.build_settings['CODE_SIGN_ENTITLEMENTS'] =
97
+ "#{APP_TARGET_NAME}/#{APP_TARGET_NAME}.entitlements"
98
+ end
99
+
100
+ # Make the host entitlements file visible in the project navigator.
101
+ app_group = project.main_group.find_subpath(APP_TARGET_NAME, true)
102
+ ent_rel = "#{APP_TARGET_NAME}/#{APP_TARGET_NAME}.entitlements"
103
+ unless app_group.files.any? { |f| f.path == ent_rel }
104
+ app_group.new_reference(ent_rel)
105
+ end
106
+
107
+ # 2. Ensure there is an "Embed Foundation Extensions" copy-files phase on the
108
+ # app target (dstSubfolderSpec = PlugIns).
109
+ embed_phase = app_target.copy_files_build_phases.find do |p|
110
+ p.symbol_dst_subfolder_spec == :plug_ins
111
+ end
112
+ unless embed_phase
113
+ embed_phase = app_target.new_copy_files_build_phase('Embed Foundation Extensions')
114
+ embed_phase.symbol_dst_subfolder_spec = :plug_ins
115
+ end
116
+
117
+ EXTENSIONS.each do |ext|
118
+ if project.targets.any? { |t| t.name == ext[:name] }
119
+ puts "#{ext[:name]}: target already exists — skipping creation."
120
+ next
121
+ end
122
+
123
+ puts "#{ext[:name]}: creating app-extension target."
124
+ target = project.new_target(
125
+ :app_extension,
126
+ ext[:name],
127
+ :ios,
128
+ DEPLOYMENT_TARGET,
129
+ nil,
130
+ :swift
131
+ )
132
+
133
+ # Group + source file (added to the Compile Sources phase).
134
+ group = project.main_group.find_subpath(ext[:name], true)
135
+ source_ref = group.new_reference("#{ext[:name]}/#{ext[:source]}")
136
+ target.add_file_references([source_ref])
137
+ # Info.plist + entitlements are referenced via build settings only — add as
138
+ # plain references for navigator visibility (not compiled / copied).
139
+ group.new_reference("#{ext[:name]}/Info.plist")
140
+ group.new_reference("#{ext[:name]}/#{ext[:suffix]}.entitlements")
141
+
142
+ target.build_configurations.each do |config|
143
+ bs = config.build_settings
144
+ bs['PRODUCT_BUNDLE_IDENTIFIER'] = "#{APP_BUNDLE_ID}.#{ext[:suffix]}"
145
+ bs['PRODUCT_NAME'] = '$(TARGET_NAME)'
146
+ bs['INFOPLIST_FILE'] = "#{ext[:name]}/Info.plist"
147
+ bs['GENERATE_INFOPLIST_FILE'] = 'NO'
148
+ bs['CODE_SIGN_ENTITLEMENTS'] = "#{ext[:name]}/#{ext[:suffix]}.entitlements"
149
+ bs['CODE_SIGN_STYLE'] = 'Automatic'
150
+ bs['IPHONEOS_DEPLOYMENT_TARGET'] = DEPLOYMENT_TARGET
151
+ bs['SWIFT_VERSION'] = SWIFT_VERSION
152
+ bs['SKIP_INSTALL'] = 'YES'
153
+ bs['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
154
+ bs['CLANG_ENABLE_MODULES'] = 'YES'
155
+ bs['MARKETING_VERSION'] = '1.0'
156
+ bs['CURRENT_PROJECT_VERSION'] = '1'
157
+ bs['TARGETED_DEVICE_FAMILY'] = '1,2'
158
+ bs['LD_RUNPATH_SEARCH_PATHS'] = [
159
+ '$(inherited)',
160
+ '@executable_path/Frameworks',
161
+ '@executable_path/../../Frameworks',
162
+ ]
163
+ end
164
+
165
+ # App depends on the extension and embeds it in PlugIns.
166
+ app_target.add_dependency(target)
167
+ build_file = embed_phase.add_file_reference(target.product_reference)
168
+ build_file.settings = { 'ATTRIBUTES' => ['RemoveHeadersOnCopy'] }
169
+ puts "#{ext[:name]}: target created, embedded, and added as app dependency."
170
+ end
171
+
172
+ # 3. Ensure each extension links the system frameworks that declare its
173
+ # extension point. Runs every time (also repairs pre-existing targets that
174
+ # were created before this step was added), and is idempotent — a framework
175
+ # already in the Link Binary phase is left untouched.
176
+ EXTENSIONS.each do |ext|
177
+ target = project.targets.find { |t| t.name == ext[:name] }
178
+ next unless target
179
+
180
+ linked = target.frameworks_build_phase.files.map(&:display_name)
181
+ Array(ext[:frameworks]).each do |fw|
182
+ if linked.include?("#{fw}.framework")
183
+ puts "#{ext[:name]}: #{fw}.framework already linked."
184
+ else
185
+ target.add_system_framework(fw)
186
+ puts "#{ext[:name]}: linked #{fw}.framework."
187
+ end
188
+ end
189
+ end
190
+
191
+ project.save
192
+ puts "Saved #{PROJECT_PATH}"
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # connect_pods.rb — shared CocoaPods helper for the Acoustic Connect SDK.
4
+ #
5
+ # Ships in the published package so consumer Podfiles don't have to re-implement
6
+ # the Connect SDK pod resolution. Mirrors AcousticConnectRN.podspec so the host
7
+ # app target and the push extensions (ConnectNSE / ConnectNCE) all link the SAME
8
+ # SDK build:
9
+ # - useRelease => 'AcousticConnect', otherwise 'AcousticConnectDebug'
10
+ # - floor '>= 2.1.12' (the push permission API floor)
11
+ # - optional exact pin via Connect.iOSVersion
12
+ #
13
+ # Usage from a Podfile (resolve the file the same way the RN template resolves
14
+ # react_native_pods.rb):
15
+ #
16
+ # require Pod::Executable.execute_command('node', ['-p',
17
+ # 'require.resolve("react-native-acoustic-connect-beta/cli/ios/connect_pods.rb", {paths: [process.argv[1]]})',
18
+ # __dir__]).strip
19
+ #
20
+ # target 'MyApp' do
21
+ # # ...
22
+ # pod *acoustic_connect_pod(__dir__)
23
+ # end
24
+ # target 'ConnectNSE' do
25
+ # pod *acoustic_connect_pod(__dir__)
26
+ # end
27
+ #
28
+ # ConnectConfig.json is resolved at <podfile_dir>/../ConnectConfig.json (the
29
+ # consumer app root), matching where the podspec and config.gradle read it.
30
+
31
+ require 'json'
32
+
33
+ # Returns [pod_name, requirements_array] for `pod *acoustic_connect_pod(__dir__)`.
34
+ #
35
+ # podfile_dir : the Podfile's own directory (pass `__dir__`). ConnectConfig.json
36
+ # is read from its parent, i.e. the app root.
37
+ # config_path : optional explicit path to ConnectConfig.json (overrides the
38
+ # default lookup).
39
+ def acoustic_connect_pod(podfile_dir, config_path: nil)
40
+ path = config_path || File.join(podfile_dir, '..', 'ConnectConfig.json')
41
+ connect_config = JSON.parse(File.read(path))['Connect'] || {}
42
+ use_release = connect_config['useRelease']
43
+ ios_version = connect_config['iOSVersion'].to_s
44
+ name = use_release ? 'AcousticConnect' : 'AcousticConnectDebug'
45
+ floor = '>= 2.1.12'
46
+ requirements = ios_version.empty? ? [floor] : [floor, ios_version]
47
+ [name, requirements]
48
+ end