AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a systematic workflow for updating Apple/Swift Expo native modules from the legacy Expo Modules API 1.0 definition DSL to the modern 2.0 macro-based API. It emphasizes preserving the existing JavaScript and TypeScript contract, ensuring that native-side changes do not break the module's observable behavior. The process involves inventorying the current API, verifying the availability of 2.0 macro support in the target environment, and performing an incremental migration using mixed-mode development where necessary.
What it does
- Inventories existing module exports, including functions, properties, events, and records.
- Verifies the compatibility of 2.0 macros with the installed Expo SDK version.
- Guides the migration of Swift code to @ExpoModule, @JS, @Event, and @Record macros.
- Supports incremental migration through mixed-mode, keeping unsupported members in the 1.0 DSL.
- Ensures threading and async behavior remain consistent with the original 1.0 implementation.
- Provides a verification workflow using native unit tests and the example app.
When to use it
- When you need to modernize an existing Apple/Swift Expo module to the 2.0 macro API.
- When you want to adopt @ExpoModule, @JS, @Event, or @Record in a legacy module.
- When you need to perform an incremental migration while keeping the module functional.
- When you need to ensure that native-side changes do not alter the existing JS/TS API contract.
Advantages
- Preserves the existing JS/TS contract, preventing breaking changes for consumers.
- Allows for safe, incremental migration via mixed-mode development.
- Provides clear guidance on handling threading and async behavior during migration.
- Includes a robust verification process to ensure runtime compatibility.
Usage examples
- “Migrate my existing Swift module 'CameraModule' from 1.0 DSL to 2.0 macros.”
- The agent will inventory the current 'CameraModule' exports, check the installed Expo SDK version for macro support, and begin an incremental migration of the Swift classes while maintaining the existing JS interface.
- “How do I handle a blocking function during my Expo module migration?”
- The agent will advise on whether to keep the function in the 1.0 DSL or refactor it to use @JS(.concurrent) or other async patterns to ensure it does not block the JS thread.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/expo/expo-migrate-module/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip expo-migrate-module.zip -d .agents/skills
Documentation by Expo
Migrate an Expo Module
Migrate the Swift side of an existing Expo module without changing its observable JS API. Treat the current JS/TypeScript surface and tests as the compatibility contract. Leave Kotlin on the 1.0 DSL unless the user explicitly expands the task.
Prerequisite
Use expo 58.0.21 or newer. Earlier 58.0.x releases lack tuple conversion and the swift:check and swift:expand commands of expo-modules-cli. Older ones also lack lazy @JS properties, SharedRef<T> subclasses in @SharedObject, static shared-object members, and .withAsync, and the oldest lack closure arguments and free-form Any return values. SDK 57 also lacks .concurrent, @Union, and module auto-discovery. Do not target either. Before editing, check the installed version (npm ls expo, or the lockfile). If it is older, stop and tell the user to upgrade first.
Check the example app's own dependencies too, not only the module root. The example app is the integration surface you build and launch in step 4, so it needs the same floor.
This is a floor, not a guarantee: the macro and core surface changed in almost every 58.0.x patch release, so step 2 must still verify the installed source.
The macros are still experimental and undocumented: SDK 58 has no page about them in the Expo docs, and the API can still change under you. Say this to the user before a large migration, and prefer incremental mixed mode over converting a module wholesale.
References
Read
references/migration-map.mdbefore changing source. It contains the 1.0-to-2.0 mappings, semantic traps, and mixed-mode rules.Read
references/example.mdfor a full before/after walkthrough of one module through mixed mode to a complete migration. Consult it when you need to see how the per-member rules compose.Read
references/compatibility.mdwhen the checked-outexpo-modules-coreversion or branch is not known to support every requested macro. It explains how to verify the actual compile-time and runtime surface instead of guessing from a version number, gives the SDK 58 status of each capability, and shows how to run the module scanners and theexpo-modules-clichecks.
Workflow
1. Establish the contract
Inspect repository instructions and the worktree before editing. Locate the Swift module classes, records, shared objects, native views, JS/TS bindings, tests, example app, podspec, expo-module.config.json, and installed or checked-out expo-modules-core.
Inventory every exported item before rewriting it:
module and shared-object JS names
function names, arity, labels, defaults, nullability, sync/async behavior, errors, and queue/thread semantics (note which
AsyncFunctionbodies do blocking or long-running work, any.runOnQueue(...), and sync/async pairs that share a body, such asreadSyncandread)property names, mutability, and constant caching behavior
event wire names and payload shapes, including events sent with no body (1.0
sendEvent("name")sends{})record field names, defaults, requiredness, and nullability
shared-object constructors and instance/static placement (
FunctionvsStaticFunction/StaticAsyncFunction)lifecycle hooks and views
Use the TypeScript declarations and JS call sites to resolve ambiguity. Do not silently "improve" requiredness, rename an event, or change sync behavior during a syntax migration.
2. Verify the available 2.0 surface
Inspect the macro declarations and matching core hooks in the dependency actually used by the target. Do not assume that all items in the 2.0 design are present because one macro compiles.
Classify each 1.0 item as:
Migrate: both its macro and required core runtime support exist.
Keep in DSL: mixed mode preserves it safely, or 2.0 lacks an equivalent.
Blocked: migration would alter the JS contract or requires unavailable runtime support.
A DSL member that takes or returns JavaScriptValue does not compile on SDK 58, so it cannot stay in the DSL. Migrate it to @JS with a borrowing JavaScriptValue parameter, as described in references/migration-map.md.
Prefer an incremental mixed-mode result over speculative generated code. Keep definition() for any remaining DSL elements; delete it only when it is empty and the resolved module name is preserved by @ExpoModule.
3. Apply the migration
Migrate one semantic group at a time: module naming, functions, properties/constants, events, shared objects, then records. Keep the diff narrow.
Follow these invariants:
Preserve every existing JS-visible name explicitly when Swift naming rules or macro defaults differ.
Keep original optional/default behavior. An optional 1.0 record field must not become required merely because 2.0 can express required fields.
Keep same-JS-name overloads on the DSL. The plugin does not dispatch overloads, and it reports two
@JSmembers with one JS name on one object as a build error.Preserve async threading behavior. A 1.0
AsyncFunctionbody ran off the JS thread; a 2.0async@JSmember starts on it and leaves only at the firstawait. A body that never awaits therefore blocks the JS thread, with no change to the JS signature. Audit what runs before the firstawait, and never leave blocking I/O on the JS actor. Fix with@JS(.concurrent), return aTask.detachedfrom a synchronous function, or restructure onto Swift Concurrency or a continuation. A plainTask { }in a@JSfunction that is notnonisolatedstarts on the JS thread, so it does not help. Queue-pinned functions get the same treatment;.runOnQueue(.main)becomes a@MainActorasyncfunction. Merge a sync/async pair that shares a body into one function with.withAsync("name"). See the threading section inreferences/migration-map.md.Do not use
@ViewProps,@ExpoView, or@Event(sync: true). The plugin implements them, but SDK 58 core does not declare the two view macros and has no runtime support for synchronous events, so none of them builds. Keep 1.0 views on the DSL. Check the installed core for each of these instead of trusting a plugin version.references/compatibility.mdhas the per-capability checks.Keep the
OnAppContextDestroys,OnAppEntersForeground,OnAppEntersBackground, andOnAppBecomesActivecomponents indefinition(). 2.0 has no hook for them.Keep the JS payload of every event. A
() -> Void@Eventsendsundefined, but a 1.0sendEvent("name")without a body sent{}. When JS code reads that payload, give the event an empty@Recordpayload type, which encodes to{}, or ask the user before you change it.Keep
expo-module.config.jsonas it is. When it has anapple.moduleslist (even an empty one), autolinking links only those classes. The entries are bare Swift class names, so renaming a class during migration detaches the module silently: it builds, then is absent at runtime. Without the list, autolinking links thepublicoropen@ExpoModuleclasses that it finds in the package sources. It does not find a class that is still on the 1.0 DSL alone. A migrated class must staypublicoropenin both cases. Remove the list only when the user asks and every module class qualifies.Do not change Kotlin, JS wrappers, or public
.d.tsfiles unless the user requested an API change.Never write macro-generated symbols into the module's source. The macro emits them; hand-writing or overriding them is not part of a migration.
After each group, search for old DSL entries and call sites that should have moved. Avoid broad formatting or unrelated cleanup.
When a 2.0 equivalent is missing or a group fails
When step 2 classified an item as Blocked, or a migrated group fails to build or breaks the contract, do not force it. Stop on that group and:
Ask the user how to proceed for that item, with two options:
Co-exist: keep the item in the 1.0
definition()DSL alongside the migrated@ExpoModule(mixed mode) and continue with the other groups.Revert: back out the group's edits, leaving it untouched on 1.0, and move on.
Default to co-existence when mixed mode is verified safe, since it preserves the most progress. Revert when the half-applied change left the module in a non-building state and cannot be salvaged incrementally.
Open a tracking issue on
expo/exponoting the functionality that 2.0 does not yet cover, so the gap is recorded rather than silently worked around. Usegh issue create --repo expo/expoand confirm with the user before posting (per repo conventions, do not post outward-facing comments without approval). Include:the 1.0 member and its JS contract
the specific macro or core hook that is missing (cite the evidence gap from
references/compatibility.md)the installed
expoversion, or theexpo-modules-corebranch when the module builds against a checkout
Reference the issue in the handoff so the remaining DSL entry is traceable to a known limitation.
Keep going with the groups that do migrate cleanly; one blocked member does not block the rest.
4. Verify behavior
Run the narrowest available checks first, then the real integration surface:
Run
npx --no-install expo-modules swift:check iosfrom the module package root. It reports macro errors and warnings in seconds, without a build.references/compatibility.mddescribes it.Build or type-check the Apple module against the target
expo-modules-core.Run native unit tests and JS/TS tests.
Build and launch the example app when the repository provides one.
Confirm that autolinking still links every module class. With an
apple.moduleslist, each entry must match a Swift class name as it now stands. Without the list, run thescanModulescheck inreferences/compatibility.mdand confirm that it reports every class aspublicoropen. A stale entry or a missed class builds clean and fails only at runtime, so the example app must actually resolve the module, not merely compile.Compare the final exported surface with the inventory from step 1. The
scanExportscheck inreferences/compatibility.mdlists the JS names, parameters, and sync/async shape of every migrated member. Members that stay in the DSL are not in its output.Search for stale
Name, migratedFunction/AsyncFunction/StaticFunction/StaticAsyncFunction/Property/Constant/Eventsentries, oldsendEventcalls,@Field, and duplicate registrations. Search the source you wrote, not macro expansion output.
Expansion alone is insufficient: swift:check runs only the macros, so generated code with no diagnostics can still fail to link or run against a mismatched core. If dependencies changed or macro plugin flags are missing, reinstall JS dependencies as appropriate, run the repository's CocoaPods installation workflow, and restart Xcode before diagnosing plugin communication failures.
Handoff
Never print macro-generated or core-internal symbol names to the user. references/compatibility.md cites them so you can grep for them, and the swift:expand output is full of them, but they are implementation details that change between plugin revisions, and they are noise in a report. Name a capability by its macro (@JS static, @Event(sync:)) and by observable JS behavior. Say "the installed core does not support synchronous events yet", not the name of the missing method. The exception is a tracking issue on expo/expo, where the specific missing hook is the point.
Report:
which members moved to 2.0
which members intentionally remain in the 1.0 DSL and why
any compatibility-sensitive choices, especially event names, record requiredness, constants, and queues
the commands run and any verification not completed
Submitting Feedback
If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:
npx --yes @expo/agent-cli@latest feedback --category skills --subject "expo-migrate-module" "<actionable feedback>"Only submit when you have something specific and actionable to report. Include as much relevant context as possible.
If an agent repeatedly fails at an Expo task or the user has to step in, submit a brief report of the task, expected result, and what went wrong using --category evals and the relevant Expo package or command as --subject.
Files
- ATTRIBUTION.mdAdded by AutoGineer824 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md12.6 KiB
- agents/openai.yaml306 B
- references/compatibility.md19.9 KiB
- references/example.md7.8 KiB
- references/migration-map.md24.8 KiB
references/compatibility.md
Expo Modules API 2.0 Compatibility Checks
The Expo Modules API 2.0 design and implementation evolve across three packages: the expo-modules-macros compiler plugin, expo-modules-core, and expo-modules-jsi. Verify the installed dependencies instead of relying on an SDK-number claim.
A fourth package, expo-modules-cli, provides the expo-modules command for module authors. expo depends on it and exposes the command as its own bin, so every project that depends on expo has it. Its swift:check and swift:expand commands run the macros of the installed expo-modules-macros version on Swift sources, without a build. See "Inspect the generated code".
Find the actual declarations
Locate ExpoModulesMacros.swift in the target repository or installed dependencies (use your search tool, or portable shell commands - do not assume rg is installed):
find . -name 'ExpoModulesMacros.swift' -not -path '*/node_modules/.cache/*'Inspect the macros that the user's source can import, and the options that @JS accepts:
grep -nE 'public macro (ExpoModule|JS|Event|SharedObject|Record|Union|ViewProps|ExpoView)' <path-to-ExpoModulesMacros.swift>
grep -nE '^ case ' <path-to-ExpoModulesMacros.swift>In SDK 58, core declares @ExpoModule, @JS, @Event, @SharedObject, @Record, and @Union, and the @JS options .concurrent and .withAsync. It does not declare @ViewProps or @ExpoView. The plugin implements both, but source cannot use them until core declares them.
A declaration proves only that Swift recognizes the attribute, not that the code the macro generates will compile and run against the installed core.
Check paired core support
The three packages can drift independently, so a successful macro expansion does not prove the generated code links or is called at runtime. The binding hooks live in expo-modules-core. The value conversions, including free-form Any, Task, and closure callbacks, live in expo-modules-jsi. Search both.
The symbol names in this section are macro internals, for your own verification only. Never print them in the conversation, name them in your report, or write them into the migrated module's source. Report a capability by its macro (
@JS static,@Event(sync:)) and by observable JS behavior. See the reporting rule inSKILL.md.
Fast pre-check. Search core and JSI for the hooks the generated code calls, to rule out an unsupported capability before you write any Swift:
grep -rnE '_decorateModule|_decorateSharedObject|_constructSharedObject|_jsName|EventEmitter|emitSync|didCreate|decodeAnyDictionary|encodeAny|extension Task: JavaScriptEncodable|JavaScriptCallback|JSOptions|withAsync|UnionCaseMismatch' <expo-modules-core> <expo-modules-jsi>An absent hook is strong evidence the capability is unavailable. A present one is weaker: it proves the symbol exists, not that its signature matches what the plugin generates or that core ever calls it.
Confirm by compiling. Write the smallest @JS member that uses the capability. Run swift:check (see "Inspect the generated code") to see the macro's own errors without a build. Then build the module target against the installed core and read the diagnostics:
The build succeeds: the capability is supported end to end.
The macro reports an error or warning: the plugin itself rejects the construct. The diagnostic names the supported alternative.
Expansion succeeds but the build fails on a missing symbol or an override with nothing to override: the plugin is ahead of core. Keep the member in the 1.0 DSL.
Then exercise the member from the example app or a test, because a binding can link and still never be invoked.
Capability gates
Treat these as independent capabilities. Confirm each by compiling a minimal member that uses it, then calling it from JS. The SDK 58 column records what SDK 58 provides at the floor in SKILL.md. Use it to decide where to look first, not in place of the checks.
| Capability | Macro surface | Hook to grep (internal) | SDK 58 | Confirm by |
|---|---|---|---|---|
| Module functions/properties | @ExpoModule, @JS | _decorateModule and its call site | yes | calling the function and reading the property from JS |
| Module name | @ExpoModule("Name") | _jsName and the name lookup that reads it | yes, but a Name(...) entry wins over it | resolving the module under its expected JS name |
| Records | @Record | coding conformances and field decode/encode | yes, on a struct or a final class with no inheritance clause | round-tripping a record argument and a record return value |
| Async events | @Event | EventEmitter on modules and shared objects | yes | receiving an emitted event through the module's JS listener |
| Shared-object instances | @SharedObject, @JS | _decorateSharedObject(prototype:), construction hook | yes | constructing one from JS and calling an instance member |
| Shared-object static members | @JS static | _decorateSharedObject(constructor:), distinct from the prototype: overload | yes | calling the member on the JS class itself, not an instance |
| Shared-object subclasses | @SharedObject on a SharedRef<T> subclass or another indirect subclass | none, the compiler checks the superclass | yes | constructing one from JS and calling a member |
| Lazy properties | @JS lazy var | none, the macro binds a getter that stores the value | yes | reading the property twice from JS and seeing one native evaluation |
| Tuples | tuples in @JS, @Record, @Union, @Event, and closure arguments | decodeTuple and encodeTuple in JSI | yes | round-tripping an unlabeled tuple as an array and a labeled one as an object |
| Synchronous events | @Event(sync:) | emitSync overloads | no, core and JSI have no emitSync | observing the listener run before the emit call returns |
| Task-returning functions | @JS returning Task | JavaScriptEncodable for Task in JSI (encode-only) | yes | awaiting the returned promise in JS |
| Views | @ViewProps, @ExpoView | the macro declarations in ExpoModulesMacros.swift | no, core does not declare them | rendering the view and updating every prop from JS |
| Module lifecycle methods | lifecycle members on the module class | AnyModule requirements and holder call sites | yes | observing each hook fire |
Free-form Any | @JS and @Record with Any, [Any], [String: Any] | decodeAny… and encodeAny… in JSI | yes | passing a JS object through and back |
| Closure arguments | @JS with a function-typed parameter | JavaScriptCallback in JSI | yes | calling the closure from native code and reading the JS result |
| Off-JS-thread async start | @JS(.concurrent) | JSOptions and the options-taking @JS overload | yes | the @JS declaration accepting the option |
| Promise variant of a sync function | @JS("nameSync", .withAsync("name")) | withAsync in JSOptions | yes | calling both JS names |
| Typed N-case unions | @Union | Union macro declaration and UnionCaseMismatch | yes | round-tripping each case through the JS boundary |
Autolinked @ExpoModule discovery | none, it is a build-time step | scanModules in expo-modules-autolinking | yes | the module loading without an apple.modules list |
If a capability cannot be confirmed, keep that item in the 1.0 DSL.
Known migration hazards
Use this only as a warning list; installed source wins.
Async threading changed architecturally, not just syntactically: a 2.0
asyncmember starts on the JS thread and leaves it at the first suspension point, where a 1.0AsyncFunctionnever ran there. A verbatim migration can move blocking work onto the JS thread with no signature change.@JS(.concurrent)restores the 1.0 behavior. In Swift 6 language mode,.concurrent,.withAsync, and a detachedTaskneed the module or shared object to be@unchecked Sendable, which newer macros add themselves. See the threading section inreferences/migration-map.md.Same-JS-name
@JSoverload grouping and dispatch were designed but never built. The plugin reports two@JSmembers with one JS name on one object as a build error. A shared object's static and instance members bind onto different JS objects, so they can share a name.@Uniondecoding is first-match in case-declaration order, so preserving a 1.0Either's type order is part of the contract. See the unions section inreferences/migration-map.md.Decode errors lacked the 1.0 argument-index wrapper. This affects diagnostics rather than call semantics, but tests asserting exact messages may fail.
The plugin in SDK 58 implements
@ViewPropsand@ExpoView, but core does not declare either macro and has no typed view-props runtime. Views stay on the 1.0 DSL.@Event(sync: true)macro generation exists, but SDK 58 core and JSI have noemitSync.Shared-object
@JS static/classmembers bind onto the JS class object through aconstructor:-labeled decoration hook, separate from theprototype:one used for instance members. Instance support does not imply static support, so confirm a static member by calling it on the JS class.Async
@JSbindings are two-phase: arguments decode synchronously before the asynchronous boundary, and return values encode on the JS thread. A 1.0 async function whose argument decoding had side effects ordered after the hop can therefore observe a different order.On SDK 58,
JavaScriptValueis a non-copyable struct, and DSLFunction,AsyncFunction,Property, andFieldno longer accept it in their signatures. A DSL member that takes or returns aJavaScriptValueno longer compiles. Migrate it to@JSand take the value asborrowing JavaScriptValue. To keep the value after the call returns, storevalue.ref()and read it back withtake()orwithUnwrappedValue(_:). Write.undefined()and.null(), which are functions now.Core reads the
@ExpoModulename only when the module has noName(...)entry. In mixed mode a leftoverName(...)wins, so a mismatch between the two names is silent.A no-payload
@Event(() -> Void) sendsundefined. A 1.0sendEvent("name")without a body sent{}.OnAppContextDestroys,OnAppEntersForeground,OnAppEntersBackground, andOnAppBecomesActivehave no 2.0 hook. They stay indefinition().
Macro changes in SDK 58 that affect a migration
All of them are present under the expo 58.0.21 floor in SKILL.md.
Free-form Any
Any, [Any], and [String: Any] are accepted as @JS arguments, return values, and properties, and as @Record fields. One optional layer ([String: Any]?) also works, and so do nested types built from Any, arrays, String-keyed dictionaries, and optionals ([String: [Any]]). They convert through dedicated free-form methods in JSI, not through JavaScriptDecodable/JavaScriptEncodable.
A 1.0 DSL member with a loosely typed dictionary can therefore keep its Swift signature. Prefer a typed @Record only when the user asks for an API-shape change.
Closure arguments
A @JS function or initializer can take a closure parameter, such as (Point) throws -> Size or (String) async throws -> Data. JS passes a function for it. Native code can store the closure and call it from any thread.
A closure that returns a value must be
throws, so that an error from JS can reach the caller.A throwing or value-returning closure blocks the caller until JS returns. An
asyncclosure suspends instead and awaits the promise that the JS function returns.A non-throwing
Voidclosure returns before JS reads its arguments, so do not change a class instance after passing it to one.An optional closure (
((Int) -> Void)?) turns JSnullandundefinedintonil.A closure nested in another type, such as an array, is not a closure parameter.
The closure type accepts only the
@escapingand@Sendableattributes. Its parameters cannot be variadic,inout, closures, or free-formAny, and it cannot use typed throws.A
@JSfunction cannot return a closure, and a@JSproperty cannot have a closure type.
Parameters and names
inoutandisolatedparameters are build errors, because a@JSargument is a fresh value decoded from JS.borrowing,consuming, andsendingparameters are accepted.A backticked Swift name binds under its bare name:
@JS func `default`()isdefaultin JS.
.withAsync
@JS("readSync", .withAsync("read")) binds a synchronous function under its own JS name, and binds it again under the given name as a function that returns a promise and runs the body on the concurrent thread pool. See the threading section in references/migration-map.md. The macro rejects it on an async function, a property, or an initializer, and on a function isolated to a global actor.
Records
@Record types convert without an app context. A @Record class must be final and have no inheritance clause, or the build fails; declare its protocol conformances in an extension. A 1.0 class Options: Record therefore becomes @Record final class Options, or a struct.
Static members on shared objects
static and class @JS members of a @SharedObject class bind onto the JS class itself, so JS calls them as Cache.open(name). A 1.0 StaticFunction or StaticAsyncFunction migrates to one. See the static members section in references/migration-map.md.
lazy properties and shared-object subclasses
A
@JS lazy varis read-only from JS. Its first read stores the value as a data property on the JS object, so later reads do not call native code. On a frozen JS object the value is not stored, and each read calls the getter. This is the closest mapping for a 1.0Constant.@SharedObjectaccepts aSharedRef<T>subclass and any other indirectSharedObjectsubclass. The compiler, not the macro, reports a class that is not aSharedObjectsubclass. Each@SharedObjectclass exposes only the@JSmembers that it declares. That matches 1.0, where aClass(...)block could not inherit from another.
Tuples
A tuple can cross the boundary as a @JS argument, result, or property, a @Record property, a @Union or @Event payload, or a parameter or result of a closure argument that is not async.
An unlabeled tuple such as
(Int, String)converts to an array with one value per element. A labeled tuple such as(x: Double, y: Double)converts to an object with one property per label.A tuple must have two or more elements, all labeled or none, and each element must be convertible. Tuples nest in other tuples, optionals, arrays, and
String-keyed dictionaries.A type alias of a tuple, such as
typealias Span = (start: Int, end: Int), resolves only when the@ExpoModuleor@SharedObjectclass body declares it.
Package and binary names
The package is expo-modules-macros, formerly @expo/expo-modules-macros-plugin, and the executable is ExpoModulesMacros, formerly ExpoModulesMacros-tool. pod install adds -load-plugin-executable <plugin>/apple/ExpoModulesMacros#ExpoModulesMacros to OTHER_SWIFT_FLAGS. Look for that flag when the compiler cannot find the macro implementation.
Autolinked module discovery
On SDK 58, autolinking scans the package sources for @ExpoModule classes when it generates the modules provider. The rules that matter for a migration:
When
expo-module.config.jsonhas anapple.moduleslist, even an empty one, autolinking uses only that list and ignores the scan.Without the list, it links every scanned class that is
publicoropenand compiles for the target platform. Aninternalclass gets a warning, and a lower access level opts the class out silently.A class inside an
#ifcondition that the scanner cannot evaluate statically, such as#if DEBUGorcanImport(...), is skipped with a warning. List such a class inapple.modules.The scan skips
Tests,UITests,__tests__,__mocks__,example,examples,e2e,Pods,node_modules,.build, and.gitdirectories. A module class kept under one of those names needs the list.The scan finds only classes with the
@ExpoModuleattribute. A package that still has a module on the 1.0 DSL alone needs the list.
Run the scanners yourself as migration checks. Run this from the module package root, and pass the scanner's name, scanModules or scanExports, as the argument:
node -e "
const path = require('path');
let dir = process.cwd();
for (const name of ['expo', 'expo-modules-core', 'expo-modules-macros']) {
dir = path.dirname(require.resolve(name + '/package.json', { paths: [dir] }));
}
require(dir)[process.argv[1]](['ios']).then((r) => console.log(JSON.stringify(r, null, 2)));
" scanModulesThe script resolves expo, then expo-modules-core from it, then expo-modules-macros from that, which is how expo-modules-cli finds the macros. Only expo has to be a dependency of the module, so the script also works with pnpm and bun isolated installs, where expo-modules-core cannot be resolved from the module root.
scanModules reports each detected class with its Swift name, jsName, accessLevel, and platforms, plus warnings. It catches an @ExpoModule that landed in a conditional block or on a non-public class.
scanExports reports the macro-declared surface: modules, sharedObjects, records, unions, and enums. Each module lists its functions (with jsName, parameters, async, throws, and static), properties (with readonly), events (with jsName, payload, and sync), and classes. Compare it against the inventory from step 1. It does not report members that stay in the DSL.
Inspect the generated code
expo-modules-cli has two commands that run the macros on Swift sources without a build. Both find the expo-modules-macros version through the package's expo and expo-modules-core, which is the version the iOS build compiles with. Run them from the module package root:
# Only the macro errors and warnings, and a summary. The exit code is 1 when there is an error.
npx --no-install expo-modules swift:check ios
# The code that the macros generate, for a file or for one type or member.
npx --no-install expo-modules swift:expand ios/MyModule.swift
npx --no-install expo-modules swift:expand --symbol MyModule.load ios/MyModule.swiftexpo declares the expo-modules bin itself and forwards it to expo-modules-cli, so every package manager links it into node_modules/.bin, also with pnpm and bun isolated installs. pnpm exec expo-modules and bunx expo-modules run the same command. It needs expo installed in the module package; when the command is missing, install the module's dependencies. --no-install keeps npx from downloading a package from npm in that case. A path is a .swift file or a directory. In a directory, only the files that use a macro are expanded, and test and example directories are skipped. The diagnostics use the compiler's <file>:<line>:<column>: error: <message> format. --json prints a report instead of text, and then the exit code is 0 even when there is an error.
Use swift:check to find a macro error fast, and swift:expand to see why a binding does not behave as expected. Do not copy the expansion into the module source, and do not quote it to the user: it consists of the internal symbols that the handoff rule in SKILL.md keeps out of reports. The macros see only syntax, so code with no diagnostics can still fail to type-check, build, or link against the installed core.
Integration verification
Use the target project's own commands. A robust sequence is:
Run macro/unit tests if working inside the macros package.
Run
npx --no-install expo-modules swift:check ioson the module's iOS sources.Compile the migrated native module against the installed core.
Re-run CocoaPods installation when plugin dependencies or injection changed.
Restart Xcode after swapping a macro plugin binary; cleaning DerivedData alone may not reload it.
Build the example app and execute existing JS/TS behavior tests.
Do not report a migration complete based only on swift:check, swift:expand, or textual expansion tests.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Expo
- Publisher
- Expo (Official)
- Source
- expo/skills · plugins/expo-experiments/skills/expo-migrate-module · commit a9e5bd3
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Expo or Expo.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download expo-migrate-module.zip