Skip to content

SDK (XCode) setup returns NSCocoaErrorDomain Code=513 (EPERM) #254

Closed

Description

@akissu

Description

XTool setup fails at Writing.metadata step, specifically at coping fuzzer
directory from "/usr/lib" to user local cache.

May related to:
swiftlang/swift-foundation#1125

Environment

  • Linux: CachyOS (Arch-based), 7.2.3-1-cachyos
  • Swift: 6.3.3-RELEASE (x86_64-unknown-linux-gnu)
  • clang / compiler-rt: 22.1.8
  • xtool: 1.19.0 (the cross-platform Xcode replacement used to build a Darwin Swift SDK)
  • SDK: Xcode_26_Universal.xip
# xtool setup
Logged in.
...
Now generating the Darwin SDK.

Please download Xcode from http://developer.apple.com/download/all/?q=Xcode
and enter the path to the downloaded Xcode.xip.

Path to Xcode.xip: /home/xxx/Documents/xtool/Xcode_26_Universal.xip
[Downloading toolset] 100%
[Extracting XIP] 100%
[Installing SDKs] 100%
[Cleaning up]
[Finalizing SDKs]
- iPhoneOS26.0.sdk
- iPhoneSimulator26.0.sdk
- MacOSX26.0.sdk
[Writing metadata]
Error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have
permission."UserInfo={NSDestinationFilePath=/home/xxx/.cache/xtool/pid-1205720-0/dir-DarwinSDKBuild-24A56082-E841-4989-ADFD-70DEA93EC8E0/DarwinSDKBuild/darwin.artifactbundle/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/fuzzer,
NSUserStringVariant=["Copy"], NSUnderlyingError=Error Domain=NSPOSIXErrorDomain
Code=1 "Operation not permitted",
NSSourceFilePathErrorKey=/usr/lib/clang/22/include/fuzzer,
NSFilePath=/usr/lib/clang/22/include/fuzzer,
NSURL=file:///usr/lib/clang/22/include/fuzzer}

Activity

  1. added
    bug
    on Sep 10, 2026
  2. akissu commented on Sep 10, 2026

    @akissu
    Author

    Two workarounds:

    1. run as sudo, but I'd rather not do this:
      sudo xtool setup

    2. Change /usr/lib permissions, but will get overwritten by package manager at some point:

    sudo chown -R xxx:xxx /usr/lib/clang/22/include
    xtool setup

    Additional:
    This may/may not be related, but I seem to be having another write related issue. The following command hangs forever

    # sudo xtool dev
    Planning...
    [1/1] Planning build
    Building for debugging...
    [2/8] Write swift-version-5BD8B568FD16BF8B.txt
  3. kabiroberai commented on Sep 10, 2026

    @kabiroberai
    Member

    I think you're right that this is the same issue as swiftlang/swift-foundation#1125. Working on a fix in #255.

    Re your second issue,

    The following command hangs forever

    The first xtool dev invocation can take a bit because it has to compile and cache the SDK modules. Can you give it 3-4 minutes and see if it works? If not, please share the output of swift build --swift-sdk arm64-apple-ios -v

  4. akissu commented on Sep 13, 2026

    @akissu
    Author

    Looks like it does return around 3 min in, but with build errors

    # xtool new Hello
    # cd Hello
    # sudo xtool dev
    Planning...
    [1/1] Planning build
    Building for debugging...
    /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/Spatial/Structures.h:4:10: note: while building module 'simd' imported from /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/Spatial/Structures.h:4:
      2 | #define Spatial_Structures_h
      3 | #include <Spatial/Base.h>
      4 | #include <simd/simd.h>
        |          `- note: while building module 'simd' imported from /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/Spatial/Structures.h:4:
      5 | #include <stdbool.h>
      6 |
    
    /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/simd/base.h:96:13: note: while building module '_Builtin_intrinsics' imported from /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/simd/base.h:96:
     94 |  *  automatically included with simd.h                                        */
     95 | #  if defined __ARM_NEON
     96 | #   include <arm_neon.h>
        |             `- note: while building module '_Builtin_intrinsics' imported from /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/simd/base.h:96:
     97 | #  elif defined __i386__ || defined __x86_64__
     98 | #   include <immintrin.h>
    
    <module-includes>:2:9: note: in file included from <module-includes>:2:
    1 | #import "arm_acle.h"
    2 | #import "arm_neon.h"
      |         `- note: in file included from <module-includes>:2:
    3 | #import "arm_fp16.h"
    4 |
    
    ... Explodes a bit...
    
    /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/include/simd/base.h: 0:
    /root/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk/usr/lib/swift/simd.swiftmodule/arm64e-apple-ios.swiftinterface: 0:
    Error: exited(1)
  5. kabiroberai commented on Sep 14, 2026

    @kabiroberai
    Member

    @akissu could you try re-installing the Darwin sdk, after updating to xtool v1.19.2? ie run xtool sdk install again

  6. added a commit that references this issue on Sep 19, 2026
    d4f6443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions