ipeddle 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ipeddle/__init__.py +3 -0
- ipeddle/__main__.py +3 -0
- ipeddle/build.py +309 -0
- ipeddle/cli.py +219 -0
- ipeddle/config.py +95 -0
- ipeddle/doctor.py +173 -0
- ipeddle/errors.py +11 -0
- ipeddle/fsutil.py +131 -0
- ipeddle/inspect.py +329 -0
- ipeddle/macho.py +281 -0
- ipeddle/mangling.py +136 -0
- ipeddle/package.py +309 -0
- ipeddle/patcher.py +247 -0
- ipeddle/paths.py +76 -0
- ipeddle/proc.py +58 -0
- ipeddle/runtime.py +73 -0
- ipeddle/scaffold.py +83 -0
- ipeddle/sdk.py +130 -0
- ipeddle/setup.py +309 -0
- ipeddle/swiftsdk.py +143 -0
- ipeddle/tbd.py +308 -0
- ipeddle/toolchain.py +194 -0
- ipeddle/ui.py +56 -0
- ipeddle/xip.py +213 -0
- ipeddle-0.1.0.dist-info/METADATA +272 -0
- ipeddle-0.1.0.dist-info/RECORD +30 -0
- ipeddle-0.1.0.dist-info/WHEEL +4 -0
- ipeddle-0.1.0.dist-info/entry_points.txt +2 -0
- ipeddle-0.1.0.dist-info/licenses/LICENSE +201 -0
- ipeddle-0.1.0.dist-info/licenses/NOTICE +27 -0
ipeddle/ui.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Console output helpers (plain text, colours only on a TTY)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
_COLOR = sys.stderr.isatty() and os.environ.get("NO_COLOR") is None
|
|
10
|
+
VERBOSE = bool(os.environ.get("IPEDDLE_VERBOSE"))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _c(code: str, s: str) -> str:
|
|
14
|
+
return f"\033[{code}m{s}\033[0m" if _COLOR else s
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def step(msg: str) -> None:
|
|
18
|
+
print(_c("1;34", "==>") + " " + msg, file=sys.stderr, flush=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def info(msg: str) -> None:
|
|
22
|
+
print(" " + msg, file=sys.stderr, flush=True)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def ok(msg: str) -> None:
|
|
26
|
+
print(_c("32", " ok ") + " " + msg, file=sys.stderr, flush=True)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def warn(msg: str) -> None:
|
|
30
|
+
print(_c("33", "warn") + " " + msg, file=sys.stderr, flush=True)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def fail(msg: str) -> None:
|
|
34
|
+
print(_c("31", "FAIL") + " " + msg, file=sys.stderr, flush=True)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def debug(msg: str) -> None:
|
|
38
|
+
if VERBOSE:
|
|
39
|
+
print(_c("2", " .. " + msg), file=sys.stderr, flush=True)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Timer:
|
|
43
|
+
def __init__(self) -> None:
|
|
44
|
+
self.t0 = time.monotonic()
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def seconds(self) -> float:
|
|
48
|
+
return time.monotonic() - self.t0
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def human_bytes(n: float) -> str:
|
|
52
|
+
for unit in ("B", "KB", "MB", "GB", "TB"):
|
|
53
|
+
if abs(n) < 1024 or unit == "TB":
|
|
54
|
+
return f"{n:.0f} {unit}" if unit == "B" else f"{n:.1f} {unit}"
|
|
55
|
+
n /= 1024
|
|
56
|
+
return f"{n:.1f} TB"
|
ipeddle/xip.py
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""Stream the iOS SDK out of an ``Xcode.xip`` without unpacking all of Xcode.
|
|
2
|
+
|
|
3
|
+
An ``.xip`` is a XAR archive whose ``Content`` file is a *pbzx* stream
|
|
4
|
+
(chunks of xz) wrapping a cpio (``odc``) archive. We read it once, front to
|
|
5
|
+
back, and write only the members whose path matches a wanted prefix, so a
|
|
6
|
+
4 GB download needs about 1 GB of free disk instead of 40 GB.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import io
|
|
12
|
+
import lzma
|
|
13
|
+
import os
|
|
14
|
+
import re
|
|
15
|
+
import struct
|
|
16
|
+
import xml.etree.ElementTree as ET
|
|
17
|
+
import zlib
|
|
18
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
from .errors import IpeddleError
|
|
22
|
+
|
|
23
|
+
XAR_MAGIC = b"xar!"
|
|
24
|
+
PBZX_MAGIC = b"pbzx"
|
|
25
|
+
CPIO_ODC = b"070707"
|
|
26
|
+
|
|
27
|
+
SDK_RE = re.compile(r"(?:^|/)Platforms/iPhoneOS\.platform/Developer/SDKs/(iPhoneOS[0-9.]*\.sdk)(/.*)?$")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def xar_content_range(fh) -> tuple[int, int, str]:
|
|
31
|
+
"""Return (absolute offset, length, encoding) of the ``Content`` file."""
|
|
32
|
+
head = fh.read(28)
|
|
33
|
+
if len(head) < 28 or head[:4] != XAR_MAGIC:
|
|
34
|
+
raise IpeddleError("not a .xip/.xar file (bad magic)")
|
|
35
|
+
hsize, _ver, toc_c, _toc_u, _alg = struct.unpack(">HHQQI", head[4:28])
|
|
36
|
+
fh.seek(hsize)
|
|
37
|
+
toc = zlib.decompress(fh.read(toc_c))
|
|
38
|
+
heap = hsize + toc_c
|
|
39
|
+
root = ET.fromstring(toc)
|
|
40
|
+
for f in root.iter("file"):
|
|
41
|
+
name = f.findtext("name")
|
|
42
|
+
if name == "Content":
|
|
43
|
+
data = f.find("data")
|
|
44
|
+
if data is None:
|
|
45
|
+
break
|
|
46
|
+
off = int(data.findtext("offset", "0"))
|
|
47
|
+
length = int(data.findtext("length", "0"))
|
|
48
|
+
enc = data.find("encoding")
|
|
49
|
+
style = enc.get("style", "") if enc is not None else ""
|
|
50
|
+
return heap + off, length, style
|
|
51
|
+
raise IpeddleError("the .xip has no Content entry")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _pbzx_chunks(fh, end: int):
|
|
55
|
+
magic = fh.read(4)
|
|
56
|
+
if magic != PBZX_MAGIC:
|
|
57
|
+
raise IpeddleError("unsupported .xip payload (not pbzx)")
|
|
58
|
+
fh.read(8) # flags / chunk size
|
|
59
|
+
while fh.tell() < end:
|
|
60
|
+
hdr = fh.read(16)
|
|
61
|
+
if len(hdr) < 16:
|
|
62
|
+
break
|
|
63
|
+
usize, csize = struct.unpack(">QQ", hdr)
|
|
64
|
+
data = fh.read(csize)
|
|
65
|
+
if len(data) != csize:
|
|
66
|
+
raise IpeddleError("truncated .xip")
|
|
67
|
+
yield usize, csize, data
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _inflate(chunk):
|
|
71
|
+
usize, csize, data = chunk
|
|
72
|
+
if csize == usize:
|
|
73
|
+
return data
|
|
74
|
+
return lzma.decompress(data)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class _ChunkReader(io.RawIOBase):
|
|
78
|
+
"""File-like view over decompressed pbzx chunks (decompressed in parallel)."""
|
|
79
|
+
|
|
80
|
+
def __init__(self, fh, end: int, workers: int):
|
|
81
|
+
self._pool = ThreadPoolExecutor(max_workers=workers)
|
|
82
|
+
self._futs = []
|
|
83
|
+
self._src = _pbzx_chunks(fh, end)
|
|
84
|
+
self._buf = b""
|
|
85
|
+
self._window = workers * 2
|
|
86
|
+
self._fill()
|
|
87
|
+
|
|
88
|
+
def _fill(self):
|
|
89
|
+
while len(self._futs) < self._window:
|
|
90
|
+
try:
|
|
91
|
+
c = next(self._src)
|
|
92
|
+
except StopIteration:
|
|
93
|
+
break
|
|
94
|
+
self._futs.append(self._pool.submit(_inflate, c))
|
|
95
|
+
|
|
96
|
+
def readable(self):
|
|
97
|
+
return True
|
|
98
|
+
|
|
99
|
+
def readinto(self, b):
|
|
100
|
+
while not self._buf:
|
|
101
|
+
if not self._futs:
|
|
102
|
+
return 0
|
|
103
|
+
self._buf = self._futs.pop(0).result()
|
|
104
|
+
self._fill()
|
|
105
|
+
n = min(len(b), len(self._buf))
|
|
106
|
+
b[:n] = self._buf[:n]
|
|
107
|
+
self._buf = self._buf[n:]
|
|
108
|
+
return n
|
|
109
|
+
|
|
110
|
+
def close(self):
|
|
111
|
+
self._pool.shutdown(wait=False, cancel_futures=True)
|
|
112
|
+
super().close()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _read_exact(r, n: int) -> bytes:
|
|
116
|
+
out = bytearray()
|
|
117
|
+
while len(out) < n:
|
|
118
|
+
b = r.read(n - len(out))
|
|
119
|
+
if not b:
|
|
120
|
+
raise IpeddleError("unexpected end of cpio stream")
|
|
121
|
+
out += b
|
|
122
|
+
return bytes(out)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _skip(r, n: int) -> None:
|
|
126
|
+
while n > 0:
|
|
127
|
+
b = r.read(min(n, 1 << 20))
|
|
128
|
+
if not b:
|
|
129
|
+
raise IpeddleError("unexpected end of cpio stream")
|
|
130
|
+
n -= len(b)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def extract_cpio(stream, want, dest: Path) -> int:
|
|
134
|
+
"""Extract members for which ``want(path)`` returns a destination
|
|
135
|
+
relative path (or None to skip). Returns the number of files written."""
|
|
136
|
+
written = 0
|
|
137
|
+
links: dict[tuple[int, int], Path] = {}
|
|
138
|
+
while True:
|
|
139
|
+
hdr = _read_exact(stream, 76)
|
|
140
|
+
if hdr[:6] != CPIO_ODC:
|
|
141
|
+
raise IpeddleError("unsupported cpio format inside .xip")
|
|
142
|
+
dev = int(hdr[6:12], 8)
|
|
143
|
+
ino = int(hdr[12:18], 8)
|
|
144
|
+
mode = int(hdr[18:24], 8)
|
|
145
|
+
nlink = int(hdr[36:42], 8)
|
|
146
|
+
namesize = int(hdr[59:65], 8)
|
|
147
|
+
filesize = int(hdr[65:76], 8)
|
|
148
|
+
name = _read_exact(stream, namesize)[:-1].decode("utf-8", "replace")
|
|
149
|
+
if name == "TRAILER!!!":
|
|
150
|
+
return written
|
|
151
|
+
rel = want(name)
|
|
152
|
+
if rel is None:
|
|
153
|
+
_skip(stream, filesize)
|
|
154
|
+
continue
|
|
155
|
+
out = dest / rel
|
|
156
|
+
kind = mode & 0o170000
|
|
157
|
+
if kind == 0o040000:
|
|
158
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
159
|
+
_skip(stream, filesize)
|
|
160
|
+
continue
|
|
161
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
162
|
+
if out.is_symlink() or out.exists():
|
|
163
|
+
out.unlink()
|
|
164
|
+
if kind == 0o120000:
|
|
165
|
+
target = _read_exact(stream, filesize).decode("utf-8", "replace")
|
|
166
|
+
os.symlink(target, out)
|
|
167
|
+
continue
|
|
168
|
+
if kind != 0o100000:
|
|
169
|
+
_skip(stream, filesize)
|
|
170
|
+
continue
|
|
171
|
+
key = (dev, ino)
|
|
172
|
+
if filesize == 0 and nlink > 1 and key in links:
|
|
173
|
+
os.link(links[key], out)
|
|
174
|
+
continue
|
|
175
|
+
with open(out, "wb") as fh:
|
|
176
|
+
left = filesize
|
|
177
|
+
while left:
|
|
178
|
+
b = stream.read(min(left, 1 << 20))
|
|
179
|
+
if not b:
|
|
180
|
+
raise IpeddleError("unexpected end of cpio stream")
|
|
181
|
+
fh.write(b)
|
|
182
|
+
left -= len(b)
|
|
183
|
+
os.chmod(out, mode & 0o777 or 0o644)
|
|
184
|
+
if nlink > 1:
|
|
185
|
+
links[key] = out
|
|
186
|
+
written += 1
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def extract_sdk(xip: Path, dest: Path, workers: int | None = None) -> Path:
|
|
190
|
+
"""Extract ``iPhoneOS*.sdk`` from ``xip`` into ``dest``; return the SDK dir."""
|
|
191
|
+
workers = workers or max(1, min(8, os.cpu_count() or 1))
|
|
192
|
+
found: dict[str, int] = {}
|
|
193
|
+
|
|
194
|
+
def want(path: str):
|
|
195
|
+
m = SDK_RE.search(path)
|
|
196
|
+
if not m:
|
|
197
|
+
return None
|
|
198
|
+
found[m.group(1)] = found.get(m.group(1), 0) + 1
|
|
199
|
+
return m.group(1) + (m.group(2) or "")
|
|
200
|
+
|
|
201
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
202
|
+
with open(xip, "rb") as fh:
|
|
203
|
+
off, length, _enc = xar_content_range(fh)
|
|
204
|
+
fh.seek(off)
|
|
205
|
+
reader = _ChunkReader(fh, off + length, workers)
|
|
206
|
+
try:
|
|
207
|
+
extract_cpio(io.BufferedReader(reader, 1 << 20), want, dest)
|
|
208
|
+
finally:
|
|
209
|
+
reader.close()
|
|
210
|
+
sdks = sorted(k for k in found if (dest / k).is_dir() and not (dest / k).is_symlink())
|
|
211
|
+
if not sdks:
|
|
212
|
+
raise IpeddleError(f"no iPhoneOS SDK found inside {xip.name}")
|
|
213
|
+
return dest / sdks[-1]
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ipeddle
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Build iOS apps (.ipa) on Linux, no Mac or Xcode required — the Gradle of iOS.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Neguiolidas/ipeddle
|
|
6
|
+
Project-URL: Issues, https://github.com/Neguiolidas/ipeddle/issues
|
|
7
|
+
Author: Neguiolidas
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Keywords: build,cross-compile,ios,ipa,linux,swift,swiftpm
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: tomli>=1.1; python_version < '3.11'
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
24
|
+
Provides-Extra: icons
|
|
25
|
+
Requires-Dist: pillow>=9; extra == 'icons'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# ipeddle
|
|
29
|
+
|
|
30
|
+
**Build iOS apps on Linux. No Mac, no Xcode.** · [Português](https://github.com/Neguiolidas/ipeddle/blob/main/README.pt-BR.md)
|
|
31
|
+
|
|
32
|
+
ipeddle is to iOS what Gradle is to Android: one command line tool that takes
|
|
33
|
+
your app's source and gives you an installable package. You write a SwiftPM
|
|
34
|
+
app, run `ipeddle build`, and get an unsigned `.ipa` that you can sign and
|
|
35
|
+
install on your iPhone with Sideloadly or AltStore and a free Apple ID.
|
|
36
|
+
|
|
37
|
+
```console
|
|
38
|
+
$ pipx install ipeddle
|
|
39
|
+
$ ipeddle setup # once: Swift for Linux, an iOS linker, the iOS SDK
|
|
40
|
+
$ ipeddle build examples/hello
|
|
41
|
+
==> building Hello (release, iOS 16.0+, dev.ipeddle.example.hello)
|
|
42
|
+
[5/7] Compiling Hello HelloApp.swift
|
|
43
|
+
[6/7] Linking Hello
|
|
44
|
+
==> packaging
|
|
45
|
+
ok examples/hello/.build/Hello.ipa (37.6 KB, unsigned) in 2.3s
|
|
46
|
+
$ ipeddle inspect examples/hello/.build/Hello.ipa
|
|
47
|
+
App: Hello.app (dev.ipeddle.example.hello)
|
|
48
|
+
Executable: Hello [arm64]
|
|
49
|
+
Platform: iOS min 16.0 (built with SDK 18.6)
|
|
50
|
+
Links: 29 libraries, 146 imported symbols
|
|
51
|
+
Result: OK
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> Status: **alpha (0.1.0)**. Pure-SwiftPM apps (SwiftUI or UIKit, Swift and
|
|
55
|
+
> C/Objective-C targets, resources, binary xcframeworks) build. Read
|
|
56
|
+
> [Limitations](#limitations) before relying on it.
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
* Linux x86_64 or aarch64 (Ubuntu 22.04/24.04, Debian 12/13, Fedora, RHEL-likes).
|
|
61
|
+
On Windows use WSL2. On a Mac, just use Xcode.
|
|
62
|
+
* Python 3.10+ and `git`.
|
|
63
|
+
* About 4 GB of free disk for setup (Swift ~2.5 GB, SDK ~0.6 GB, caches).
|
|
64
|
+
* The system libraries the Swift toolchain needs, see
|
|
65
|
+
<https://www.swift.org/install/linux/> (on Ubuntu:
|
|
66
|
+
`sudo apt install binutils git libc6-dev libcurl4-openssl-dev libedit2 libgcc-13-dev libstdc++-13-dev libxml2-dev libncurses-dev libz3-dev pkg-config tzdata unzip zlib1g-dev`).
|
|
67
|
+
|
|
68
|
+
`ipeddle doctor` checks all of this and tells you what is missing.
|
|
69
|
+
|
|
70
|
+
## Quick start
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pipx install ipeddle # or: pip install --user ipeddle ('ipeddle[icons]' to resize app icons)
|
|
74
|
+
# latest from git: pipx install git+https://github.com/Neguiolidas/ipeddle
|
|
75
|
+
ipeddle doctor # what is there, what is missing, how to fix it
|
|
76
|
+
ipeddle setup # ~5-10 min the first time, mostly downloads
|
|
77
|
+
git clone https://github.com/Neguiolidas/ipeddle && cd ipeddle
|
|
78
|
+
ipeddle build examples/hello --inspect
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The `.ipa` is in `examples/hello/.build/Hello.ipa`. To put it on a phone:
|
|
82
|
+
|
|
83
|
+
1. Install [Sideloadly](https://sideloadly.io) (Windows/macOS) or
|
|
84
|
+
[AltStore](https://altstore.io).
|
|
85
|
+
2. Plug in the iPhone, drop the `.ipa` in, sign in with your Apple ID (a free
|
|
86
|
+
one works; apps then expire after 7 days and you re-install).
|
|
87
|
+
3. On the phone: Settings → General → VPN & Device Management → trust your
|
|
88
|
+
Apple ID. On iOS 16+ also enable Settings → Privacy & Security → Developer Mode.
|
|
89
|
+
|
|
90
|
+
## Commands
|
|
91
|
+
|
|
92
|
+
| Command | What it does |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `ipeddle init DIR` | Creates a minimal SwiftUI app (`Package.swift`, `ipeddle.toml`, `.gitignore`) to start from. |
|
|
95
|
+
| `ipeddle doctor [--deep]` | Checks Python, OS, disk, the toolchain, the linker, the SDK; `--deep` also compiles and links a test program. |
|
|
96
|
+
| `ipeddle setup` | Downloads Swift for Linux and the linker, fetches the iOS SDK, prepares it. Idempotent: re-running only does what is missing. |
|
|
97
|
+
| `ipeddle build [DIR]` | Builds the SwiftPM app in `DIR` into `DIR/.build/<App>.ipa` (`-o` to choose). `-c debug`, `--product`, `--clean`, `--inspect`. |
|
|
98
|
+
| `ipeddle inspect FILE` | Checks an `.ipa` or `.app`: architectures, minimum iOS, Info.plist, embedded frameworks, and that every imported symbol exists in the library it is bound to. `--json` for scripts. |
|
|
99
|
+
| `ipeddle clean [DIR]` | Deletes temporary files, an app's `.build`, or with `--all` everything ipeddle installed. |
|
|
100
|
+
|
|
101
|
+
Setup options: `--swift DIR` (use a toolchain you have), `--linker FILE`,
|
|
102
|
+
`--sdk DIR` (an `iPhoneOS*.sdk` you have), `--xip FILE` (extract the SDK from
|
|
103
|
+
an `Xcode_*.xip` you downloaded from Apple; only the SDK is written to disk),
|
|
104
|
+
`--sdk-version` (default 18.6), `--force`, `--no-download`. `ipeddle clean
|
|
105
|
+
--cache` empties the shared module cache. Everything lives
|
|
106
|
+
in `$IPEDDLE_HOME` (default `~/.local/share/ipeddle`).
|
|
107
|
+
|
|
108
|
+
## Making an app ipeddle can build
|
|
109
|
+
|
|
110
|
+
An ipeddle app is a regular Swift package with an executable product and an
|
|
111
|
+
iOS platform. See [`examples/hello`](https://github.com/Neguiolidas/ipeddle/tree/main/examples/hello):
|
|
112
|
+
|
|
113
|
+
```swift
|
|
114
|
+
// swift-tools-version: 5.9
|
|
115
|
+
import PackageDescription
|
|
116
|
+
|
|
117
|
+
let package = Package(
|
|
118
|
+
name: "Hello",
|
|
119
|
+
platforms: [.iOS(.v16)],
|
|
120
|
+
products: [.executable(name: "Hello", targets: ["Hello"])],
|
|
121
|
+
targets: [
|
|
122
|
+
.executableTarget(name: "Hello", resources: [.process("Resources")]),
|
|
123
|
+
]
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The `@main` SwiftUI `App` (or a UIKit `UIApplicationMain`) lives in the
|
|
128
|
+
executable target. App settings go in an optional `ipeddle.toml`:
|
|
129
|
+
|
|
130
|
+
```toml
|
|
131
|
+
[app]
|
|
132
|
+
product = "Hello" # which executable product to package
|
|
133
|
+
bundle-id = "com.example.hello" # default: dev.ipeddle.<product>
|
|
134
|
+
display-name = "Hello"
|
|
135
|
+
version = "1.0.0" # CFBundleShortVersionString
|
|
136
|
+
build = "1" # CFBundleVersion
|
|
137
|
+
icon = "Icon.png" # square PNG, 1024x1024 recommended
|
|
138
|
+
info-plist = "Info.plist" # extra keys (permissions, URL types...); $(VARS) are expanded
|
|
139
|
+
resources = ["Extra"] # files/folders copied into the .app as-is
|
|
140
|
+
device-family = ["iphone", "ipad"]
|
|
141
|
+
swiftc-flags = []
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## How it works
|
|
145
|
+
|
|
146
|
+
Apple's toolchain is open source; what makes "iOS on Linux" hard is
|
|
147
|
+
everything around it. ipeddle puts these pieces together on your machine:
|
|
148
|
+
|
|
149
|
+
1. **Compiler.** The official Swift toolchain for Linux already contains
|
|
150
|
+
`swiftc`, `clang` and `llvm-ar` with the ARM64/Darwin backends.
|
|
151
|
+
2. **Linker.** The Linux toolchain's `ld64.lld` refuses iOS, so setup downloads
|
|
152
|
+
the ld64-compatible `lld` that the [xtool](https://github.com/xtool-org/xtool)
|
|
153
|
+
project publishes.
|
|
154
|
+
3. **SDK.** Headers, `.swiftinterface` files and `.tbd` stubs for iOS. By
|
|
155
|
+
default setup makes a sparse, shallow `git` checkout of a public mirror
|
|
156
|
+
(only the one SDK folder, a few hundred MB). You can point it at an SDK you
|
|
157
|
+
already have, or at an `Xcode.xip` (streamed: only the SDK is extracted).
|
|
158
|
+
4. **SDK patches, generated on your machine.** Public SDK mirrors carry
|
|
159
|
+
*reconstructed* `.tbd` stubs that describe the newest iOS layout, so a
|
|
160
|
+
naively linked app crashes on older iOS. ipeddle copies the SDK (hard links,
|
|
161
|
+
so it costs almost no disk) and rewrites the stubs with rules derived from
|
|
162
|
+
the SDK itself, never from a hand-made list:
|
|
163
|
+
* **Swift overlays.** Until iOS 17 the Swift half of a framework
|
|
164
|
+
(`Foundation`'s `Data`, `URLRequest`...) lived in
|
|
165
|
+
`/usr/lib/swift/libswiftFoundation.dylib`; since iOS 18 it lives in the
|
|
166
|
+
framework. Every Swift symbol whose mangled name says it belongs to module
|
|
167
|
+
*X* is moved from the framework's stub to `libswiftX`'s stub. Binding
|
|
168
|
+
through the overlay works on both old and new systems.
|
|
169
|
+
* **Split frameworks.** Declarations moved to a new framework keep their
|
|
170
|
+
original mangling (`@_originallyDefinedIn`), e.g. `SwiftUICore` split
|
|
171
|
+
out of `SwiftUI` in iOS 18. Such symbols are moved back into the parent
|
|
172
|
+
that re-exports the child, so the app never links the child and still
|
|
173
|
+
launches on iOS 15-17.
|
|
174
|
+
* **Missing symbols.** If the link fails on Swift symbols the stubs do not
|
|
175
|
+
list at all, ipeddle works out the owning module from the mangled name,
|
|
176
|
+
declares them in that module's overlay, and relinks. What it learns is
|
|
177
|
+
kept in the patched SDK for every later build.
|
|
178
|
+
5. **Runtime bits.** Xcode ships `libclang_rt.ios.a`; ipeddle compiles the
|
|
179
|
+
one routine apps need from it (`__isPlatformVersionAtLeast`, used by
|
|
180
|
+
`#available` / `@available`) from its own source at setup.
|
|
181
|
+
6. **Build and package.** `swift build` cross-compiles with a generated Swift
|
|
182
|
+
SDK bundle; ipeddle then assembles `Payload/<App>.app` (binary, resource
|
|
183
|
+
bundles, frameworks, Info.plist, icons) and zips a reproducible `.ipa`.
|
|
184
|
+
|
|
185
|
+
### Caching
|
|
186
|
+
|
|
187
|
+
* The SDK's Swift and Clang modules (Swift, Foundation, UIKit, SwiftUI...) are
|
|
188
|
+
compiled into **one module cache shared by all your apps**. Setup ends with a
|
|
189
|
+
test compile that also fills it, so even the first build of a new app is fast.
|
|
190
|
+
* SwiftPM's incremental build does the rest; the `.ipa` step takes milliseconds.
|
|
191
|
+
* When the SDK stubs change (re-setup, learned symbols), the next build relinks.
|
|
192
|
+
|
|
193
|
+
Measured on a 16-core Linux box with `examples/hello`:
|
|
194
|
+
|
|
195
|
+
| Build | Time |
|
|
196
|
+
|---|---|
|
|
197
|
+
| very first compile, empty module cache | 68 s |
|
|
198
|
+
| first build of an app after `ipeddle setup` (cache filled by setup) | 2.0 s |
|
|
199
|
+
| `--clean` rebuild | 2.1 s |
|
|
200
|
+
| rebuild with no changes | 0.7 s |
|
|
201
|
+
|
|
202
|
+
## Limitations
|
|
203
|
+
|
|
204
|
+
Honest list. Some are fundamental, some are just not done yet.
|
|
205
|
+
|
|
206
|
+
* **No code signing.** The `.ipa` is unsigned. Sideloadly/AltStore sign it
|
|
207
|
+
with your Apple ID; App Store / TestFlight distribution still needs Apple's
|
|
208
|
+
tools and a paid developer account.
|
|
209
|
+
* **No asset catalogs (`actool`).** `.xcassets` cannot be compiled. ipeddle
|
|
210
|
+
falls back: the app icon is taken from `icon` (or the largest PNG of an
|
|
211
|
+
`AppIcon` set), and image sets are bundled as loose `name@2x.png` files,
|
|
212
|
+
which `UIImage(named:)` and `Image("name")` find. Color sets, data sets and
|
|
213
|
+
symbol sets are not supported; define them in code.
|
|
214
|
+
* **No Interface Builder (`ibtool`).** Storyboards and XIBs are not compiled;
|
|
215
|
+
build UI in code (SwiftUI or UIKit). The launch screen comes from
|
|
216
|
+
`UILaunchScreen` in Info.plist.
|
|
217
|
+
* **SwiftPM projects only.** `.xcodeproj` / `.xcworkspace` projects are not
|
|
218
|
+
read. CocoaPods are not supported; SwiftPM dependencies and binary
|
|
219
|
+
`.xcframework` targets are.
|
|
220
|
+
* **Device builds only** (arm64). There is no iOS Simulator on Linux.
|
|
221
|
+
* **iOS 15 or newer.** Older deployment targets need back-deployment
|
|
222
|
+
libraries that only ship with Xcode.
|
|
223
|
+
* **Public SDK caveats.** The symbol rules are derived from the SDK and
|
|
224
|
+
`examples/hello` (SwiftUI, Foundation, a C target with `#available`) and a
|
|
225
|
+
UIKit + PhotosUI app built from the 18.6 SDK were launched on iOS 16.7, but
|
|
226
|
+
the rules are heuristics over reconstructed stubs: a symbol that lived in a different library on some
|
|
227
|
+
older iOS version than the stubs suggest will fail at launch on that
|
|
228
|
+
version. `ipeddle inspect` catches symbols the SDK does not export at all,
|
|
229
|
+
not this case. Test on the oldest iOS you support.
|
|
230
|
+
* **Macros.** Macros that ship with the Swift toolchain (`@Observable`,
|
|
231
|
+
`#Predicate`...) work; SwiftUI's `#Preview` and other Apple-only macro
|
|
232
|
+
plugins do not (remove `#Preview` blocks or wrap them in `#if DEBUG` checks you
|
|
233
|
+
do not build).
|
|
234
|
+
* **Embedded dynamic frameworks** (from binary `.xcframework` targets) are
|
|
235
|
+
packaged the way Xcode does it (`Frameworks/`, stripped of headers and
|
|
236
|
+
modules, `@executable_path/Frameworks` rpath) and pass `ipeddle inspect`,
|
|
237
|
+
but have not yet been launched on a real device.
|
|
238
|
+
* **Less-tested inputs.** Development used the public mirror's 18.6 SDK.
|
|
239
|
+
SDKs extracted from an Xcode `.xip` use the same code path but have had
|
|
240
|
+
less testing; downloads are checked for completeness, not signatures.
|
|
241
|
+
* **No dSYMs** (`-debug-info-format none`), so crash logs are not symbolicated.
|
|
242
|
+
* SwiftPM prints a deprecation warning for the `native` build system that
|
|
243
|
+
ipeddle uses; a future Swift release may require changes.
|
|
244
|
+
|
|
245
|
+
## Legal
|
|
246
|
+
|
|
247
|
+
ipeddle is licensed under the Apache License 2.0 and contains no Apple
|
|
248
|
+
software. The iOS SDK is downloaded by **you**, onto **your** machine, from a
|
|
249
|
+
source **you** choose, and Apple's license terms apply to it (Apple's Xcode
|
|
250
|
+
and SDK agreement allows use on Apple-branded computers; whether and how you
|
|
251
|
+
may use the SDK elsewhere is between you and Apple). ipeddle does not
|
|
252
|
+
redistribute SDK files and the patched copy never leaves your machine.
|
|
253
|
+
|
|
254
|
+
ipeddle is not affiliated with, endorsed by, or sponsored by Apple Inc.
|
|
255
|
+
iOS, iPhone, iPad, Xcode and Swift are trademarks of Apple Inc.
|
|
256
|
+
|
|
257
|
+
## Acknowledgements
|
|
258
|
+
|
|
259
|
+
* [xtool](https://github.com/xtool-org/xtool) (MIT) pioneered Xcode-free iOS
|
|
260
|
+
builds on Linux; ipeddle downloads its ld64-compatible linker.
|
|
261
|
+
* The [Swift project](https://swift.org) for the Linux toolchain.
|
|
262
|
+
|
|
263
|
+
## Contributing
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
pip install -e '.[dev]'
|
|
267
|
+
ruff check src tests
|
|
268
|
+
pytest
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Unit tests use synthetic `.tbd`, Mach-O and `.xip` fixtures generated in the
|
|
272
|
+
tests themselves; no Apple files are needed or allowed in the repository.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
ipeddle/__init__.py,sha256=rTezBt8eWsr3v00d8R6lwlVUAINFlt-X0z5SsV8evzc,96
|
|
2
|
+
ipeddle/__main__.py,sha256=hBa8vbDgsfwYmZ9oTDiS_5PabLk36YQ8k6ja3HhLBK0,55
|
|
3
|
+
ipeddle/build.py,sha256=s9vsNak9ED9EV17AmRInrwoAK2hmba1-drZiJOKkr2k,12473
|
|
4
|
+
ipeddle/cli.py,sha256=zqTstPjk0wAQl5dUJ6byyyQXmzcbUQZrB1fAoWhnubo,9012
|
|
5
|
+
ipeddle/config.py,sha256=J8MBMlwt65NkScgMnyuiJin55fakjdJ05S2N841cZ2A,3266
|
|
6
|
+
ipeddle/doctor.py,sha256=Lk07Osp5GRGSWPzy4V0uvTpGe8Q0yh8OACCytAiiwM4,7202
|
|
7
|
+
ipeddle/errors.py,sha256=Yr-JiP_pj8fqEAhiWZ27RVJ_0qsZH2AO3wNELt7ofN0,327
|
|
8
|
+
ipeddle/fsutil.py,sha256=fd0bsCmh-FVhWr3qoUnLtzGepVCuZUKmHeMQAUzMY0o,3951
|
|
9
|
+
ipeddle/inspect.py,sha256=VMH00yeedlhE0FBMHu1rd9TQo62x-5KF_foGJ6Me_EQ,14290
|
|
10
|
+
ipeddle/macho.py,sha256=RK74rBI8eraDhDbTv_FmgTWgyzUfY4SKQGKfP0oR3m0,9805
|
|
11
|
+
ipeddle/mangling.py,sha256=mJ4iUnfyalrpPIl3JxVPkVZrQ_9IHBvrE3-gRbrR01A,4295
|
|
12
|
+
ipeddle/package.py,sha256=2zdckRZZzTFNDI9Vb5L1P3LTxzcSaEOReQz_AYkZGfc,12056
|
|
13
|
+
ipeddle/patcher.py,sha256=yla2EabhvW_sAEGxhyd3_VFjoO680E3k2DMCKUt1xYM,9409
|
|
14
|
+
ipeddle/paths.py,sha256=az6OR6yc48v505VZqOGEgjVXeD45L7RbPlJ9B08vlgM,1958
|
|
15
|
+
ipeddle/proc.py,sha256=KvPEeBFPzMHvspf7bt9fpsIWK445Fdbk9SpJYeT13vA,1971
|
|
16
|
+
ipeddle/runtime.py,sha256=uSybaKE_P1AR8ei3gIsW-hHsWj9gW24PqJr_65Dko5k,2645
|
|
17
|
+
ipeddle/scaffold.py,sha256=581-aj1BYErB9QtKRLZge8D0EvVpg6VHWXiZ-P8bfRE,2367
|
|
18
|
+
ipeddle/sdk.py,sha256=OszNqIBD1KCjpmNz6JDjdedtElyb8TQubJTpjla3ejc,4977
|
|
19
|
+
ipeddle/setup.py,sha256=4N-48AyAWYp6hmaKXlkQJsSkCDn0QRiS8Inj3HObsUo,13021
|
|
20
|
+
ipeddle/swiftsdk.py,sha256=46iUR3L2wkIjeHBIzq5X0PlwWBK7o2RKRQU993_3Eks,5976
|
|
21
|
+
ipeddle/tbd.py,sha256=fuiwiublTH1flcvUcPnu9LUJOYVUGRiYjvqyWgaDosA,10197
|
|
22
|
+
ipeddle/toolchain.py,sha256=O6K4qwJ5k_lgVVLuQpgBDfhs-JrF9OI3lKYPG_rff3s,6619
|
|
23
|
+
ipeddle/ui.py,sha256=FbG0xLDui9cA3bRrVZk7XGRtZ5zBnxwlzOfKJj9LG8c,1351
|
|
24
|
+
ipeddle/xip.py,sha256=4D3f2NQ0vFNV1rbqCjvloJh0lA8cv7uZ8VLgjmgI-lw,6841
|
|
25
|
+
ipeddle-0.1.0.dist-info/METADATA,sha256=HrzIeWYTind4vkZf_iorCSVpcUk3CByS--_4Cq-rJ8s,13490
|
|
26
|
+
ipeddle-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
27
|
+
ipeddle-0.1.0.dist-info/entry_points.txt,sha256=tnzs1vpor6VHKYMTWMpV3i6W5dDyA87lQENWBSe40mw,45
|
|
28
|
+
ipeddle-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
29
|
+
ipeddle-0.1.0.dist-info/licenses/NOTICE,sha256=bOkjH6kUeHLZ4yfbMWtCAZoQrfyvLtoAOWNmoO_MfUw,1096
|
|
30
|
+
ipeddle-0.1.0.dist-info/RECORD,,
|