Skip to content

How to build for iOS? #260

Closed
Closed
@DagAgren

Description

I see references to people getting wgpu to build for iOS, but I am failing to figure out how.

I am trying to build a static library for wgpu, then building a project in Xcode that uses C and Swift, and linking it against the static library. I have this working for macOS.

What I have tried so far:

  1. "cargo lipo" - fails because of a bug in cargo-lipo: Final step fails when package name contains a dash TimNN/cargo-lipo#32
  2. Applied this PR to cargo-lipo to fix the bug: Replace - by _ in library names TimNN/cargo-lipo#30 - Now libwgpu_native.a does build (with a warning about cdylib not being supported but this does not seem to matter, since I don't want a dylib).
  3. Building for simulator on Xcode 10 does not work due to Metal not being supported, this is expected.
  4. Building for simulator on Xcode 11 does not work and gives hundreds of warnings like "ld: warning: building for iOS Simulator, but linking in object file (/.../libwgpu_native.a(wgpu_native.23kem15cwy8kmrf8.rcgu.o)) built for", and then fails to link the wgpu symbols.
  5. Building for device on Xcode 10 or 11 gives this error: "ignoring file libwgpu_native.a, file was built for archive which is not the architecture being linked (arm64)", and then every wgpu symbol is not found.
  6. I tried taking the .a files apart and re-building them with ar, but that changes nothing.
  7. I also tried taking just the arm64 .a file before lipo combines it into a fat library along with x86_64, but that also fixes nothing.

Any hints what I should be trying?

Activity

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions