@smileid/usesmileid_vision_face 12.0.0-beta01
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 +3 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/app.plugin.js +3 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/expo-module.config.json +6 -0
- package/ios/UseSmileIDVisionFaceExpo.podspec +61 -0
- package/ios/UseSmileIDVisionFaceModule/ResizingFrameStorage.swift +181 -0
- package/ios/UseSmileIDVisionFaceModule/UseSmileIDAnalyzerExecutor.swift +119 -0
- package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceFrameProcessorPlugin.swift +96 -0
- package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceModule.swift +280 -0
- package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceSessionHolder.swift +105 -0
- package/package.json +79 -0
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +115 -0
- package/plugin/build/index.js.map +1 -0
- package/plugin/build/lib/podfile.d.ts +17 -0
- package/plugin/build/lib/podfile.js +180 -0
- package/plugin/build/lib/podfile.js.map +1 -0
- package/plugin/build/lib/spm.d.ts +33 -0
- package/plugin/build/lib/spm.js +196 -0
- package/plugin/build/lib/spm.js.map +1 -0
- package/plugin/src/index.ts +96 -0
- package/plugin/src/lib/podfile.ts +209 -0
- package/plugin/src/lib/spm.ts +314 -0
- package/plugin/tsconfig.json +19 -0
- package/src/__tests__/use_smile_id_vision_face.test.ts +79 -0
- package/src/index.ts +41 -0
|
@@ -0,0 +1,180 @@
|
|
|
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
|
|
93
|
+
# bridge code can \`import\` them. Idempotent across pod installs.
|
|
94
|
+
#
|
|
95
|
+
# UUIDs are minted via SecureRandom rather than \`pods_project.new\`
|
|
96
|
+
# because \`prepare_react_native_project!\` sets
|
|
97
|
+
# \`:deterministic_uuids => false\`. With that flag off, CocoaPods
|
|
98
|
+
# skips its predictabilize step and \`stabilize_target_uuids\` resets
|
|
99
|
+
# \`@generated_uuids\` to a tiny leftover pool — so any post_install
|
|
100
|
+
# call to \`pods_project.new\` restarts the sequential index near 0
|
|
101
|
+
# and re-mints UUIDs already in use. The collision then runs through
|
|
102
|
+
# \`add_referrer\`, which clobbers \`objects_by_uuid[uuid]\` and
|
|
103
|
+
# leaves the rootObject (\`46EB2E00000000\`) unreachable, crashing
|
|
104
|
+
# Xcode 26 with \`XCSwiftPackageProductDependency
|
|
105
|
+
# _setSavedArchiveVersion:\` unrecognized selector. Random 24-char
|
|
106
|
+
# hex IDs can't collide with the 14-char cocoapods scheme.
|
|
107
|
+
begin
|
|
108
|
+
pods_project = installer.pods_project
|
|
109
|
+
spm_url = '${options.package.url}'
|
|
110
|
+
spm_requirement = ${requirement}
|
|
111
|
+
product_names = [${productList}]
|
|
112
|
+
target_name = '${options.podTarget}'
|
|
113
|
+
|
|
114
|
+
smileid_spm_safe_uuid = lambda do |project|
|
|
115
|
+
loop do
|
|
116
|
+
candidate = SecureRandom.hex(12).upcase
|
|
117
|
+
return candidate unless project.objects_by_uuid.key?(candidate)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
pkg = pods_project.root_object.package_references.find do |r|
|
|
122
|
+
r.respond_to?(:repositoryURL) && r.repositoryURL == spm_url
|
|
123
|
+
end
|
|
124
|
+
unless pkg
|
|
125
|
+
pkg_uuid = smileid_spm_safe_uuid.call(pods_project)
|
|
126
|
+
pkg = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference.new(pods_project, pkg_uuid)
|
|
127
|
+
pkg.initialize_defaults
|
|
128
|
+
pkg.repositoryURL = spm_url
|
|
129
|
+
pkg.requirement = spm_requirement
|
|
130
|
+
pods_project.root_object.package_references << pkg
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
target = pods_project.targets.find { |t| t.name == target_name }
|
|
134
|
+
if target.nil?
|
|
135
|
+
Pod::UI.warn "[smileid-spm] Pod target #{target_name} not found; skipping SPM link."
|
|
136
|
+
else
|
|
137
|
+
product_names.each do |product_name|
|
|
138
|
+
already = target.package_product_dependencies.any? do |d|
|
|
139
|
+
d.package == pkg && d.product_name == product_name
|
|
140
|
+
end
|
|
141
|
+
next if already
|
|
142
|
+
|
|
143
|
+
dep_uuid = smileid_spm_safe_uuid.call(pods_project)
|
|
144
|
+
dep = Xcodeproj::Project::Object::XCSwiftPackageProductDependency.new(pods_project, dep_uuid)
|
|
145
|
+
dep.initialize_defaults
|
|
146
|
+
dep.package = pkg
|
|
147
|
+
dep.product_name = product_name
|
|
148
|
+
target.package_product_dependencies << dep
|
|
149
|
+
|
|
150
|
+
bf_uuid = smileid_spm_safe_uuid.call(pods_project)
|
|
151
|
+
bf = Xcodeproj::Project::Object::PBXBuildFile.new(pods_project, bf_uuid)
|
|
152
|
+
bf.initialize_defaults
|
|
153
|
+
bf.product_ref = dep
|
|
154
|
+
target.frameworks_build_phase.files << bf
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
pods_project.save
|
|
159
|
+
rescue => e
|
|
160
|
+
Pod::UI.warn "[smileid-spm] Failed to link SPM products for ${options.podTarget}: #{e.message}"
|
|
161
|
+
raise
|
|
162
|
+
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"podfile.js","sourceRoot":"","sources":["../../src/lib/podfile.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sEAAsE;AACtE,mEAAmE;AACnE,mEAAmE;AACnE,iEAAiE;;AAuBjE,sDA6CC;AAhED,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAChD,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAY5C;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,OAAe,EACf,OAA2B;IAE3B,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE1B,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC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AC,CAAS;IAC7B,OAAO,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { XcodeProject } from "@expo/config-plugins";
|
|
2
|
+
export interface SpmPackage {
|
|
3
|
+
/** Remote git URL of the Swift Package, e.g. `https://github.com/smileidentity/ios-spm`. */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Version requirement; mirrors Xcode's package resolution UI. */
|
|
6
|
+
requirement: SpmRequirement;
|
|
7
|
+
}
|
|
8
|
+
export type SpmRequirement = {
|
|
9
|
+
kind: "upToNextMajorVersion";
|
|
10
|
+
minimumVersion: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "upToNextMinorVersion";
|
|
13
|
+
minimumVersion: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "exactVersion";
|
|
16
|
+
version: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "branch";
|
|
19
|
+
branch: string;
|
|
20
|
+
};
|
|
21
|
+
export interface SpmTargetLink {
|
|
22
|
+
/** Native target name in the project (app target or pod target). */
|
|
23
|
+
targetName: string;
|
|
24
|
+
/** SPM library product names to attach to the target. */
|
|
25
|
+
products: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adds (or reuses) a remote Swift Package reference on the given
|
|
29
|
+
* Xcode project and links the requested products to the target.
|
|
30
|
+
* Idempotent: existing package refs and product deps are reused so
|
|
31
|
+
* multiple plugins can compose without conflict.
|
|
32
|
+
*/
|
|
33
|
+
export declare function linkSpmPackage(project: XcodeProject, pkg: SpmPackage, link: SpmTargetLink): void;
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spm.js","sourceRoot":"","sources":["../../src/lib/spm.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,qEAAqE;AACrE,4CAA4C;AAC5C,EAAE;AACF,uDAAuD;AACvD,kEAAkE;AAClE,mEAAmE;AACnE,4CAA4C;;AA8B5C,wCAeC;AArBD;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAqB,EACrB,GAAe,EACf,IAAmB;IAEnB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,gCAAgC,IAAI,CAAC,UAAU,+BAA+B,CAC/E,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;AAC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AC;QACxD,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAClD,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5D,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Expo config plugin that wires the Smile Identity Swift Package
|
|
2
|
+
// (`https://github.com/smileidentity/ios-spm`) into both:
|
|
3
|
+
// 1. The consuming app's Xcode project — so the .xcframeworks ship
|
|
4
|
+
// and embed in the final .app bundle.
|
|
5
|
+
// 2. The autogenerated Pods.xcodeproj at `pod install` time — so
|
|
6
|
+
// the Expo Module bridge (`UseSmileIDVisionFaceExpo`) compiles
|
|
7
|
+
// with `import UseSmileIDVisionFace` / `import UseSmileIDBridge`.
|
|
8
|
+
//
|
|
9
|
+
// Why a plugin: `expo-modules-autolinking@55.0.x`'s
|
|
10
|
+
// `RawModuleConfigApple` schema has no `dependencies` field, so the
|
|
11
|
+
// `apple.dependencies` block in `expo-module.config.json` is silently
|
|
12
|
+
// ignored. Without this plugin, neither the bridge nor the host app
|
|
13
|
+
// know about the SPM package.
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
ConfigPlugin,
|
|
17
|
+
withDangerousMod,
|
|
18
|
+
withXcodeProject,
|
|
19
|
+
} from "@expo/config-plugins";
|
|
20
|
+
import * as fs from "fs";
|
|
21
|
+
import * as path from "path";
|
|
22
|
+
|
|
23
|
+
import { injectPodfileSpmBlock } from "./lib/podfile";
|
|
24
|
+
import { linkSpmPackage, SpmPackage } from "./lib/spm";
|
|
25
|
+
|
|
26
|
+
// Pinned to the exact `12.0.0-beta01` release tag — `from: 12.0.0`
|
|
27
|
+
// would not resolve because `ios-spm` publishes pre-release tags (e.g.
|
|
28
|
+
// `12.0.0-beta01`), and SPM excludes pre-release tags from open-ended
|
|
29
|
+
// major-version requirements.
|
|
30
|
+
const SMILE_ID_PACKAGE: SpmPackage = {
|
|
31
|
+
url: "https://github.com/smileidentity/ios-spm",
|
|
32
|
+
requirement: {
|
|
33
|
+
kind: "exactVersion",
|
|
34
|
+
version: "12.0.0-beta01",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const POD_TARGET = "UseSmileIDVisionFaceExpo";
|
|
39
|
+
// `UseSmileIDBridge` is also listed explicitly even though the Vision
|
|
40
|
+
// library product wraps it as a transitive target — empirically this
|
|
41
|
+
// is what makes `import UseSmileIDBridge` resolve in the bridge under
|
|
42
|
+
// SPM-via-CocoaPods. A cleaner config that drops the redundant
|
|
43
|
+
// listing is plausible (the SPM Package.swift declares
|
|
44
|
+
// `targets: ["UseSmileIDVisionFace", "UseSmileIDBridge"]` for the Vision
|
|
45
|
+
// library product) but unverified, and the duplicate produces only a
|
|
46
|
+
// benign "Conflicting parseable interfaces" warning at link time.
|
|
47
|
+
const SPM_PRODUCTS = ["UseSmileIDVisionFace", "UseSmileIDBridge"] as const;
|
|
48
|
+
const PODFILE_MARKER = "usesmileid_vision_face";
|
|
49
|
+
|
|
50
|
+
const withVisionFaceSpm: ConfigPlugin = (config) => {
|
|
51
|
+
// 1. Add the package + products to the host app's Xcode project so
|
|
52
|
+
// Xcode resolves the binary xcframeworks and embeds them in the
|
|
53
|
+
// .app at link time.
|
|
54
|
+
config = withXcodeProject(config, (config) => {
|
|
55
|
+
const appTarget = config.modRequest.projectName;
|
|
56
|
+
if (!appTarget) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"[usesmileid_vision_face] Unable to resolve host app native target name from Expo config.",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
linkSpmPackage(config.modResults, SMILE_ID_PACKAGE, {
|
|
62
|
+
targetName: appTarget,
|
|
63
|
+
products: [...SPM_PRODUCTS],
|
|
64
|
+
});
|
|
65
|
+
return config;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// 2. Inject a Ruby block into the Podfile's post_install hook that
|
|
69
|
+
// re-applies the same wiring to Pods.xcodeproj when CocoaPods
|
|
70
|
+
// materializes it. The bridge pod target needs the products
|
|
71
|
+
// visible at compile time; the host-app step alone isn't enough.
|
|
72
|
+
config = withDangerousMod(config, [
|
|
73
|
+
"ios",
|
|
74
|
+
(config) => {
|
|
75
|
+
const podfilePath = path.join(
|
|
76
|
+
config.modRequest.platformProjectRoot,
|
|
77
|
+
"Podfile",
|
|
78
|
+
);
|
|
79
|
+
const original = fs.readFileSync(podfilePath, "utf-8");
|
|
80
|
+
const next = injectPodfileSpmBlock(original, {
|
|
81
|
+
marker: PODFILE_MARKER,
|
|
82
|
+
package: SMILE_ID_PACKAGE,
|
|
83
|
+
podTarget: POD_TARGET,
|
|
84
|
+
products: [...SPM_PRODUCTS],
|
|
85
|
+
});
|
|
86
|
+
if (next !== original) {
|
|
87
|
+
fs.writeFileSync(podfilePath, next);
|
|
88
|
+
}
|
|
89
|
+
return config;
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
return config;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default withVisionFaceSpm;
|