Skip to content

Commit 0e3fae6

Browse files
marchboldCopilot
andauthored
feat(tutorials): add a tutorial on using ios sdk and llvm to package ios applications on windows (#179)
* feat(tutorials): add a tutorial on using ios sdk and llvm to package ios applications on windows * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e33dc34 commit 0e3fae6

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

12.9 KB
Loading
25.7 KB
Loading
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
title: Packaging on Windows
3+
---
4+
5+
Packaging iOS applications on Windows is not supported by Apple, however, the AIR SDK has been able to get around this for a long time by creating stubs of the iOS SDK and using a specially packaged version of the open source Apple linker.
6+
7+
More recently, however, this has become more difficult as Apple have made changes to their toolchain and the AIR SDK can no longer successfully package all iOS applications on Windows. This becomes more apparent when trying to package applications that use more recent iOS SDK features, frameworks or capabilities, and particularly when swift code is involved.
8+
9+
You may run into issues like:
10+
11+
- Errors about missing symbols when packaging / linking (particularly related to swift)
12+
- Errors about framework signatures
13+
- Installation verification errors when installing on device
14+
15+
The simplest solution to these issues is to package your iOS applications on a Mac. However if you need to package on Windows then please see the following suggestions that may help you resolve some of these issues.
16+
17+
18+
## Providing an iOS SDK
19+
20+
The AIR SDK includes stubs of the iOS SDK to allow it to compile and link iOS applications. This may or may not include all the symbols and frameworks that your application needs.
21+
22+
However you can use a full version of the iOS SDK from a Mac to provide the missing symbols and frameworks.
23+
24+
25+
### Obtaining the iOS SDK
26+
27+
You can copy the iOS SDK from a Mac that has Xcode installed. The SDKs are located in the following folder:
28+
29+
```
30+
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
31+
```
32+
33+
You will see one or more folders named like `iPhoneOSXX.X.sdk` where `XX.X` is the version number of the SDK (e.g. `iPhoneOS18.4.sdk`).
34+
35+
:::note
36+
Avoid using the generic `iPhoneOS.sdk` name as this is a symbolic link to the latest version
37+
:::
38+
39+
You need to copy the entire `iPhoneOSXX.X.sdk` folder to your Windows machine. Due to the symbolic links in the SDK it is best to use a tool that can handle these correctly, such as `rsync` or `zip`. For example, you can use `zip` on the command line as below:
40+
41+
```
42+
zip -r iPhoneOS18.4.sdk.zip /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk
43+
```
44+
45+
:::note
46+
Make sure you use the actual version number of the SDK you are copying.
47+
:::
48+
49+
Copy this zip file to your Windows machine and extract it to a folder where you want to keep the iOS SDK (e.g. `C:\Users\yourname\work\sdks\ios\iPhoneOS18.4.sdk`).
50+
51+
52+
53+
### Configuring the AIR SDK
54+
55+
#### AIR SDK Manager
56+
57+
The easiest way to configure the AIR SDK to use the iOS SDK is to use the AIR SDK Manager application.
58+
59+
1. Open the AIR SDK Manager application
60+
2. Select the "Configuration" tab
61+
62+
![](images/airsdkmanager-configuration.png)
63+
64+
3. In the "iOS" section, find the "iOS Platform SDK" and either enter or browse for the path to the `iPhoneOSXX.X.sdk` folder that you extracted
65+
66+
![](images/airsdkmanager-iossdk-path.png)
67+
68+
4. Click "Apply" to save the configuration
69+
70+
Any iOS applications that you package using the AIR SDK will now use the provided iOS SDK.
71+
72+
73+
#### Configuration File
74+
75+
You can also configure the iOS SDK by editing the `adt.cfg` file located in the `~/.airsdk` folder of your user directory.
76+
77+
:::note
78+
This file is where the AIR SDK Manager saves its configuration, so if you have already configured the iOS SDK using the AIR SDK Manager then you should see the path already set in this file.
79+
:::
80+
81+
Add or edit the following line to point to the path of the `iPhoneOSXX.X.sdk` folder that you copied from the Mac:
82+
83+
84+
```
85+
...
86+
87+
iOSPlatformSDK=C:/Users/yourname/work/sdks/ios/iPhoneOS18.4.sdk
88+
89+
...
90+
```
91+
92+
This will configure the AIR SDK to use the provided iOS SDK for all iOS applications that you package.
93+
94+
95+
#### Command line
96+
97+
You can also configure a specific build command to use the iOS SDK by adding the `-platformsdk` option to your `adt` command.
98+
99+
```
100+
adt -package -target
101+
...
102+
-platformsdk "C:/Users/yourname/work/sdks/ios/iPhoneOS18.4.sdk"
103+
...
104+
```
105+
106+
This will configure the AIR SDK to use the provided iOS SDK for this specific packaging command only.
107+
108+
109+
## Installing the LLVM toolchain
110+
111+
:::info
112+
A lot of issues are solved by simply providing a full iOS SDK, however some issues may still remain due to limitations in the version of the Apple linker included in the AIR SDK.
113+
If after providing the iOS SDK you still have issues linking (for example, missing symbols when building) then you can try installing a more recent version of the LLVM toolchain for Windows.
114+
115+
This is not guaranteed to solve all issues, but it may help in some cases.
116+
:::
117+
118+
The AIR SDK uses a custom version of the Apple linker to create iOS applications on Windows.
119+
This is included in the AIR SDK but it is based on an older version of the Apple toolchain and may not work with all applications.
120+
121+
122+
### Installation
123+
124+
You can try installing a more recent version of the LLVM toolchain for Windows from here:
125+
126+
https://github.com/llvm/llvm-project
127+
128+
Download the installer executable appropriate for your system (e.g. `LLVM-15.0.7-win64.exe`) and run it to install the toolchain.
129+
130+
If you leave the default options selected it will install to `C:\Program Files\LLVM` and the AIR SDK will automatically find it.
131+
132+
However if you install it to a different location you will need to set the `LLVM_HOME` configuration in your `adt.cfg` file to point to the folder of the LLVM installation.
133+
For example:
134+
135+
```
136+
AndroidPlatformSDK=C:/Users/yourname/work/sdks/android
137+
iOSPlatformSDK=C:/Users/yourname/work/sdks/ios/iPhoneOS18.4.sdk
138+
LLVM_HOME=C:/Program Files/LLVM
139+
```
140+
141+
### Usage
142+
143+
You can confirm that the AIR SDK is using the LLVM toolchain by looking at the `adt.log` output when packaging an iOS application.
144+
You should see something like this:
145+
146+
```
147+
ld64 command line: C:/Program Files/LLVM/bin/ld64.lld.exe -pie -ObjC ...
148+
```
149+
150+
whereas if it is using the built-in linker you will see something like this (using `ld64.exe` from within the AIR SDK):
151+
152+
```
153+
ld64 command line: C:\AIRSDK_51.2.2\lib\aot/bin/ld64/ld64.exe -pie -ObjC ...
154+
```

0 commit comments

Comments
 (0)