Commit Graph

179 Commits

Author SHA1 Message Date
Kabir Oberai c9d3fa3dbf use swift-subprocess 2026-06-22 02:24:28 -04:00
Kabir Oberai 7f151a9c66 Fix tmpdir reentrancy (#234)
Previously, we would clear xtool's temporary directory on startup. This
(practically) meant you couldn't have multiple instances running in
parallel, because the second instance could delete the first instance's
temp resources while the first instance still needed them. Fix this by
having xtool instances declare locks on their temporary directories.
2026-06-22 02:22:42 -04:00
Kabir Oberai e49934c1fe Fix DarwinSDK legacy compat (#230) 2026-05-28 01:50:58 -04:00
Kabir Oberai 9c4772d64f Fix clang headers (#228)
A slightly different approach to #215.

---------

Co-authored-by: sfusco <slf@stevenfusco.com>
2026-05-28 01:43:22 -04:00
Kabir Oberai 4077e1a0b8 Add build --sign option (#224)
Running `xtool dev build --sign [--ipa]` will produce a codesigned
app/ipa, without installing
2026-05-16 22:40:45 -04:00
Kabir Oberai 756a867854 Update dependencies (#222) 2026-05-16 20:57:29 -04:00
Kabir Oberai 8edb54fb71 Fix capability creation via public API (#220)
Ref #216: the public API seems to now complain when passing in
`capabilities`, but the field is still required when using the private
API.

Co-authored-by: sfusco <slf@stevenfusco.com>
2026-05-16 20:04:51 -04:00
Swapnil Nakate c65d45ba60 fix(linux): use home cache dir to avoid tmpfs→ext4 EINVAL on SDK install (#211)
## Problem

`xtool setup` fails on Linux Mint (and other distros) with:

```
Error: Error Domain=NSCocoaErrorDomain Code=512 "(null)" UserInfo={
  NSUserStringVariant=["Copy"],
  NSSourceFilePathErrorKey=/tmp/sh.xtool/tmp-DarwinSDKBuild-.../darwin.artifactbundle/...,
  NSDestinationFilePath=/home/<user>/.swiftpm/swift-sdks/darwin.artifactbundle/...,
  NSUnderlyingError=Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument"
}
```

## Root Cause

On Linux Mint (and Ubuntu-based distros), `/tmp` is mounted as **tmpfs**
while the home directory is on **ext4**. Foundation's
`FileManager.copyItem` uses `sendfile(2)` internally, which returns
`EINVAL (22)` when copying between different filesystem types.

`TemporaryDirectoryRoot` defaults to
`FileManager.default.temporaryDirectory` → `/tmp` on Linux. When `swift
sdk install` copies the built SDK from `/tmp/sh.xtool/...` to
`~/.swiftpm/swift-sdks/`, it crosses filesystem boundaries and fails.

## Fix

On Linux, default the temp directory root to `$XDG_CACHE_HOME/xtool`
(falling back to `~/.cache/xtool`) instead of `/tmp`. This keeps the
build directory and install destination on the same filesystem, so the
copy always succeeds.

- `$XTL_TMPDIR` and `$TMPDIR` overrides continue to work as before
- macOS behaviour is unchanged
- Follows XDG Base Directory Specification

## Changes

One file, `Sources/XUtils/TemporaryDirectory.swift` — 11 lines added
inside a `#if os(Linux)` block.

Fixes #181
2026-04-18 17:25:10 +05:30
Kabir Oberai 7a5dfd2ccd Validate SDK before overwriting (#192)
Running an invalid `sdk` subcommand like `xtool sdk list` (there's no
`list` subcommand) is interpreted as "install the sdk at path `./list`".
We previously unconditionally removed the existing SDK during
installation. By switching the order so that we validate the path first,
we avoid performing a potentially destructive action unless we have
clear intent.

See #186.

Before:

```bash
$ xtool sdk list
Removing existing SDK... # destructive!
Error: Could not read file or directory at path 'list'.
```

After:

```bash
$ xtool sdk list
Error: Could not read file or directory at path 'list'.
  See 'xtool help sdk' for usage.
```
2026-01-04 21:55:35 -05:00
Kabir Oberai 9af49f6f08 Bump deployment to macOS 13, iOS 16 (#173)
Necessary in order to pull in swift-subprocess
2025-10-12 17:20:06 -04:00
Kabir Oberai f29f6ba601 Clean up some entitlements code (#165)
- We already do the `isFree` declarations in
`DeveloperServiceCapability.swift`. Don't need to duplicate it on the
entitlement types.
- Add support for creating capabilities with raw names
2025-09-28 19:04:28 -04:00
Antonio Cheong c303e27eb1 Bump device versions to fix #25 (#163) 2025-09-28 17:32:04 -04:00
Kabir Oberai 96032d0f17 Enable cross import overlays (#153)
Fixes #152

We might want to figure out if there are any other flags we don't pass
but should
2025-08-10 18:05:39 -04:00
Kabir Oberai 0710653cd0 Handle static xcframeworks not being unpacked (#156)
SwiftPM may not unpack static xcframeworks. Handle this gracefully, if
SwiftPM doesn't need the framework we don't either.

Fixes #155.
2025-08-10 18:05:28 -04:00
Kabir Oberai 836fca8daf Improve tmpdir management (#147)
- We now have a single tmpdir "root" that can be recreated at launch to
clean up old stragglers
- The location of this tmpdir root can be controlled by `XTL_TMPDIR` or
`TMPDIR`. In general the path is `$TMPDIR/sh.xtool`.

With this change it should be possible to `export XTL_TMPDIR=/var/tmp`
if `/tmp` doesn't have enough space, which fixes #23.
2025-08-10 01:43:09 -04:00
Kabir Oberai 41f81b2851 Update ASC spec to v4.0.0 (#142)
No breaking changes afaik

One notable change is the addition of
`components.schemas.PagingInformation.paging.nextCursor` (which is
possibly supposed to be the query parameter portion of `links.next`?
could simplify the pagination code) but this doesn't seem to be returned
by the prod ASC API right now.
2025-07-21 04:03:31 -04:00
Kabir Oberai 7308756c50 Update PublicStaging path (#132)
Previously this was shadowing the user's cwd path onto the device, e.g.
if you were installing from `/home/foo/bar` it would create
`/home/foo/bar/PublicStaging` on the device. For uniformity with other
tools like `ideviceinstaller`, clean this up and just create
`/PublicStaging`.
2025-07-14 00:19:38 -04:00
Erik Bautista Santibanez edd6b90f53 Add support for App Extensions (#97)
This pull request adds support for Apple's [App
Extensions](https://developer.apple.com/app-extensions/).

Closes: #45

---------

Co-authored-by: ErrorErrorError <16653389+ErrorErrorError@users.noreply.github.com>
Co-authored-by: Kabir Oberai <oberai.kabir@gmail.com>
2025-07-13 23:47:47 -04:00
Erik Bautista Santibanez bf34edcf6e fix: resolve ASC invalid bearer token (#129)
This pull request resolves potential clock drift between ASC and bearer
token.

Ref: https://github.com/xtool-org/xtool/pull/97#discussion_r2203584344
2025-07-13 20:29:50 -04:00
Kabir Oberai d691e614b4 Support building with Swift 6.2 (#114) 2025-07-12 16:28:48 -04:00
Amlal El Mahrouss 74d6a91537 Harden mobileprovision.c to avoid UB on OOM (#122)
# fix: hardening `mobileprovision.c` to avoid future crashes.

## Context:

I found two common weakness inside `Sources/CXKit/mobileprovision.c`,
which seems to be an important layer of `xtool`'s signing logic.

### Common weaknesses found:

- CWE-476
- CWE-119

---------

Co-authored-by: Kabir Oberai <oberai.kabir@gmail.com>
2025-06-28 17:34:04 -04:00
Kabir Oberai bf057263cc Support unxipping Xcode betas (#115)
Xcode betas are stored in the xip as Xcode-beta.app. Support this by
avoiding hardcoding the `Xcode.app` path.
2025-06-10 17:09:06 -04:00
Kabir Oberai 9e80b7d04f Linux: increase http connect timeout (#111)
Tentative fix for #69, ref
https://github.com/xtool-org/xtool/issues/69#issuecomment-2913232533
2025-06-01 19:02:06 +05:30
Kabir Oberai 0425f9edeb Add SwiftLint (#104)
Closes #72
2025-05-31 19:38:57 +05:30
Kabir Oberai 5beec34370 Validate path to Xcode.app/xip (#100)
Fixes #16
2025-05-27 18:11:08 +05:30
Kabir Oberai 3fb39717cd Drop the "Logging in" stage (#99)
This was vestigial, and besides the fact that we don't actually do any
work in this stage, we also never update the progress here so it gets
stuck at 0%.
2025-05-27 16:45:35 +05:30
Kabir Oberai 6730ea3896 Make ALL response enums extensible (#92)
Another bugfix for #64. Fifth… time's the charm?
2025-05-25 19:09:17 +05:30
Kabir Oberai 8d8ba6fb94 FetchDeviceOperation: account for pagination (#91)
- Always try to register the device and just return gracefully if it
fails (prevents races, pagination issues)
- Allow `SigningContext` (and therefore `AutoSigner`) to be created
without a target device: just skip device registration.
2025-05-25 03:56:19 +05:30
Kabir Oberai 72db71c871 DeveloperServices: support paginated requests (#89)
Realized that we need to paginate due to #87
2025-05-25 03:29:43 +05:30
Kabir Oberai efc1ed943f Fix duplicate App ID registration (#90)
We pull the list of App IDs in `upsertApp` to see if we already created
the App ID. This broke when the user had too many App IDs, since DS
returned a paginated response and we only looked at the first page.

We could paginate the whole list (as seen in #89) but that's slow.
Instead, just filter the query to the expected App ID. This is a prefix
search so we might still receive multiple responses, but it's much less
likely that the user has like 10(? I'm not sure what the default/max
pagination limit is) apps registered with the XTL-ABC.com.foo.bar prefix
(they could have PlugIns but usually just a small number of them.)

This is a tentative fix for #87.
2025-05-25 02:42:22 +05:30
Kabir Oberai 693e60faef Support entitlements with XcodePacker (#88) 2025-05-24 02:28:17 +05:30
Kabir Oberai f76e1eda04 patch.js: improve ergonomics (#85) 2025-05-24 01:36:12 +05:30
Kabir Oberai 8f31686c92 Only add iOS-type devices to profile (#84)
Another tentative fix for #64
2025-05-24 00:56:29 +05:30
Kabir Oberai 3b17975fe7 Add support for custom entitlements (#82)
Closes #46
2025-05-24 00:35:46 +05:30
Kabir Oberai 48a2d30684 Fix changeCurrentDirectory warning (#81)
This is `discardableResult` on macOS (perhaps because it goes through
objc bridging?) but not on Linux so we get a warning on the latter
2025-05-23 23:32:45 +05:30
Kabir Oberai b5d49a63cf Improve OpenAPI error handling (#78)
- Make some enums non-exhaustive (closes #77)
  - Also a tentative fix for #62 and #64
- Improve logging on deserialization failure

We now use raw JS to patch the OpenAPI spec instead of openapi-overlay.
It's a lot more flexible this way.
2025-05-23 19:05:02 +05:30
Kabir Oberai cd3d72c6b7 OpenAPI spec tweaks (#76)
- Add `BundleIdPlatform.macos` (potential fix for #64)
- Fix deprecation warnings
- Improve overlay organization
2025-05-22 22:37:47 +05:30
Kabir Oberai 2265449730 Support for logging OpenAPI responses (#75)
Allow setting `XTL_DEV_LOG` to a regex (e.g. `export
XTL_DEV_LOG='profiles_.*'`) to log the responses of all matching
operations

Also add `BundleIdPlatform.services` as seen
[here](https://github.com/AvdLee/appstoreconnect-swift-sdk/blob/60bbc198c8d9f9992807bfebef86f45d6173a1f1/Makefile#L9)
2025-05-22 22:03:37 +05:30
Kabir Oberai 3a4290c85e Support building for iOS simulator (#74)
Closes #68

## On any platform

You can now do

```bash
xtool dev build --triple arm64-apple-ios-simulator [--ipa]
```

To build a .app/.ipa that works on the simulator.

## On macOS

You can do

```bash
xtool dev --simulator
```

To one-shot build-and-install on the booted simulator.
2025-05-22 19:35:51 +05:30
Kabir Oberai fbbd8366ca Support xtool --version (#53) 2025-05-21 18:16:46 +05:30
Kabir Oberai 26e076b95f More DocC improvements (#65) 2025-05-20 03:10:36 +05:30
Kabir Oberai 25fd269b47 Update Netlify footer copy (#63)
Netlify wants specific copy in order to be eligible for their [Open
Source plan](https://www.netlify.com/legal/open-source-policy)
2025-05-19 00:52:20 +05:30
Kabir Oberai 02ea670a91 Add footer to docs (#61) 2025-05-19 00:02:05 +05:30
Kabir Oberai dfb0e36d0e GitHub Pages (#56) 2025-05-18 07:25:55 +05:30
Kabir Oberai 77b086d2d8 More XTL renaming (#51) 2025-05-17 18:32:58 +05:30
Kabir Oberai 54d03f525a Improve SDK handling (#40)
* Use swift-sdk commands instead of file ops

* comment
2025-05-16 00:06:39 +05:30
Kabir Oberai 2538d18ab0 Update macOS installation, suggest cask/.app 2025-05-14 13:40:38 +05:30
Kabir Oberai fa74cd9b10 Fix ADI permissions (#33) 2025-05-14 12:11:08 +05:30
Kabir Oberai 17d3d1019b Improve handling of paid developer accounts (#20)
* getTeamIsFree -> XcodeAuthData.team().isFree

* Only revoke certificates if on a free team

* Update OpenAPI spec, handle AVP

* Fix App ID capabilities on paid accounts
2025-05-12 18:14:36 +05:30
Kabir Oberai b3c12ef4d2 Add build --ipa (#24) 2025-05-12 16:33:57 +05:30