Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS bindings #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix iOS bindings #17

wants to merge 1 commit into from

Conversation

Moxinilian
Copy link

This fixes the generation of bindings for iOS.
Huge thanks to @huhlig for the help to make this work.

@Moxinilian
Copy link
Author

It seems like CI is broken for nightly.
@Rhuagh

@mtak-
Copy link

mtak- commented Jun 27, 2018

Thank you! This fixes my issues with building on OSX.

fn main() {
if let Ok(directory) = frameworks_path() {
build(&directory);
let (target, platform) = match std::env::var("TARGET") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a better way of doing this? All of this should be exposed via cfg, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe cfg will return the building platform as this is build.rs, so here it would always be darwin. Unless I'm wrong. I can't check right now unfortunately.

builder = builder.clang_arg(format!("-F/{}", frameworks_path));
builder = builder
.clang_arg(format!("-F/{}", frameworks_path))
.clang_arg("-isysroot")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been tested on older versions of osx ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but I have no means to do it.

@mitchmindtree
Copy link
Member

@Moxinilian thanks so much for this PR - super excited to hear you managed to get this going with iOS. I'd actually love to hear more about what you're using it for if you're free to share details on the project? Also, I'm guessing you were testing this on a version of macOS? May I ask which version of macOS it does work on?

Also @Rhuagh if you did get a chance to test this and it built fine, which version of macOS?

@mtak- which issue in particular were you running into prior to this PR? Also, if you don't mind me asking, which version of OSX and Xcode do you have on the system which is fixed by this PR?

In summary, I'm just trying to check which versions of macOS are working so far :) If anyone's reading this that happens to be on 10.10 or prior, it would be great to hear whether or not this branch works for you! Otherwise I'll have access to a macbook air which might have 10.10 installed within a weeks time for testing. It would be nice to land this.

@Moxinilian
Copy link
Author

I used latest High Sierra.
Come to think of it, I believe we may have fixed without wanting it building for all platforms, either MacOSX or iPhoneOS, considering we're requesting the location of the SDK to Xcode itself.
I'm not sure if changing the sysroot is enough however, that would require testing.

@mtak-
Copy link

mtak- commented Jul 5, 2018

@mitchmindtree I was trying to build ggez for iOS, (among other game libraries). Just to see what was currently possible with rust. I don't recall the particular issue, but it was definitely path related. So far nothing is really working, so I have no idea if this PR does more than let me build.

I have a couple of notes on the PR that might help as well.

  • iPhoneSimulator is never detected as a platform in the build script even though it is a separate sdk from iPhoneOS (the i386 and x86_64 apple-ios targets should use this platform).
  • Atleast in recent bindgen versions there is a hidden --target= which helps with dropping the erroneous sysroot bindgen appends
    • .clang_arg(format!("--target={}", TARGET_TRIPLE))

Possibly unnecessary flags for your project, but helped with getting other ios bindgen scripts to work

  • .clang_arg("-x")
  • .clang_arg("objective-c")

I am no longer using this as a dependency, hope that helps

@mtak-
Copy link

mtak- commented Jul 5, 2018

Ah, osx version is 10.13.6 Beta (17G47b) - High Sierra

@Moxinilian
Copy link
Author

This code is fairly old, but I do remember dropping iPhoneSimulator because it was causing issues somewhere, but I don't remember where exactly.
Also, what is erroneous with the sysroot argument?

@mtak-
Copy link

mtak- commented Jul 6, 2018

Not your sysroot argument. IIRC, at some point bindgen was adding an incorrect sysroot on osx when cross compiling for iOS. I can no longer find it in the bindgen master source.

Sorry for the confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants