Apple MobileDevice in Roblox

Hello! This post is related to Project Alpine: Remastered, and is all about interaction with the iPhone. And that’s what I’m going to discuss.

However, this software is a work in progress, so don’t mind anything you see that may be for Apple-internal use!

Introducing MobileDevice, the next step into interaction with the iPhone in Roblox. This means you can allow your games and apps to implement restoring, updating, tweaking, etc.

A little tip: This is my first OOP script!

--[[
	Copyright (c) 2025 Apple Inc. All rights reserved.
	
	@APPLE_LICENSE_HEADER_START@
	
	The contents of this file constitute Original Code as defined in and
	are subject to the Apple Public Source License Version 1.1 (the 
	"License").  You may not use this file except in compliance with the
	License.  Please obtain a copy of the License at
	https://www.apple.com/publicsource and read it before using this file.
	
	The Original Code and all software distributed under this License are
	distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
	EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
	INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  	Please see the 
	License for the specific language governing rights and limitations
	under the License.
	
	@APPLE_LICENSE_HEADER_END@
]]

--[[

	MobileDevice.framework
	
	MobileDevice is a framework that allows the communication between iOS devices and a Mac.
	This lets you run an XPC & lockdownd connection on the device from either Wi-Fi or USB.
	
	In Roblox logic, you can simply find the device in any directory, as long as the proper
	files are on that device.

]]

local MobileDevice = {}
MobileDevice.__index = {}

--[[
	AMDeviceUpdateWithPackageBundlePath(restore_path:Folder):number
	
	Updates the connected (and valid) device using the provided iTunes Update Package.
	
	The device is placed in Recovery Mode, and then into iBoot Upgrade Mode using the
	`upgrade` command. The structure of the packaged, however, must be checked before
	the software update can be installed.
]]
function MobileDevice:AMDeviceUpdateWithPackageBundlePath(restore_path:Folder):number
	if not self.Device then
		print("AMDeviceUpdateWithPackageBundlePath: Unable to locate device. Is the device connected?")
		return -1
	end
	
	if not restore_path:HasTag("iTunesUpdatePkg") then
		print("AMDeviceUpdateWithPackageBundlePath: Unable to install with update package. Package is not a valid iTunes Software Update.")
		return -1
	end
	
	print("AMDeviceUpdateWithPackageBundlePath: updating device with package "..restore_path:GetFullName())
	
	self.iBoot:reboot({Autoboot = false,BootCommand = ""},"iBootStage2")
	-- we also need to jump to iBootStage2 so we can perform the upgrade
	self.iBoot:JumpIntoSisterImage("iBootStage2")
	
	-- now, we gotta get the ramdisk and upload it
	local ramdisk = restore_path:FindFirstChild("ramdisk.dmg",true)
	if ramdisk ~= nil then
		self.iBoot:UploadRamdisk(ramdisk)
	end
	
	-- send the update contents to the ramdisk at /Library/Caches/MobileDeviceUpdateResources
	local UpdateContent = restore_path:FindFirstChild("updatepkgcontent",true)
	self.iBoot:UploadContentToRamdisk(UpdateContent,"MobileDeviceUpdateResources")
	local ASR_CMD = self.iBoot:GetFileFromRamdisk("asr")
	
	if not ASR_CMD then
		print("AMDeviceUpdateWithPackageBundlePath: ASR ramdisk command not found: No such file or directory")
		self.iBoot:RemoveCurrentRamdisk(true)
		
		self.iBoot:reboot({Autoboot = true,BootCommand = "fsboot"},"iBoot")
		return -1
	end
end

--[[
	MobileDevice.new(device:SurfaceGui)
	
	Creates a new MobileDevice session.
]]
MobileDevice.new = function(device:SurfaceGui)
	local self = setmetatable({},MobileDevice)
	
	if not device:HasTag("iPhoneOSDevice") then
		print("AppleMobileDevice: device "..device.Name.." is not a valid device.")
		return nil
	end
	
	print("AppleMobileDevice: Setting up MobileDevice connection with device "..device.Name)
	
	self.Device = device
	self.iBoot = require(self.Device.iPhone.boot["iBoot"]).new()
	self.DevRoot = self.Device.iPhone.rootfs
	
	return self
end

return MobileDevice

If you have any tips on how I can make this code cleaner, do let me know! Your feedback is greatly appreciated! :white_heart:

I’ll work on a dummy device for you guys to test out MobileDevice on in the meantime! For now, I’m working on ramdisks that allow you to transfer files from iBoot into the root filesystem.

With great love, Opuqide :white_heart:

1 Like

ok but uhh what does it do

2 Likes

MobleDevice is supposed to let you manage your Apple devices, and be able to download and install apps to it, install updates via computer, restoration (erasing the device and installing a fresh copy of an OS), sending videos, music, files, and data, and managing the device when it’s in recovery or DFU mode.

no shade but this doesnt do anything

and this means nothing :sob::sob:

yes im very well aware of that ;-;
but im still gonna work on the rest of the stuff tho

also that header is there cuz MobileDevice was originally made by Apple as a private framework (/System/Library/PrivateFrameworks/MobileDevice.framework)

Making Device in roblox is possible

Problem is limitations and performance, others things (depends)

You see it’s not easy since Luau has limitations

this literally doesnt do anything and wont work, youre just writing random stuff in a roblox script
you cant access anything outside the roblox game

Read the article linked in the post, you’ll see what I’m talking about.

I know isn’t, and I’m well aware that it’s sandboxed. But, this is part of my project. I’m trying my hardest to work on something that has been a dream of mine for three years, and I want to make it a reality in the digital world to show what I’m talking about.

so youre making an iphone in roblox?? :sob::sob:

thats right
ive been workin on this for 9 months now and my butt hurts from making it tho :sob: