Targets like aarch64-apple-ios don't appear under --print target-list with today's nightly (and latest beta):
$ rustc --print target-list | grep ios || echo (empty)
(empty)
but they appear there if I use the latest stable:
$ rustup run stable rustc --print target-list | grep ios
aarch64-apple-ios
armv7-apple-ios
armv7s-apple-ios
i386-apple-ios
x86_64-apple-ios
It's not like they just don't appear under the list of built-in targets. Using --target aarch64-apple-ios also says that the target doesn't exist
$ rustc --target aarch64-apple-ios --print cfg
error: Error loading target specification: Could not find specification for target "aarch64-apple-ios"
The weird thing is that you _can_ rustup target add aarch64-apple-ios but then you can't use the target:
$ rustup target add aarch64-apple-ios
info: component 'rust-std' for target 'aarch64-apple-ios' is up to date
$ rustc --target aarch64-apple-ios --print cfg
error: Error loading target specification: Could not find specification for target "aarch64-apple-ios"
$ rustc -V
rustc 1.13.0-nightly (77d2cd28f 2016-08-29)
$ rustup run beta rustc -V
rustc 1.12.0-beta.2 (389dad798 2016-08-24)
$ rustup run stable rustc -V
rustc 1.11.0 (9b21dcd6a 2016-08-15)
cc @alexcrichton
Works fine on OS X:
$ rustc +nightly-2016-08-30 --print target-list | grep ios
aarch64-apple-ios
armv7-apple-ios
armv7s-apple-ios
i386-apple-ios
x86_64-apple-ios
I think this was a side effect of #34980 and is directly related to #36157:
Results now)Err Results for the iOS ones are filtered out (and the error messages discarded)I believe @TimNN's diagnosis is correct in that https://github.com/rust-lang/rust/pull/34980 is the cause here.
I feel like we should do a larger refactor and just not return a Result at all. That is, the iOS pieces should all have graceful fallbacks, or we should delay running tools like xcrun until as late as possible (e.g. when actually linking for the target).
@alexcrichton The point of the Result was so that in the future if there was a default search path like RFC 131 first mentioned that they could get filtered out if they were invalid for the current version of the compiler used.
I will also note that I agree with deferring the xcrun until as late as possible and making that target not fail where it does so that its always printed out. I was just trying to say why we went with the Result because part of the discussion happened on IRC and was not captured in the issue.
@cardoe yeah I just figure that something like --print target-list should probably print these out and the actual error should just be delayed as long as possible.
This is still a problem. I suspect that the issue lies with code somewhere in src/librustc_back/target/mod.rs but I'm not sure.
Still having this problem on Linux, on current nightly as well as on stable:
$ rustup target add aarch64-apple-ios
info: component 'rust-std' for target 'aarch64-apple-ios' is up to date
$ cargo lipo --release
error: failed to run `rustc` to learn about target-specific information
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type proc-macro --crate-type rlib --crate-type staticlib --target aarch64-apple-ios` (exit code: 101)
--- stderr
error: Error loading target specification: Could not find specification for target "aarch64-apple-ios"
|
= help: Use `--print target-list` for a list of built-in targets
Cargo exited unsuccessfully: exit code: 101
$ cargo build --release --target aarch64-apple-ios
error: failed to run `rustc` to learn about target-specific information
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type proc-macro --crate-type rlib --crate-type staticlib --target aarch64-apple-ios` (exit code: 101)
--- stderr
error: Error loading target specification: Could not find specification for target "aarch64-apple-ios"
|
= help: Use `--print target-list` for a list of built-in targets
Is there a workaround, or is it currently not possible to build Rust libraries for iOS targets from Linux?
I am receiving the error just above, and I am working on a Mac. I'm trying to build a Rust library for my iOS application right now. Any workarounds to this?
Install Xcode along with the necessary SDKs for the iOS target you are trying to build for. What's failing is the following command:
xcrun --show-sdk-path -sdk sdk_name where "sdk_name" is likely "iphoneos".
Is there a workaround, or is it currently not possible to build Rust libraries for iOS targets from Linux?
No. It is not possible to use the iOS SDK from any platform other than a Mac. This is not a limitation of Rust but a limitation of the SDK itself.
I've downloaded the SDKs, and I'm using the latest version of Xcode. I'm able to program in Swift and build applications. However, when I run the command, this shows up:
$ xcrun --show-sdk-path -sdk iphoneos
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
Any ideas on getting around this?
I've never done iOS dev and I've only got Xcode really because of some interest in Swift a while back. So that being said, it unfortunately works on my box.
$ xcrun --show-sdk-path -sdk iphoneos
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk
I suspect there's probably a component manager in Xcode that allows you to pull in different components and you don't have the iOS SDK installed.
I'm not an macOS developer at all, but if I remember correctly you have to open the Xcode GUI once, which will ask you to accept some license and download some components. You could be missing those components.
@brianpesy you are missing Xcode installation, Xcode command line tools are not enough. Install full version of Xcode, start it to accept license (it will install additional components) then
xcrun --show-sdk-path -sdk iphoneos will run without errors.
had the same problem, the solution was to run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error/17980786#17980786
I hit this problem today trying to build some @dalek-cryptography code for iOS on a Linux machine and switching to macOS and using @tmarkovski's workaround fixed it for me.
For those who just want to print the ios targets using --print target-list or --print cfg --target aarch64-apple-ios etc, you can create an executable script called xcrun anywhere in your PATH that echos a valid path somewhere on your system, eg.
#!/bin/bash
echo "/home/<your_use_name>"
Most helpful comment
had the same problem, the solution was to run
sudo xcode-select -s /Applications/Xcode.app/Contents/Developerhttps://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error/17980786#17980786