Frustrated by rising App Store costs?
Missing the ability to write automation scripts like you do on your laptop or desktop?
Enjoy having your device’s hardware but want to do more with it?
With Scriptable, you can take almost complete control of your iOS device through customizable scripts—no app store restrictions or fees involved.
Leverage JavaScript to automate tasks, integrate with APIs, access device features, display analytics, or even streamline processes. Turn your iPhone into a programmable tool that works precisely the way you need it, maybe even more.
Customize and Automate Your iOS Device with Scriptable — Shape Your Own Digital World
Scriptable is a powerful automation application for iOS that enables developers and users to create custom scripts using JavaScript. The app integrates with the native APIs of iOS directly using JavaScript, allowing scripts to run from Siri Shortcuts, present tables, websites, and HTML in Siri, and perform operations on files through integration with the file system and Files.app.
Scriptable was developed by Simon B. Støvring and serves as a bridge between JavaScript and iOS's native functionality.
Scriptable provides it's own automation platform for iOS devices with the following capabilities:
- JavaScript Execution: Uses Apple's JavaScriptCore, which supports ECMAScript 6
- Native iOS API Integration: Direct access to iOS APIs from JavaScript code
- External API Integration: Full HTTP/HTTPS request capabilities for web APIs and services
- Siri Shortcuts Integration: Execute scripts through voice commands and shortcuts
- Widget Support: Run scripts directly on your Lock Screen and Home Screen using widgets
- File System Access: Full integration with iOS file system and Files.app
- Share Sheet Integration: Process inputs from share sheets across iOS apps
- Offline Documentation: Built-in API documentation available without internet connection
Scriptable excels at integrating with external APIs and web services through its robust networking capabilities:
- HTTP/HTTPS Requests: Full support for GET, POST, PUT, DELETE, and other HTTP methods with custom headers and request bodies
- REST API Integration: Seamless integration with RESTful web services
- JSON/XML Processing: Built-in support for parsing and generating JSON and XML data
- Authentication Support: Handle various authentication methods including API keys, OAuth, and custom headers
- Real-time Data: Fetch live data from weather services, social media APIs, IoT devices, and more
- Web Scraping: Parse HTML content from web pages for data extraction
- Visual Organization: Assign one of over 800 glyphs and a color to a script to easily identify it in your directory of scripts
- Quick Access: Run scripts by 3D touching the app icon
- File-Based Storage: Scripts are stored as plain JS files on disk
Scriptable operates as a JavaScript runtime environment on iOS, utilizing Apple's JavaScriptCore framework. Which provides:
- A JavaScript Engine: Full ES6 support for modern JavaScript features
- Native Bridge: Direct communication between JavaScript and iOS native APIs
- Network Layer: Built-in HTTP client for external API communication
- Sandboxed Environment: Secure execution within iOS security constraints
- Resource Management: Efficient memory and CPU usage for mobile devices
Scripts are stored as plain JS files on disk and executed within a controlled JavaScript environment. Unlike web browsers, Scriptable doesn't provide DOM objects or browser-specific APIs. Instead, it offers iOS-specific objects and functions.
- Script Loading: JavaScript file is loaded into memory
- Environment Setup: iOS-specific APIs and objects are made available
- Execution: Script runs from top to bottom, with support for async/await
- Completion: Script completion is reported to the system through Script.complete() or automatic detection
- Resource Cleanup: Memory and resources are freed after execution
Scripts can be executed through various mechanisms:
- Manual Execution: Direct launch from the Scriptable app
- Siri Shortcuts: Voice activation or automation triggers
- Widget Runtime: Automatic execution for Home Screen widgets
- Share Sheet: Triggered when content is shared to Scriptable
- URL Schemes: External app integration via custom URLs
- Background Refresh: Scheduled execution for data updates
Through its networking capabilities, your scripts can easily integrate with external APIs and web services:
Scriptable constructs requests that are sent to provided URLs using appropriate load methods. The Request class supports:
- Multiple HTTP Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
- Custom Headers: Authentication tokens, content types, user agents
- Request Body: JSON, form data, raw text, binary data
- Response Handling: JSON parsing, text content, binary data, images
- Error Handling: Network errors, HTTP status codes, timeout handling
Integrating APIs into a codebase is a common practice today. Many software applications rely on multiple APIs to provide data and functionality that users find valuable.
Scripts on Scriptable follows the same principle.
Common API integration patterns include:
- Weather Services: Fetch real-time weather data for widgets and applications.
- Social Media: Retrieve metrics like post counts, follower statistics, and recent posts.
- IoT Devices: Access sensor data from temperature probes, smart home devices, and other monitoring hardware.
- Financial Services: Get up-to-date stock prices, cryptocurrency values, account balances, and debt tracking.
- Web Services: Consume any RESTful API that returns data in formats like JSON or XML.
This seems very similar to userscripts, how do they compare?
- JavaScript-Based: Both use JavaScript for automation
- API Integration: Both can make HTTP requests to external services
- Automation Focus: Both designed to automate repetitive tasks
- Customization: Both allow deep customization of behavior
Execution Environment:
- Userscripts: Run within web browser context with DOM access
- Scriptable: Runs in native iOS environment with system API access
Target Platform:
- Userscripts: Web pages and browser-based content
- Scriptable: Native iOS features and mobile-specific functionality
Integration Points:
- Userscripts: Modify web page behavior, intercept web requests
- Scriptable: Integrate with native iOS APIs, run from Siri Shortcuts, present content in iOS interface
Distribution:
- Userscripts: Installed via browser extensions (Tampermonkey, Greasemonkey)
- Scriptable: Scripts stored as plain JS files in the app's file system
Capabilities:
-
Userscripts:
- DOM manipulation
- Web page modification
- Browser storage (localStorage, sessionStorage, cookies)
- Event handling on web pages
- Automating repetitive tasks in the browser
-
Scriptable (iOS):
- Sending local notifications
- Creating and customizing widgets
- Accessing the file system (reading/writing files)
- Using device camera and photo library
- Accessing location services (GPS)
- Network requests (fetching data from APIs)
- Running scripts on schedule or via widget interaction
Userscripts are better for:
- Modifying web page appearance or behavior
- Bypassing website limitations
- Enhancing web-based workflows
- Cross-site data integration
Scriptable is better for:
- Mobile device automation
- iOS system integration
- Native app-like experiences
- Offline-capable mobile widgets
- Location-based automation
- iOS device running iOS 12.0 or later
- Apple ID for App Store access
- Basic understanding of JavaScript (optional but recommended)
- Open the App Store on your iOS device
- Search for "Scriptable"
- Download and install the app (developed by Simon B. Støvring)
- Launch the app once installation is complete
-
Grant Permissions: Upon first launch, grant necessary permissions for:
- File system access
- Location services (if needed)
- Photos access (if needed)
- Calendar access (if needed)
-
Explore Sample Scripts: The app comes with several example scripts to get you started
- Review provided examples
- Run sample scripts to understand functionality
- Examine code structure and API usage
-
Configure Editor: The editor can be customized to match your preferences
- Set font size and theme
- Configure indentation preferences
- Enable/disable line numbers
- Set up keyboard shortcuts
-
Access Documentation:
- Use built-in offline documentation
- Reference API documentation for available methods
- Visit the community forum at talk.automators.fm for help and inspiration
- Open Scriptable app
- Tap the "+" button to create a new script
- Choose a name and icon for your script
- Write your JavaScript code using available APIs
- Test the script using the play button
- Save your script
-
Create Widget-Compatible Script:
- Ensure script returns appropriate data for widget display
- Handle different widget sizes (small, medium, large)
- Implement proper error handling
-
Add to Home Screen:
- Long-press on Home Screen
- Tap "+" to add widget
- Search for "Scriptable"
- Select widget size
- Configure widget to run your script
-
Widget Configuration:
- Set refresh interval
- Configure widget parameters
- Test widget functionality
-
Create Shortcut:
- Open Shortcuts app
- Create new shortcut
- Add "Run Script" action
- Select your Scriptable script
-
Configure Voice Command:
- Record phrase for Siri activation
- Test voice command functionality
- Set up automation triggers if needed
-
Export Script:
- Select script in Scriptable
- Use share button
- Choose export format (file or URL)
-
Import Script:
- Receive shared script file
- Open with Scriptable
- Review and modify as needed
-
File Management:
- Scripts stored as .js files
- Can be managed through Files.app
- Support for cloud storage integration
-
Backup Strategy:
- Export scripts regularly
- Store in iCloud or other cloud services
- Maintain version history manually
- Use async/await for asynchronous operations
- Implement proper error handling
- Comment code for future reference
- Test scripts thoroughly before deployment
- Minimize API calls where possible
- Cache data when appropriate
- Handle memory management efficiently
- Use appropriate data structures
- Validate all user inputs
- Secure API keys and sensitive data
- Follow iOS security guidelines
- Test permissions and access controls
- Regular script updates for iOS compatibility
- Monitor script performance
- Update deprecated API usage
- Maintain documentation for custom scripts
- Script Execution Errors: Check console output for detailed error messages
- API Access Problems: Verify required permissions are granted
- Widget Display Issues: Ensure widget-compatible code structure
- Siri Integration Problems: Check Shortcuts app configuration
- Built-in documentation within the app
- GitHub/Gitlab repositories filled with free samples
@author Mitul Patel