Skip to content

When using an xcodeproj (such as generated by cargo xcode) one should not use the SwiftLinker but rather build the package through the xcodeproj #49

@franklyonnet

Description

@franklyonnet

Not really a bug but something to add into the docs. It took me a while to figure out what was going on...

When building for an ios target on a macos device, the swift build command generated by SwiftLinker is ignoring the -target specification. See below the command built by cargo from within a xcodeproj built by cargo-xcode.
As per my findings trying to wrap the swift command with xcrun as suggested in some threads, or adding a swift -arch with or without -Xswiftc, or prepending the command with export ARCHS= doesn't change the outcome.

A workaround (and probably the best course of action) is to build the package within the xcodeproject itself :
1 - Drag the package folder which contains the Package.swift into your Xcode project
2 - Click the Plus button in the "Link Binary with Libraries" section, locate the package in the modal dialog, select the gray library icon inside the package, and add this one.

                  command: cd "apple/EdamameNative" && "swift" "build" "-c" "release" "--build-path"
                  "/Users/flyonnet/Library/Developer/Xcode/DerivedData/Runner-gyjydghdoilsppddiyqqpyifgfkp/Build/Intermediates.noindex/edamame_core.buil
                  d/cargo_target/aarch64-apple-ios/release/build/edamame_core-7be057f67cfcb7b2/out/swift-rs/EdamameNative" "-Xswiftc" "-sdk" "-Xswiftc"
                  "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk" "-Xswiftc" "-target"
                  "-Xswiftc" "aarch64-apple-ios"
                  error: 'edamamenative': Invalid manifest (compiled with:
                  ["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc", "-vfsoverlay",
                  "/var/folders/s9/vlddfbs96d12sz5jgrhg3js40000gn/T/TemporaryDirectory.XDdAsN/vfs.yaml", "-L",
                  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription",
                  "-Xlinker", "-rpath", "-Xlinker",
                  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target",
                  "arm64-apple-macosx12.0", "-sdk",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk", "-F",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-I",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "5", "-I",
                  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk",
                  "-package-description-version", "5.7.0",
                  "/Users/flyonnet/Temporaire/Programming/edamame/rust/userspace/apple/EdamameNative/Package.swift", "-Xfrontend",
                  "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o",
                  "/var/folders/s9/vlddfbs96d12sz5jgrhg3js40000gn/T/TemporaryDirectory.bYOOTT/edamamenative-manifest"])
                  <unknown>:0: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX'
                  <unknown>:0: error: unable to load standard library for target 'arm64-apple-macosx12.0'
                  thread 'main' panicked at 'Failed to compile swift package EdamameNative',

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions