Skip to content

Commit 2787545

Browse files
[clr-ios] Update iOS on CoreCLR docs (#120482)
* Update iOS on CoreCLR docs * Remove simulator creation command as it doesn't work --------- Co-authored-by: David Nguyen <[email protected]>
1 parent 7f76bea commit 2787545

File tree

1 file changed

+114
-15
lines changed
  • docs/workflow/building/coreclr

1 file changed

+114
-15
lines changed
Lines changed: 114 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,132 @@
1-
# Cross Compilation for iOS/tvOS Simulator on macOS
1+
# Experimental support of CoreCLR on iOS/tvOS
22

3-
## Requirements
3+
This is the internal documentation which outlines experimental support of CoreCLR on iOS/tvOS platforms.
44

5-
Build requirements are the same as for building native CoreCLR on macOS. iPhone SDK has to be enabled in Xcode installation.
5+
## Table of Contents
66

7-
## Cross compiling CoreCLR
7+
- [Building CoreCLR for iOS/tvOS](#building-coreclr-for-iostvos)
8+
- [macOS](#macos)
9+
- [Prerequisites](#prerequisites)
10+
- [Building the runtime, libraries and tools](#building-the-runtime-libraries-and-tools)
11+
- [Building and running a sample app](#building-and-running-a-sample-app)
12+
- [Building HelloiOS sample](#building-helloios-sample)
13+
- [Running HelloiOS sample on a simulator](#running-helloios-sample-on-a-simulator)
14+
- [Building and running tests on a simulator](#building-and-running-tests-on-a-simulator)
15+
- [Debugging the runtime and the sample app](#debugging-the-runtime-and-the-sample-app)
16+
- [Steps](#steps)
17+
- [See also](#see-also)
18+
- [Troubleshooting](#troubleshooting)
819

9-
Build the runtime pack and tools with
20+
## Building CoreCLR for iOS/tvOS
1021

22+
Supported host systems for building CoreCLR for iOS/tvOS:
23+
- [macOS](#macos)
24+
25+
Supported target platforms:
26+
- iOS Simulator ✔
27+
- tvOS Simulator ❌ (not yet supported)
28+
- Mac Catalyst ✔
29+
- iOS Device ✔
30+
- tvOS Device ❌ (not yet supported)
31+
32+
Supported target architectures:
33+
- x64 ✔
34+
- arm64 ✔
35+
36+
### macOS
37+
38+
#### Prerequisites
39+
40+
- macOS with Xcode installed
41+
- iPhone SDK enabled in Xcode installation
42+
- Build requirements are the same as for building native CoreCLR on macOS
43+
- Xcode command line tools installed:
44+
```bash
45+
xcode-select --install
46+
```
47+
48+
> [!NOTE]
49+
> Make sure you have accepted the Xcode license agreement:
50+
> ```bash
51+
> sudo xcodebuild -license accept
52+
> ```
53+
54+
#### Building the runtime, libraries and tools
55+
56+
To build CoreCLR runtime, libraries and tools, run the following command from `<repo-root>`:
57+
58+
```bash
59+
./build.sh clr+clr.runtime+libs+packs -os <ios|iossimulator|maccatalyst> -arch arm64 -cross -c <Debug|Checked>
1160
```
12-
./build.sh clr+clr.runtime+libs+packs -os [iossimulator/tvossimulator/maccatalyst] -arch [x64/arm64] -cross -c Release
61+
62+
> [!NOTE]
63+
> The runtime packages will be located at: `<repo-root>/artifacts/packages/<configuration>/Shipping/`
64+
65+
## Building and running a sample app
66+
67+
To demonstrate building and running an iOS application with CoreCLR, we will use the [HelloiOS sample app](../../../../src/mono/sample/iOS/Program.csproj).
68+
69+
A prerequisite for building and running samples locally is to have CoreCLR successfully built for the desired iOS platform.
70+
71+
### Building HelloiOS sample
72+
73+
To build `HelloiOS`, run the following command from `<repo-root>`:
74+
75+
```bash
76+
./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
1377
```
1478

15-
## Running the sample iOS app
79+
On successful execution, the command will output the iOS app bundle.
1680

17-
Build and run the sample app with
81+
### Running HelloiOS sample on a simulator
1882

83+
To run the sample on a simulator, run the following command from `<repo-root>`:
84+
85+
```bash
86+
./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
1987
```
20-
./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
88+
89+
The command also produces an Xcode project that can be opened for debugging:
90+
91+
```bash
92+
open ./src/mono/sample/iOS/bin/<ios|iossimulator|maccatalyst>-arm64/Bundle/HelloiOS/HelloiOS.xcodeproj
2193
```
2294

23-
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.
95+
> [!NOTE]
96+
> Make sure you have a simulator available. You can list available simulators with:
97+
> ```bash
98+
> xcrun simctl list devices
99+
> ```
24100
25-
## Running the runtime tests
101+
## Building and running tests on a simulator
26102
27-
Build the runtime tests with
103+
To build the runtime tests for iOS with CoreCLR, run the following command from `<repo-root>`:
28104
105+
```bash
106+
./src/tests/build.sh -os <iossimulator|tvossimulator> <x64|arm64> <Debug|Release> -p:UseMonoRuntime=false
29107
```
30-
./src/tests/build.sh -os iossimulator arm64 Release -p:UseMonoRuntime=false
31-
```
32108
33-
Running the tests is not implemented yet. It will likely need similar app bundle infrastructure as NativeAOT/iOS uses.
109+
> [!NOTE]
110+
> Running the tests is not fully implemented yet. It will likely need similar app bundle infrastructure as NativeAOT/iOS uses.
111+
112+
## Debugging the runtime and the sample app
113+
114+
Native debugging is supported through Xcode. You can debug both the managed portion of the sample app and the native CoreCLR runtime.
115+
116+
### Steps
117+
118+
1. Build the runtime and `HelloiOS` sample app in `Debug` configuration.
119+
2. Open the generated Xcode project:
120+
```bash
121+
open ./src/mono/sample/iOS/bin/<target>/Bundle/HelloiOS/HelloiOS.xcodeproj
122+
```
123+
3. In Xcode, set breakpoints in the native CoreCLR code or managed code as needed.
124+
4. Run the app in the iOS Simulator from Xcode to start debugging.
125+
5. Use Xcode's debugging tools to inspect variables, call stacks, and step through code.
126+
127+
> [!NOTE]
128+
> For debugging native CoreCLR code, you may need to build with debug symbols.
129+
130+
## See also
131+
132+
- [Building CoreCLR on macOS](../macos.md)

0 commit comments

Comments
 (0)