Automation
Fastlane register_device: Register an iPhone Safely
Use Fastlane register_device with trusted UDID input, explicit Apple team context, secure authentication, verification, profile refresh, and a replacement Ad Hoc build.
Fastlane’s register_device action registers one approved iOS or Mac device with the Apple Developer Portal so it can later be included in a provisioning profile. It takes a device name and UDID, supports explicit team context, and currently supports App Store Connect API key inputs as well as Apple ID-based context.
It does not add the device to an existing profile, rebuild or re-sign an IPA, verify the embedded profile, or deliver the app. Treat it as one mutation inside a larger authorized workflow.
Prerequisites
Before running the action, establish all of these:
- the tester has consented to registration for a defined app or test;
- the UDID came from the intended physical device and passed input validation;
- the target Apple Developer team ID is explicit;
- the operator or CI identity is authorized to register devices for that team;
- the product-family device limit has capacity;
- credentials are stored outside the repository and build logs; and
- the release process knows which profile and artifact must be updated next.
If the input comes from a client-facing form, do not pass it directly to Fastlane. Validate, deduplicate, approve, and bind it to a known client/team first. Automatic UDID Registration owns that complete intake-to-delivery design.
Authentication and team context
The current register_device documentation lists these relevant inputs:
nameandudidfor the device;platform, withiosas the default andmacalso supported;team_idorteam_namewhen the account belongs to multiple teams;api_key_pathorapi_keyfor App Store Connect API key authentication; andusernamefor Apple ID context.
Prefer an App Store Connect API key when the current action and team configuration support it. Fastlane recommends API-key authentication where available and notes that provisioning-related access requires a Team API key; Individual keys cannot use provisioning endpoints.
Keep the P8 file and its identifiers in a CI secret store or protected runtime path. Do not commit the key, paste it into a Fastfile, print the API-key hash, or accept it from an end client. Use the least Apple role that permits the approved task and keep each client’s credentials isolated.
One-device Fastfile example
Use an explicit lane that receives already validated input:
private_lane :register_approved_device do |options|
register_device(
name: options.fetch(:name),
udid: options.fetch(:udid),
platform: "ios",
team_id: ENV.fetch("APPLE_TEAM_ID"),
api_key_path: ENV.fetch("ASC_API_KEY_PATH")
)
end
Invoke the lane from a controlled release workflow, not directly from an untrusted web request. When running Fastlane in CI, pin the project through its existing Ruby dependency workflow and use bundle exec fastlane so local and CI versions do not drift silently.
Do not put real UDIDs, team IDs, account emails, or secret paths in a public example. Your production lane should attach the request to an internal change record without exposing those values in ordinary logs.
One-off CLI use
Fastlane documents fastlane run register_device for one-off execution and recommends placing recurring actions in a Fastfile. A one-off command is reasonable for an accountable operator testing a known device, but it is a poor interface for an unattended client intake because shell history and CI output can expose parameters.
Before using CLI parameters, review the current local action interface:
bundle exec fastlane action register_device
That output is tied to the Fastlane version installed by the project, which is safer than copying an old command from a blog post.
Controlled batch registration
Fastlane provides a separate register_devices action for several devices. It accepts a devices hash or a devices_file in the current documentation:
private_lane :register_approved_batch do
register_devices(
devices_file: "./approved-devices.txt",
team_id: ENV.fetch("APPLE_TEAM_ID"),
api_key_path: ENV.fetch("ASC_API_KEY_PATH")
)
end
Generate the input file from a reviewed system of record. Validate every row, reject duplicate normalized UDIDs, bind the whole batch to one explicit team, and fail before Fastlane if any record is ambiguous. Do not treat a spreadsheet emailed by a client as authorization to mutate the Apple account.
For occasional manual batches, Apple also documents its own supported device-file upload formats. Choose one ownership path and record the resulting Apple state; do not run several registration systems against the same untracked list.
Duplicate and idempotent behavior
Fastlane describes register_device and register_devices as optimistic actions: they add devices and do not remove existing portal records. If the device is already registered, it is left in place.
That makes rerunning the same valid registration less destructive, but it is not complete workflow idempotency. Your lane still needs to prevent:
- the same client submission from starting concurrent jobs;
- a UDID from being registered in the wrong team;
- a duplicate job from generating multiple release records;
- profile refresh from running against the wrong app; and
- the old IPA from being delivered after a successful rerun.
Use a stable internal request ID and check the Apple device state before and after the action. Return the existing state for an already satisfied request instead of claiming a second registration.
CI safety checklist
Before enabling the lane in CI:
- Separate intake from execution. Only approved records reach the signing/portal worker.
- Pin team context. Do not depend on an interactive team picker or a developer’s default session.
- Use protected secrets. Keep P8 or Apple session material out of source, artifacts, caches, and logs.
- Restrict job triggers. Pull requests from untrusted forks must not gain access to registration credentials.
- Serialize team mutations. Avoid races between registration and profile refresh jobs.
- Capture a redacted result. Record request, team, device reference, action version, outcome, and follow-up state.
- Fail closed. If validation, authorization, capacity, or team resolution fails, do not fall back to another account.
Registration automation is account administration. Treat it with a narrower trust boundary than ordinary unit tests or static builds.
Verify registration afterward
A green Fastlane step is useful, but verify the resulting Apple state before refreshing profiles. The supported App Store Connect API can list devices and read a device resource. Confirm:
- the expected team context;
- the returned UDID and platform;
- the device status or eligibility; and
- whether Apple reports any additional processing state relevant to provisioning.
Apple documents that some devices on new memberships or memberships renewed after a long lapse can be registered while temporarily ineligible for profile inclusion. Do not rerun register_device indefinitely when the device exists but Apple has not finished processing it.
Also monitor Apple Developer Device Limits. Fastlane cannot bypass the team’s per-product-family membership-year capacity.
What happens after register_device
For Ad Hoc delivery, the remaining chain is:
register_device
→ verify device in the correct team
→ refresh the intended Ad Hoc profile
→ synchronize certificate and profile to the build environment
→ build a new IPA or perform an authorized re-sign
→ inspect embedded profile, signature, and entitlements
→ deliver the verified replacement artifact
If the profile is manually managed, follow Add a Device to an Existing Provisioning Profile. If the device exists in the portal but the delivered app still excludes it, use Device Not in Provisioning Profile instead of registering it again.
Relationship to Fastlane match and build_app
Fastlane’s current match documentation shows this device-refresh pattern:
lane :beta do
register_devices(devices_file: "./approved-devices.txt")
match(type: "adhoc", force_for_new_devices: true)
end
force_for_new_devices checks whether the enabled device count changed and can regenerate Ad Hoc or Development profiles when needed. It does not apply to App Store profiles, which do not contain device lists. Use Fastlane match for Ad Hoc for signing-asset storage, CI read-only mode, and refresh behavior.
After the profile is current, Build an Ad Hoc IPA with Fastlane owns the build_app/gym export and final artifact checks. Keeping those topics separate prevents a registration guide from hiding the signing and export decisions.
Handle errors by stage
- Invalid UDID or untrusted source: reject before Fastlane and recollect from the physical device.
- Authentication or permission error: stop and repair the service identity; never ask a tester for credentials.
- Multiple-team ambiguity: require an explicit
team_idand accountable approval. - Capacity failure: stop registering and reassess TestFlight or another approved method.
- Existing but ineligible device: preserve the Apple state and follow Apple’s documented processing window.
- Registration succeeds, profile refresh fails: keep the device result but fail the release; do not deliver the old build.
- Profile refresh succeeds, build fails: repair the signing/export stage without creating another device record.
- Final IPA excludes the UDID: inspect the embedded profile and artifact provenance rather than trusting the portal.
Retries should be narrow. Do not retry malformed input, permission denial, wrong-team selection, or capacity exhaustion. For a service-side failure, preserve the original request and retry only when the official response indicates that the operation is safe to repeat.
The boundary to remember
register_device is a legitimate way to automate an approved Apple Developer account operation. It is not a distribution method and does not bypass Apple’s controls.
Run the UDID Validator before an operator approves uncertain input, then verify the full profile and artifact chain before client delivery. If that repeated chain is the operational bottleneck, IPAFlow is in Private Beta / In Development for authorized device onboarding and delivery workflows; review the product boundaries or join Early Access.