-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[clr-ios] Update iOS on CoreCLR docs #120482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kotlarmilos
merged 3 commits into
dotnet:main
from
kotlarmilos:improvement/clr-ios-update-docs
Oct 14, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,137 @@ | ||
# Cross Compilation for iOS/tvOS Simulator on macOS | ||
# Experimental support of CoreCLR on iOS/tvOS | ||
|
||
## Requirements | ||
This is the internal documentation which outlines experimental support of CoreCLR on iOS/tvOS platforms. | ||
|
||
Build requirements are the same as for building native CoreCLR on macOS. iPhone SDK has to be enabled in Xcode installation. | ||
## Table of Contents | ||
|
||
## Cross compiling CoreCLR | ||
- [Building CoreCLR for iOS/tvOS](#building-coreclr-for-iostvos) | ||
- [macOS](#macos) | ||
- [Prerequisites](#prerequisites) | ||
- [Building the runtime, libraries and tools](#building-the-runtime-libraries-and-tools) | ||
- [Building and running a sample app](#building-and-running-a-sample-app) | ||
- [Building HelloiOS sample](#building-helloios-sample) | ||
- [Running HelloiOS sample on a simulator](#running-helloios-sample-on-a-simulator) | ||
- [Building and running tests on a simulator](#building-and-running-tests-on-a-simulator) | ||
- [Debugging the runtime and the sample app](#debugging-the-runtime-and-the-sample-app) | ||
- [Steps](#steps) | ||
- [See also](#see-also) | ||
- [Troubleshooting](#troubleshooting) | ||
|
||
Build the runtime pack and tools with | ||
## Building CoreCLR for iOS/tvOS | ||
|
||
Supported host systems for building CoreCLR for iOS/tvOS: | ||
- [macOS](#macos) ✔ | ||
|
||
Supported target platforms: | ||
- iOS Simulator ✔ | ||
- tvOS Simulator ❌ (not yet supported) | ||
- Mac Catalyst ✔ | ||
- iOS Device ✔ | ||
- tvOS Device ❌ (not yet supported) | ||
|
||
Supported target architectures: | ||
- x64 ✔ | ||
- arm64 ✔ | ||
|
||
### macOS | ||
|
||
#### Prerequisites | ||
|
||
- macOS with Xcode installed | ||
- iPhone SDK enabled in Xcode installation | ||
- Build requirements are the same as for building native CoreCLR on macOS | ||
- Xcode command line tools installed: | ||
```bash | ||
xcode-select --install | ||
``` | ||
|
||
> [!NOTE] | ||
> Make sure you have accepted the Xcode license agreement: | ||
> ```bash | ||
> sudo xcodebuild -license accept | ||
> ``` | ||
|
||
#### Building the runtime, libraries and tools | ||
|
||
To build CoreCLR runtime, libraries and tools, run the following command from `<repo-root>`: | ||
|
||
```bash | ||
./build.sh clr+clr.runtime+libs+packs -os <ios|iossimulator|maccatalyst> -arch arm64 -cross -c <Debug|Checked> | ||
``` | ||
./build.sh clr+clr.runtime+libs+packs -os [iossimulator/tvossimulator/maccatalyst] -arch [x64/arm64] -cross -c Release | ||
|
||
> [!NOTE] | ||
> The runtime packages will be located at: `<repo-root>/artifacts/packages/<configuration>/Shipping/` | ||
|
||
## Building and running a sample app | ||
|
||
To demonstrate building and running an iOS application with CoreCLR, we will use the [HelloiOS sample app](../../../../src/mono/sample/iOS/Program.csproj). | ||
|
||
A prerequisite for building and running samples locally is to have CoreCLR successfully built for the desired iOS platform. | ||
|
||
### Building HelloiOS sample | ||
|
||
To build `HelloiOS`, run the following command from `<repo-root>`: | ||
|
||
```bash | ||
./dotnet.sh build src/mono/sample/iOS/Program.csproj -c <Debug|Checked> /p:TargetOS=<ios|iossimulator|maccatalyst> /p:TargetArchitecture=arm64 /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false | ||
``` | ||
|
||
## Running the sample iOS app | ||
On successful execution, the command will output the iOS app bundle. | ||
|
||
Build and run the sample app with | ||
### Running HelloiOS sample on a simulator | ||
|
||
To run the sample on a simulator, run the following command from `<repo-root>`: | ||
|
||
```bash | ||
./dotnet.sh publish src/mono/sample/iOS/Program.csproj -c <Debug|Checked> /p:TargetOS=<ios|iossimulator|maccatalyst> /p:TargetArchitecture=arm64 /p:DeployAndRun=true /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false | ||
``` | ||
./dotnet.sh publish src/mono/sample/iOS/Program.csproj -c Release /p:TargetOS=iossimulator /p:TargetArchitecture=arm64 /p:DeployAndRun=true /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false | ||
|
||
The command also produces an Xcode project that can be opened for debugging: | ||
|
||
```bash | ||
open ./src/mono/sample/iOS/bin/<ios|iossimulator|maccatalyst>-arm64/Bundle/HelloiOS/HelloiOS.xcodeproj | ||
``` | ||
|
||
The command also produces an Xcode project that can be opened with `open ./src/mono/sample/iOS/bin/iossimulator-arm64/Bundle/HelloiOS/HelloiOS.xcodeproj` and debugged in Xcode. | ||
> [!NOTE] | ||
> Make sure you have a simulator available. You can list available simulators with: | ||
> ```bash | ||
> xcrun simctl list devices | ||
> ``` | ||
> | ||
> If no simulators are available, create one using Xcode's Device Manager or the command line: | ||
> ```bash | ||
> xcrun simctl create "My iPhone" "iPhone 15" "iOS 17.0" | ||
> ``` | ||
kotlarmilos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Running the runtime tests | ||
## Building and running tests on a simulator | ||
|
||
Build the runtime tests with | ||
To build the runtime tests for iOS with CoreCLR, run the following command from `<repo-root>`: | ||
|
||
```bash | ||
./src/tests/build.sh -os <iossimulator|tvossimulator> <x64|arm64> <Debug|Release> -p:UseMonoRuntime=false | ||
``` | ||
./src/tests/build.sh -os iossimulator arm64 Release -p:UseMonoRuntime=false | ||
``` | ||
|
||
Running the tests is not implemented yet. It will likely need similar app bundle infrastructure as NativeAOT/iOS uses. | ||
> [!NOTE] | ||
> Running the tests is not fully implemented yet. It will likely need similar app bundle infrastructure as NativeAOT/iOS uses. | ||
|
||
## Debugging the runtime and the sample app | ||
|
||
Native debugging is supported through Xcode. You can debug both the managed portion of the sample app and the native CoreCLR runtime. | ||
|
||
### Steps | ||
|
||
1. Build the runtime and `HelloiOS` sample app in `Debug` configuration. | ||
2. Open the generated Xcode project: | ||
```bash | ||
open ./src/mono/sample/iOS/bin/<target>/Bundle/HelloiOS/HelloiOS.xcodeproj | ||
``` | ||
3. In Xcode, set breakpoints in the native CoreCLR code or managed code as needed. | ||
4. Run the app in the iOS Simulator from Xcode to start debugging. | ||
5. Use Xcode's debugging tools to inspect variables, call stacks, and step through code. | ||
|
||
> [!NOTE] | ||
> For debugging native CoreCLR code, you may need to build with debug symbols. | ||
|
||
## See also | ||
|
||
- [Building CoreCLR on macOS](../macos.md) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.