@smileid/usesmileid_vision_document 12.0.1 → 12.1.0

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.
@@ -1,102 +1,16 @@
1
- "use strict";
2
- // Injects an idempotent Ruby block into the Expo-generated Podfile's
3
- // `post_install` hook. The block runs at `pod install` time and wires
4
- // the Smile ID Swift Package into the autogenerated Pods.xcodeproj
5
- // for a specific bridge pod target — Pods.xcodeproj only exists at
6
- // pod-install time, so this is the only hook that can mutate it.
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.injectPodfileSpmBlock = injectPodfileSpmBlock;
9
- const BEGIN_PREFIX = "# === BEGIN smileid-spm:";
10
- const END_PREFIX = "# === END smileid-spm:";
11
- /**
12
- * Idempotently injects an SPM-linking Ruby block into the Podfile's
13
- * top-level `post_install` block. Re-running on an already-injected
14
- * Podfile rewrites the same marker block in place (so version /
15
- * product changes flow through cleanly on the next prebuild).
16
- */
17
- function injectPodfileSpmBlock(podfile, options) {
18
- validateRubySafe(options);
19
- const block = renderBlock(options);
20
- const beginMarker = `${BEGIN_PREFIX} ${options.marker} ===`;
21
- const endMarker = `${END_PREFIX} ${options.marker} ===`;
22
- const blockRegex = new RegExp(`${escapeRegExp(beginMarker)}[\\s\\S]*?${escapeRegExp(endMarker)}`, "m");
23
- if (blockRegex.test(podfile)) {
24
- return podfile.replace(blockRegex, block);
25
- }
26
- // Inject at the *start* of the post_install body — right after
27
- // `post_install do |installer|`. We tried matching the closing
28
- // `end` pair instead, but a second plugin running on a Podfile
29
- // already mutated by the first sees a non-flat body and the
30
- // non-greedy `end…end` match latches onto inner block ends,
31
- // nesting the second injection inside the first. Anchoring on
32
- // the opening line removes that failure mode entirely. Order
33
- // relative to `react_native_post_install` doesn't matter because
34
- // CocoaPods persists the Pods project at the end of pod install
35
- // regardless of what we explicitly save mid-block.
36
- const headerRegex = /(post_install\s+do\s*\|\s*installer\s*\|)\r?\n/;
37
- const headerMatch = podfile.match(headerRegex);
38
- if (!headerMatch || headerMatch.index === undefined) {
39
- throw new Error("[smileid-spm] Could not locate `post_install do |installer|` in Podfile. " +
40
- "Refusing to append a top-level post_install hook because CocoaPods only honors one — adding a second " +
41
- "would silently override the React Native post-install plumbing. Restore the Expo Podfile template " +
42
- "or wire the SPM block in manually.");
43
- }
44
- const insertAt = headerMatch.index + headerMatch[0].length;
45
- const indented = block
46
- .split("\n")
47
- .map((line) => (line.length > 0 ? ` ${line}` : line))
48
- .join("\n") + "\n";
49
- return podfile.slice(0, insertAt) + indented + podfile.slice(insertAt);
50
- }
51
- // All injected strings flow into single-quoted Ruby literals. We
52
- // reject characters that could break out of those literals so a
53
- // typo in the bridge plugin can't produce code that runs during
54
- // `pod install`. Rejected: single-quote, backslash, control chars.
55
- function validateRubySafe(options) {
56
- const fields = [
57
- ["marker", options.marker],
58
- ["package.url", options.package.url],
59
- ["podTarget", options.podTarget],
60
- ];
61
- for (const product of options.products) {
62
- fields.push(["products[*]", product]);
63
- }
64
- switch (options.package.requirement.kind) {
65
- case "upToNextMajorVersion":
66
- case "upToNextMinorVersion":
67
- fields.push([
68
- "requirement.minimumVersion",
69
- options.package.requirement.minimumVersion,
70
- ]);
71
- break;
72
- case "exactVersion":
73
- fields.push(["requirement.version", options.package.requirement.version]);
74
- break;
75
- case "branch":
76
- fields.push(["requirement.branch", options.package.requirement.branch]);
77
- break;
78
- }
79
- for (const [name, value] of fields) {
80
- if (/['\\\n\r\t]/.test(value)) {
81
- throw new Error(`[smileid-spm] Refusing to inject Podfile block: '${name}' contains an unsafe character (got: ${JSON.stringify(value)}).`);
82
- }
83
- }
84
- }
85
- function renderBlock(options) {
86
- const beginMarker = `${BEGIN_PREFIX} ${options.marker} ===`;
87
- const endMarker = `${END_PREFIX} ${options.marker} ===`;
88
- const requirement = renderRequirement(options.package.requirement);
89
- const productList = options.products.map((p) => `'${p}'`).join(", ");
90
- return `${beginMarker}
91
- # Wires ${options.package.url} into Pods.xcodeproj and links its
92
- # products to the '${options.podTarget}' pod target so the Swift
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.injectPodfileSpmBlock=injectPodfileSpmBlock,exports.injectPodfileKameraLinkBlock=injectPodfileKameraLinkBlock,exports.injectPodfileSignatureDedupBlock=injectPodfileSignatureDedupBlock;const signature_dedup_1=require("./signature_dedup"),BEGIN_PREFIX="# === BEGIN smileid-spm:",END_PREFIX="# === END smileid-spm:",SIGNATURE_DEDUP_MARKER="usesmileid_signature_dedup",KAMERA_LINK_MARKER="kamera_spm";function injectPodfileSpmBlock(e,r){return validateRubySafe(r),injectMarkerBlock(e,r.marker,renderBlock(r))}function injectPodfileKameraLinkBlock(e){return injectMarkerBlock(e,KAMERA_LINK_MARKER,renderKameraLinkBlock())}function injectPodfileSignatureDedupBlock(e){return injectMarkerBlock(e,SIGNATURE_DEDUP_MARKER,renderSignatureDedupBlock())}function injectMarkerBlock(e,r,a){const t=`${BEGIN_PREFIX} ${r} ===`,n=`${END_PREFIX} ${r} ===`,s=new RegExp(`([ \\t]*)${escapeRegExp(t)}[\\s\\S]*?${escapeRegExp(n)}`,"m"),o=e.match(s);if(o)return e.replace(s,()=>indentBlock(a,o[1]??""));const p=/(post_install\s+do\s*\|\s*installer\s*\|)\r?\n/,i=e.match(p);if(!i||i.index===void 0)throw new Error("[smileid-spm] Could not locate `post_install do |installer|` in Podfile. Refusing to append a top-level post_install hook because CocoaPods only honors one \u2014 adding a second would silently override the React Native post-install plumbing. Restore the Expo Podfile template or wire the SPM block in manually.");const d=i.index+i[0].length,c=`${indentBlock(a," ")}
2
+ `;return e.slice(0,d)+c+e.slice(d)}function indentBlock(e,r){return e.split(`
3
+ `).map(a=>a.length>0?`${r}${a}`:a).join(`
4
+ `)}function validateRubySafe(e){const r=[["marker",e.marker],["package.url",e.package.url],["podTarget",e.podTarget]];for(const a of e.products)r.push(["products[*]",a]);switch(e.package.requirement.kind){case"upToNextMajorVersion":case"upToNextMinorVersion":r.push(["requirement.minimumVersion",e.package.requirement.minimumVersion]);break;case"exactVersion":r.push(["requirement.version",e.package.requirement.version]);break;case"branch":r.push(["requirement.branch",e.package.requirement.branch]);break}for(const[a,t]of r)if(/['"#\\\n\r\t]/.test(t))throw new Error(`[smileid-spm] Refusing to inject Podfile block: '${a}' contains an unsafe character (got: ${JSON.stringify(t)}).`)}function renderBlock(e){const r=`${BEGIN_PREFIX} ${e.marker} ===`,a=`${END_PREFIX} ${e.marker} ===`,t=renderRequirement(e.package.requirement),n=e.products.map(o=>`'${o}'`).join(", "),s=e.required?`raise "[smileid-spm] Pod target #{target_name} is missing from Pods.xcodeproj, so #{product_names.join(', ')} cannot be linked and the Smile ID bridge will not compile. Check that '@smileid/usesmileid_bridge' is installed and that its npm package ships its 'ios' directory."`:'Pod::UI.warn "[smileid-spm] Pod target #{target_name} not found; skipping SPM link."';return`${r}
5
+ # Wires ${e.package.url} into Pods.xcodeproj and links its
6
+ # products to the '${e.podTarget}' pod target so the Swift
93
7
  # bridge code can \`import\` them. Idempotent across pod installs.
94
8
  #
95
9
  # UUIDs are minted via SecureRandom rather than \`pods_project.new\`
96
10
  # because \`prepare_react_native_project!\` sets
97
11
  # \`:deterministic_uuids => false\`. With that flag off, CocoaPods
98
12
  # skips its predictabilize step and \`stabilize_target_uuids\` resets
99
- # \`@generated_uuids\` to a tiny leftover pool — so any post_install
13
+ # \`@generated_uuids\` to a tiny leftover pool \u2014 so any post_install
100
14
  # call to \`pods_project.new\` restarts the sequential index near 0
101
15
  # and re-mints UUIDs already in use. The collision then runs through
102
16
  # \`add_referrer\`, which clobbers \`objects_by_uuid[uuid]\` and
@@ -106,10 +20,10 @@ function renderBlock(options) {
106
20
  # hex IDs can't collide with the 14-char cocoapods scheme.
107
21
  begin
108
22
  pods_project = installer.pods_project
109
- spm_url = '${options.package.url}'
110
- spm_requirement = ${requirement}
111
- product_names = [${productList}]
112
- target_name = '${options.podTarget}'
23
+ spm_url = '${e.package.url}'
24
+ spm_requirement = ${t}
25
+ product_names = [${n}]
26
+ target_name = '${e.podTarget}'
113
27
 
114
28
  smileid_spm_safe_uuid = lambda do |project|
115
29
  loop do
@@ -132,7 +46,7 @@ begin
132
46
 
133
47
  target = pods_project.targets.find { |t| t.name == target_name }
134
48
  if target.nil?
135
- Pod::UI.warn "[smileid-spm] Pod target #{target_name} not found; skipping SPM link."
49
+ ${s}
136
50
  else
137
51
  product_names.each do |product_name|
138
52
  already = target.package_product_dependencies.any? do |d|
@@ -153,28 +67,184 @@ begin
153
67
  bf.product_ref = dep
154
68
  target.frameworks_build_phase.files << bf
155
69
  end
70
+
71
+ # Every linking static pod absorbs ios-spm's source-target objects and the
72
+ # app's -ObjC link then sees duplicates \u2014 the app keeps the single copy.
73
+ strip_name = '[smileid-spm] Strip absorbed SPM source objects'
74
+ unless target.shell_script_build_phases.any? { |p| p.name == strip_name }
75
+ # \`new_shell_script_build_phase\` mints through \`pods_project.new\`, whose
76
+ # reset index (see above) hands out 46EB2E00000000 \u2014 the rootObject's own
77
+ # UUID \u2014 and the overwrite makes Xcode reject the project as damaged.
78
+ phase_uuid = smileid_spm_safe_uuid.call(pods_project)
79
+ phase = Xcodeproj::Project::Object::PBXShellScriptBuildPhase.new(pods_project, phase_uuid)
80
+ phase.initialize_defaults
81
+ phase.name = strip_name
82
+ target.build_phases << phase
83
+ phase.shell_script = <<~'STRIPSH'
84
+ set -u
85
+ A="\${TARGET_BUILD_DIR}/\${EXECUTABLE_PATH}"
86
+ [ -f "$A" ] || exit 0
87
+ strip_obj() {
88
+ ar -t "$1" 2>/dev/null | grep -q "^$2$" || return 0
89
+ ar -d "$1" "$2" && ranlib "$1" 2>/dev/null || true
90
+ }
91
+ ARCHS_IN=$(lipo -archs "$A" 2>/dev/null || true)
92
+ for OBJ in UseSmileIDSentrySupport.o UseSmileIDLottieSupport.o UseSmileIDKameraSupport.o; do
93
+ if [ "$(echo "$ARCHS_IN" | wc -w)" -gt 1 ]; then
94
+ THIN=""
95
+ for ARCH in $ARCHS_IN; do
96
+ lipo -thin "$ARCH" "$A" -output "$A.$ARCH"
97
+ strip_obj "$A.$ARCH" "$OBJ"
98
+ THIN="$THIN $A.$ARCH"
99
+ done
100
+ lipo -create $THIN -output "$A"
101
+ rm -f $THIN
102
+ else
103
+ strip_obj "$A" "$OBJ"
104
+ fi
105
+ done
106
+ STRIPSH
107
+ end
156
108
  end
157
109
 
158
110
  pods_project.save
159
111
  rescue => e
160
- Pod::UI.warn "[smileid-spm] Failed to link SPM products for ${options.podTarget}: #{e.message}"
112
+ Pod::UI.warn "[smileid-spm] Failed to link SPM products for ${e.podTarget}: #{e.message}"
113
+ raise
114
+ end
115
+ ${a}`}function renderKameraLinkBlock(){return`${BEGIN_PREFIX} ${KAMERA_LINK_MARKER} ===
116
+ # Links kamera-spm's Kamera / KameraVision products into the kamera-rn pod target (and
117
+ # KameraTesting into kamera-testing when present) with the helper @smileid/kamera ships,
118
+ # pinned at the installed package's own version. The Smile ID SDK binaries link
119
+ # Kamera.framework dynamically and ios-spm declares kamera-spm for the app, so the pod
120
+ # must take Kamera from that same package rather than vendor a second copy.
121
+ require 'json'
122
+ require 'securerandom'
123
+ begin
124
+ kamera_package_json = \`node --print "require.resolve('@smileid/kamera/package.json')"\`.strip
125
+ if kamera_package_json.empty?
126
+ raise "[smileid-spm] @smileid/kamera is not installed, so its kamera-rn pod cannot be linked to kamera-spm."
127
+ end
128
+ kamera_spm_helper = File.join(File.dirname(kamera_package_json), 'ios', 'kamera_spm_link.rb')
129
+ if File.exist?(kamera_spm_helper)
130
+ require kamera_spm_helper
131
+ # The Smile ID provider pods import Kamera themselves. A SwiftPM product linked into the
132
+ # kamera-rn target does not reach the pods that depend on it the way a vendored framework's
133
+ # search path did, so those targets take the product directly (absent ones are skipped).
134
+ kamera_spm_link!(installer, targets: KAMERA_SPM_TARGETS.merge(
135
+ 'UseSmileIDVisionFaceExpo' => %w[Kamera],
136
+ 'UseSmileIDVisionDocumentExpo' => %w[Kamera],
137
+ ))
138
+ # Two things only the app's own project can do, exactly as it does for ios-spm:
139
+ # 1. CocoaPods rewrites the Pods project after post_install and drops the package
140
+ # references the helper attaches to it (the product dependencies survive), so Xcode
141
+ # resolves kamera-spm only if a project in the workspace still lists it \u2014 otherwise
142
+ # the build stops at "Missing package product 'Kamera'".
143
+ # 2. Kamera and KameraVision are dynamic frameworks. Linked into static pod targets they
144
+ # are never embedded, and the app dies in dyld ("Library not loaded:
145
+ # @rpath/Kamera.framework/Kamera"). Xcode embeds a binary product only for an app
146
+ # target that depends on it, so the app target takes both products directly.
147
+ kamera_spm_url = 'https://github.com/smileidentity/kamera-spm'
148
+ kamera_spm_version = JSON.parse(File.read(kamera_package_json))['version'].sub(/-SNAPSHOT.*$/, '')
149
+ kamera_spm_app_products = %w[Kamera KameraVision]
150
+ # A reference an app added by hand may spell the same repository differently (.git suffix,
151
+ # trailing slash, case); a second reference to one repository fails Xcode's resolution.
152
+ normalize_url = ->(url) { url.to_s.downcase.chomp('/').sub(/\\.git\\z/, '') }
153
+ installer.aggregate_targets.group_by(&:user_project).each do |user_project, aggregate_targets|
154
+ next if user_project.nil? # integrate_targets: false \u2014 nothing to register on
155
+ # SecureRandom, not user_project.new: React Native's prepare_react_native_project!
156
+ # leaves Xcodeproj's UUID pool unusable for objects minted in post_install.
157
+ new_uuid = lambda do
158
+ loop do
159
+ candidate = SecureRandom.hex(12).upcase
160
+ break candidate unless user_project.objects_by_uuid.key?(candidate)
161
+ end
162
+ end
163
+ changed = false
164
+ ref = user_project.root_object.package_references.find do |r|
165
+ r.respond_to?(:repositoryURL) && normalize_url.call(r.repositoryURL) == normalize_url.call(kamera_spm_url)
166
+ end
167
+ unless ref
168
+ ref = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference.new(user_project, new_uuid.call)
169
+ ref.initialize_defaults
170
+ ref.repositoryURL = kamera_spm_url
171
+ user_project.root_object.package_references << ref
172
+ changed = true
173
+ end
174
+ requirement = { 'kind' => 'exactVersion', 'version' => kamera_spm_version }
175
+ if ref.requirement != requirement
176
+ ref.requirement = requirement
177
+ changed = true
178
+ end
179
+ app_targets = aggregate_targets.flat_map(&:user_targets).uniq.select do |t|
180
+ t.respond_to?(:product_type) && t.product_type == 'com.apple.product-type.application'
181
+ end
182
+ app_targets.each do |app_target|
183
+ kamera_spm_app_products.each do |product_name|
184
+ next if app_target.package_product_dependencies.any? { |d| d.package == ref && d.product_name == product_name }
185
+ dep = Xcodeproj::Project::Object::XCSwiftPackageProductDependency.new(user_project, new_uuid.call)
186
+ dep.initialize_defaults
187
+ dep.package = ref
188
+ dep.product_name = product_name
189
+ app_target.package_product_dependencies << dep
190
+ build_file = Xcodeproj::Project::Object::PBXBuildFile.new(user_project, new_uuid.call)
191
+ build_file.initialize_defaults
192
+ build_file.product_ref = dep
193
+ app_target.frameworks_build_phase.files << build_file
194
+ changed = true
195
+ end
196
+ end
197
+ next unless changed
198
+ user_project.save
199
+ Pod::UI.puts "[smileid-spm] #{File.basename(user_project.path)}: #{app_targets.map(&:name).join(', ')} link kamera-spm #{kamera_spm_version} (#{kamera_spm_app_products.join(', ')}) so Xcode resolves and embeds it"
200
+ end
201
+ else
202
+ # Releases before the helper vendor Kamera.xcframework themselves, so the pod still
203
+ # compiles; but the app then embeds that copy next to the one ios-spm resolves.
204
+ Pod::UI.warn "[smileid-spm] @smileid/kamera at #{File.dirname(kamera_package_json)} ships no ios/kamera_spm_link.rb " \\
205
+ "(it still vendors Kamera.xcframework). Upgrade to a release that depends on kamera-spm so the app carries one Kamera.framework."
206
+ end
207
+ rescue => e
208
+ Pod::UI.warn "[smileid-spm] Failed to link kamera-spm into the kamera pods: #{e.message}"
209
+ raise
210
+ end
211
+ ${END_PREFIX} ${KAMERA_LINK_MARKER} ===`}function renderSignatureDedupBlock(){return`${BEGIN_PREFIX} ${SIGNATURE_DEDUP_MARKER} ===
212
+ # For apps whose \`ios/\` is hand-maintained, so no config plugin ever runs.
213
+ # UUIDs come from SecureRandom for the same reason as above.
214
+ begin
215
+ dedup_name = '${signature_dedup_1.SIGNATURE_DEDUP_PHASE_NAME}'
216
+ smileid_dedup_safe_uuid = lambda do |project|
217
+ loop do
218
+ candidate = SecureRandom.hex(12).upcase
219
+ return candidate unless project.objects_by_uuid.key?(candidate)
220
+ end
221
+ end
222
+
223
+ installer.aggregate_targets.each do |aggregate_target|
224
+ user_project = aggregate_target.user_project
225
+ next unless user_project
226
+
227
+ added = false
228
+ aggregate_target.user_targets.each do |user_target|
229
+ next if user_target.shell_script_build_phases.any? { |p| p.name == dedup_name }
230
+
231
+ phase = Xcodeproj::Project::Object::PBXShellScriptBuildPhase.new(
232
+ user_project, smileid_dedup_safe_uuid.call(user_project)
233
+ )
234
+ phase.initialize_defaults
235
+ phase.name = dedup_name
236
+ phase.always_out_of_date = '1'
237
+ phase.shell_script = <<~'SMILEIDDEDUP'
238
+ ${indentBlock(signature_dedup_1.SIGNATURE_DEDUP_SCRIPT," ")}
239
+ SMILEIDDEDUP
240
+ user_target.build_phases << phase
241
+ added = true
242
+ end
243
+
244
+ user_project.save if added
245
+ end
246
+ rescue => e
247
+ Pod::UI.warn "[smileid-spm] Failed to add the XCFramework signature dedup phase: #{e.message}"
161
248
  raise
162
249
  end
163
- ${endMarker}`;
164
- }
165
- function renderRequirement(req) {
166
- switch (req.kind) {
167
- case "upToNextMajorVersion":
168
- return `{ kind: 'upToNextMajorVersion', minimumVersion: '${req.minimumVersion}' }`;
169
- case "upToNextMinorVersion":
170
- return `{ kind: 'upToNextMinorVersion', minimumVersion: '${req.minimumVersion}' }`;
171
- case "exactVersion":
172
- return `{ kind: 'exactVersion', version: '${req.version}' }`;
173
- case "branch":
174
- return `{ kind: 'branch', branch: '${req.branch}' }`;
175
- }
176
- }
177
- function escapeRegExp(s) {
178
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
179
- }
180
- //# sourceMappingURL=podfile.js.map
250
+ ${END_PREFIX} ${SIGNATURE_DEDUP_MARKER} ===`}function renderRequirement(e){switch(e.kind){case"upToNextMajorVersion":return`{ kind: 'upToNextMajorVersion', minimumVersion: '${e.minimumVersion}' }`;case"upToNextMinorVersion":return`{ kind: 'upToNextMinorVersion', minimumVersion: '${e.minimumVersion}' }`;case"exactVersion":return`{ kind: 'exactVersion', version: '${e.version}' }`;case"branch":return`{ kind: 'branch', branch: '${e.branch}' }`}}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
@@ -0,0 +1,14 @@
1
+ import { XcodeProject } from "expo/config-plugins";
2
+ export declare const SIGNATURE_DEDUP_PHASE_NAME = "[smileid-spm] Dedupe XCFramework signatures";
3
+ export declare const SIGNATURE_DEDUP_SCRIPT: string;
4
+ /**
5
+ * Appends the dedup phase, idempotently by name so both vision plugins and
6
+ * repeated prebuilds converge on one. It goes last because every pod target
7
+ * must have staged its signatures before it runs.
8
+ */
9
+ export declare function ensureSignatureDedupPhase(project: XcodeProject, targetName: string): void;
10
+ /**
11
+ * Stops Xcode recording XCFramework signatures at all — the escape hatch behind
12
+ * `iosSignatureAggregation: "disabled"`.
13
+ */
14
+ export declare function disableSignatureAggregation(project: XcodeProject, targetName: string): void;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SIGNATURE_DEDUP_SCRIPT=exports.SIGNATURE_DEDUP_PHASE_NAME=void 0,exports.ensureSignatureDedupPhase=ensureSignatureDedupPhase,exports.disableSignatureAggregation=disableSignatureAggregation;const spm_1=require("./spm");exports.SIGNATURE_DEDUP_PHASE_NAME="[smileid-spm] Dedupe XCFramework signatures",exports.SIGNATURE_DEDUP_SCRIPT=["# Archive assembly sweeps staged *.signature files into one filename-keyed","# folder and aborts on the first duplicate; keep exactly one per name.","set -u",'case "${BUILT_PRODUCTS_DIR:-}" in'," */ArchiveIntermediates/*) ;;"," *) exit 0 ;;","esac",'seen=" "','for sig in "${BUILT_PRODUCTS_DIR}"/*/*.xcframework-*.signature; do',' [ -e "$sig" ] || continue',' name=$(basename "$sig")',' if [ -e "${BUILT_PRODUCTS_DIR}/${name}" ]; then',' rm -rf "$sig"'," else",' case "$seen" in',' *" ${name} "*) rm -rf "$sig" ;;',' *) seen="${seen}${name} " ;;'," esac"," fi","done","exit 0"].join(`
2
+ `);function ensureSignatureDedupPhase(e,i){const s=(0,spm_1.findNativeTarget)(e,i);if(!s)throw new Error(`[smileid-spm] Native target '${i}' not found in Xcode project.`);const t=(0,spm_1.section)(e,"PBXShellScriptBuildPhase");if(s.obj.buildPhases.some(n=>{const o=t[n.value];return o!==void 0&&typeof o=="object"&&o!==null&&o.name?.replace(/^"|"$/g,"")===exports.SIGNATURE_DEDUP_PHASE_NAME}))return;const r=(0,spm_1.generateUuid)(e);t[r]={isa:"PBXShellScriptBuildPhase",name:`"${exports.SIGNATURE_DEDUP_PHASE_NAME}"`,shellPath:"/bin/sh",shellScript:JSON.stringify(exports.SIGNATURE_DEDUP_SCRIPT),alwaysOutOfDate:"1",buildActionMask:"2147483647",files:[],inputPaths:[],outputPaths:[],runOnlyForDeploymentPostprocessing:"0"},t[`${r}_comment`]=exports.SIGNATURE_DEDUP_PHASE_NAME,s.obj.buildPhases.push({value:r,comment:exports.SIGNATURE_DEDUP_PHASE_NAME})}function disableSignatureAggregation(e,i){const s=(0,spm_1.findNativeTarget)(e,i);if(!s)throw new Error(`[smileid-spm] Native target '${i}' not found in Xcode project.`);const t=s.obj.buildConfigurationList;if(!t)throw new Error(`[smileid-spm] Native target '${i}' has no build configuration list.`);const u=(0,spm_1.section)(e,"XCConfigurationList"),r=(0,spm_1.section)(e,"XCBuildConfiguration"),n=u[t];if(!n||typeof n!="object"||!n.buildConfigurations)throw new Error(`[smileid-spm] Build configuration list for '${i}' is unreadable.`);for(const o of n.buildConfigurations){const a=r[o.value];!a||typeof a!="object"||(a.buildSettings??={},a.buildSettings.ENABLE_SIGNATURE_AGGREGATION="NO")}}
@@ -1,4 +1,4 @@
1
- import { XcodeProject } from "@expo/config-plugins";
1
+ import { XcodeProject } from "expo/config-plugins";
2
2
  export interface SpmPackage {
3
3
  /** Remote git URL of the Swift Package, e.g. `https://github.com/smileidentity/ios-spm`. */
4
4
  url: string;
@@ -31,3 +31,24 @@ export interface SpmTargetLink {
31
31
  * multiple plugins can compose without conflict.
32
32
  */
33
33
  export declare function linkSpmPackage(project: XcodeProject, pkg: SpmPackage, link: SpmTargetLink): void;
34
+ export interface NativeTarget {
35
+ uuid: string;
36
+ obj: PbxNativeTarget;
37
+ }
38
+ interface PbxNativeTarget {
39
+ isa: "PBXNativeTarget";
40
+ name: string;
41
+ packageProductDependencies?: Array<{
42
+ value: string;
43
+ comment?: string;
44
+ }>;
45
+ buildPhases: Array<{
46
+ value: string;
47
+ comment?: string;
48
+ }>;
49
+ buildConfigurationList?: string;
50
+ }
51
+ export declare function section<T>(project: XcodeProject, isa: string): Record<string, T>;
52
+ export declare function generateUuid(project: XcodeProject): string;
53
+ export declare function findNativeTarget(project: XcodeProject, name: string): NativeTarget | undefined;
54
+ export {};
@@ -1,196 +1 @@
1
- "use strict";
2
- // Shared plumbing for wiring a remote Swift Package into both the
3
- // consuming Expo app's Xcode project and the autogenerated CocoaPods
4
- // project for a specific bridge pod target.
5
- //
6
- // Why this exists: `expo-modules-autolinking@55.0.x`'s
7
- // `RawModuleConfigApple` schema does not surface a `dependencies`
8
- // field, so listing SPM products in `expo-module.config.json` is a
9
- // silent no-op. This module fills that gap.
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.linkSpmPackage = linkSpmPackage;
12
- /**
13
- * Adds (or reuses) a remote Swift Package reference on the given
14
- * Xcode project and links the requested products to the target.
15
- * Idempotent: existing package refs and product deps are reused so
16
- * multiple plugins can compose without conflict.
17
- */
18
- function linkSpmPackage(project, pkg, link) {
19
- const pkgRef = upsertPackageReference(project, pkg);
20
- const target = findNativeTarget(project, link.targetName);
21
- if (!target) {
22
- throw new Error(`[smileid-spm] Native target '${link.targetName}' not found in Xcode project.`);
23
- }
24
- for (const product of link.products) {
25
- upsertProductDependency(project, target.uuid, pkgRef, product);
26
- }
27
- }
28
- function objects(project) {
29
- const hash = project.hash.project.objects;
30
- return hash;
31
- }
32
- function section(project, isa) {
33
- const objs = objects(project);
34
- if (!objs[isa]) {
35
- objs[isa] = {};
36
- }
37
- return objs[isa];
38
- }
39
- function generateUuid(project) {
40
- return project.generateUuid();
41
- }
42
- function upsertPackageReference(project, pkg) {
43
- const refs = section(project, "XCRemoteSwiftPackageReference");
44
- for (const [uuid, ref] of Object.entries(refs)) {
45
- if (uuid.endsWith("_comment"))
46
- continue;
47
- if (typeof ref !== "object" || ref === null)
48
- continue;
49
- if (ref.repositoryURL?.replace(/^"|"$/g, "") === pkg.url) {
50
- return { uuid };
51
- }
52
- }
53
- const uuid = generateUuid(project);
54
- refs[uuid] = {
55
- isa: "XCRemoteSwiftPackageReference",
56
- repositoryURL: `"${pkg.url}"`,
57
- requirement: serializeRequirement(pkg.requirement),
58
- };
59
- refs[`${uuid}_comment`] =
60
- `XCRemoteSwiftPackageReference "${repoName(pkg.url)}"`;
61
- // Attach to the PBXProject's packageReferences list.
62
- const projectSection = section(project, "PBXProject");
63
- for (const [projUuid, proj] of Object.entries(projectSection)) {
64
- if (projUuid.endsWith("_comment"))
65
- continue;
66
- if (typeof proj !== "object" || proj === null)
67
- continue;
68
- if (proj.isa !== "PBXProject")
69
- continue;
70
- proj.packageReferences ??= [];
71
- if (!proj.packageReferences.some((r) => r.value === uuid)) {
72
- proj.packageReferences.push({
73
- value: uuid,
74
- comment: `XCRemoteSwiftPackageReference "${repoName(pkg.url)}"`,
75
- });
76
- }
77
- }
78
- return { uuid };
79
- }
80
- function upsertProductDependency(project, targetUuid, pkgRef, productName) {
81
- const targetSection = section(project, "PBXNativeTarget");
82
- const target = targetSection[targetUuid];
83
- if (!target || typeof target !== "object") {
84
- throw new Error(`[smileid-spm] Target ${targetUuid} disappeared between lookups.`);
85
- }
86
- const productDeps = section(project, "XCSwiftPackageProductDependency");
87
- // Each target owns its own XCSwiftPackageProductDependency entry —
88
- // sharing one across targets is not how Xcode writes pbxproj and
89
- // would cause downstream tools (and re-runs of this plugin) to
90
- // silently drop the second target's binding. Look up the dep
91
- // *within this target's* packageProductDependencies, never globally.
92
- target.packageProductDependencies ??= [];
93
- let depUuid = target.packageProductDependencies.find((d) => {
94
- const entry = productDeps[d.value];
95
- return (entry !== undefined &&
96
- typeof entry === "object" &&
97
- entry !== null &&
98
- entry.package === pkgRef.uuid &&
99
- entry.productName === productName);
100
- })?.value;
101
- if (!depUuid) {
102
- depUuid = generateUuid(project);
103
- productDeps[depUuid] = {
104
- isa: "XCSwiftPackageProductDependency",
105
- package: pkgRef.uuid,
106
- productName,
107
- };
108
- productDeps[`${depUuid}_comment`] = productName;
109
- target.packageProductDependencies.push({
110
- value: depUuid,
111
- comment: productName,
112
- });
113
- }
114
- ensureFrameworkLink(project, target, depUuid, productName);
115
- }
116
- function ensureFrameworkLink(project, target, productDepUuid, productName) {
117
- const frameworksPhase = findFrameworksBuildPhase(project, target);
118
- if (!frameworksPhase) {
119
- throw new Error(`[smileid-spm] Target '${target.name}' has no PBXFrameworksBuildPhase; cannot link ${productName}.`);
120
- }
121
- const buildFiles = section(project, "PBXBuildFile");
122
- // Scope the existence check to *this target's* frameworks phase.
123
- // A globally-scoped check would early-return when a sibling target
124
- // already linked the same product, leaving this target unlinked.
125
- frameworksPhase.obj.files ??= [];
126
- for (const fileRef of frameworksPhase.obj.files) {
127
- const bf = buildFiles[fileRef.value];
128
- if (bf !== undefined &&
129
- typeof bf === "object" &&
130
- bf !== null &&
131
- bf.productRef === productDepUuid) {
132
- return;
133
- }
134
- }
135
- const buildFileUuid = generateUuid(project);
136
- buildFiles[buildFileUuid] = {
137
- isa: "PBXBuildFile",
138
- productRef: productDepUuid,
139
- };
140
- buildFiles[`${buildFileUuid}_comment`] =
141
- `${productName} in Frameworks`;
142
- frameworksPhase.obj.files.push({
143
- value: buildFileUuid,
144
- comment: `${productName} in Frameworks`,
145
- });
146
- }
147
- function findFrameworksBuildPhase(project, target) {
148
- const phaseSection = section(project, "PBXFrameworksBuildPhase");
149
- for (const phaseRef of target.buildPhases) {
150
- const phase = phaseSection[phaseRef.value];
151
- if (phase &&
152
- typeof phase === "object" &&
153
- phase.isa === "PBXFrameworksBuildPhase") {
154
- return { uuid: phaseRef.value, obj: phase };
155
- }
156
- }
157
- return undefined;
158
- }
159
- function findNativeTarget(project, name) {
160
- const targets = section(project, "PBXNativeTarget");
161
- for (const [uuid, t] of Object.entries(targets)) {
162
- if (uuid.endsWith("_comment"))
163
- continue;
164
- if (typeof t !== "object" || t === null)
165
- continue;
166
- if (t.isa !== "PBXNativeTarget")
167
- continue;
168
- if (t.name === name || t.name === `"${name}"`) {
169
- return { uuid, obj: t };
170
- }
171
- }
172
- return undefined;
173
- }
174
- function serializeRequirement(req) {
175
- switch (req.kind) {
176
- case "upToNextMajorVersion":
177
- return {
178
- kind: "upToNextMajorVersion",
179
- minimumVersion: req.minimumVersion,
180
- };
181
- case "upToNextMinorVersion":
182
- return {
183
- kind: "upToNextMinorVersion",
184
- minimumVersion: req.minimumVersion,
185
- };
186
- case "exactVersion":
187
- return { kind: "exactVersion", version: req.version };
188
- case "branch":
189
- return { kind: "branch", branch: req.branch };
190
- }
191
- }
192
- function repoName(url) {
193
- const match = url.replace(/\.git$/, "").match(/\/([^/]+)$/);
194
- return match?.[1] ?? url;
195
- }
196
- //# sourceMappingURL=spm.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.linkSpmPackage=linkSpmPackage,exports.section=section,exports.generateUuid=generateUuid,exports.findNativeTarget=findNativeTarget;function linkSpmPackage(e,n,o){const t=upsertPackageReference(e,n),i=findNativeTarget(e,o.targetName);if(!i)throw new Error(`[smileid-spm] Native target '${o.targetName}' not found in Xcode project.`);for(const c of o.products)upsertProductDependency(e,i.uuid,t,c)}function objects(e){return e.hash.project.objects}function section(e,n){const o=objects(e);return o[n]||(o[n]={}),o[n]}function generateUuid(e){return e.generateUuid()}function upsertPackageReference(e,n){const o=section(e,"XCRemoteSwiftPackageReference");for(const[c,r]of Object.entries(o))if(!c.endsWith("_comment")&&!(typeof r!="object"||r===null)&&r.repositoryURL?.replace(/^"|"$/g,"")===n.url)return{uuid:c};const t=generateUuid(e);o[t]={isa:"XCRemoteSwiftPackageReference",repositoryURL:`"${n.url}"`,requirement:serializeRequirement(n.requirement)},o[`${t}_comment`]=`XCRemoteSwiftPackageReference "${repoName(n.url)}"`;const i=section(e,"PBXProject");for(const[c,r]of Object.entries(i))c.endsWith("_comment")||typeof r!="object"||r===null||r.isa==="PBXProject"&&(r.packageReferences??=[],r.packageReferences.some(s=>s.value===t)||r.packageReferences.push({value:t,comment:`XCRemoteSwiftPackageReference "${repoName(n.url)}"`}));return{uuid:t}}function upsertProductDependency(e,n,o,t){const c=section(e,"PBXNativeTarget")[n];if(!c||typeof c!="object")throw new Error(`[smileid-spm] Target ${n} disappeared between lookups.`);const r=section(e,"XCSwiftPackageProductDependency");c.packageProductDependencies??=[];let s=c.packageProductDependencies.find(a=>{const u=r[a.value];return u!==void 0&&typeof u=="object"&&u!==null&&u.package===o.uuid&&u.productName===t})?.value;s||(s=generateUuid(e),r[s]={isa:"XCSwiftPackageProductDependency",package:o.uuid,productName:t},r[`${s}_comment`]=t,c.packageProductDependencies.push({value:s,comment:t})),ensureFrameworkLink(e,c,s,t)}function ensureFrameworkLink(e,n,o,t){const i=findFrameworksBuildPhase(e,n);if(!i)throw new Error(`[smileid-spm] Target '${n.name}' has no PBXFrameworksBuildPhase; cannot link ${t}.`);const c=section(e,"PBXBuildFile");i.obj.files??=[];for(const s of i.obj.files){const a=c[s.value];if(a!==void 0&&typeof a=="object"&&a!==null&&a.productRef===o)return}const r=generateUuid(e);c[r]={isa:"PBXBuildFile",productRef:o},c[`${r}_comment`]=`${t} in Frameworks`,i.obj.files.push({value:r,comment:`${t} in Frameworks`})}function findFrameworksBuildPhase(e,n){const o=section(e,"PBXFrameworksBuildPhase");for(const t of n.buildPhases){const i=o[t.value];if(i&&typeof i=="object"&&i.isa==="PBXFrameworksBuildPhase")return{uuid:t.value,obj:i}}}function findNativeTarget(e,n){const o=section(e,"PBXNativeTarget");for(const[t,i]of Object.entries(o))if(!t.endsWith("_comment")&&!(typeof i!="object"||i===null)&&i.isa==="PBXNativeTarget"&&(i.name===n||i.name===`"${n}"`))return{uuid:t,obj:i}}function serializeRequirement(e){switch(e.kind){case"upToNextMajorVersion":return{kind:"upToNextMajorVersion",minimumVersion:e.minimumVersion};case"upToNextMinorVersion":return{kind:"upToNextMinorVersion",minimumVersion:e.minimumVersion};case"exactVersion":return{kind:"exactVersion",version:e.version};case"branch":return{kind:"branch",branch:e.branch}}}function repoName(e){return e.replace(/\.git$/,"").match(/\/([^/]+)$/)?.[1]??e}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAGpC;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;GAIG;AACH,eAAO,MAAM,mCAAmC;;;CAGtC,CAAC;AAEX,eAAO,MAAM,wBAAwB,mEAKnC,CAAC;AAEH,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,gBAAgB,EAAE,0BAA0B;IAC5C,wBAAwB,EAAE,wCAAwC;CAC1D,CAAC;AAEX,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;IACjE,gBAAgB,EAAE,mCAAmC,CAAC,gBAAgB;IACtE,wBAAwB,EACtB,mCAAmC,CAAC,wBAAwB;IAC9D,IAAI,EAAE,UAAU;CACjB,CAAC,CAAC"}