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

Swift Package Manager support broken? #7630

Closed
gibssa opened this issue Nov 9, 2022 · 9 comments
Closed

Swift Package Manager support broken? #7630

gibssa opened this issue Nov 9, 2022 · 9 comments

Comments

@gibssa
Copy link

gibssa commented Nov 9, 2022

Hi FlatBuffers team,

I see #7548 from September 2022 that moved Package.swift into root.

But, it seems like Swift Package Manager support is currently broken despite the change?
image

Or is the current solution still to pull the Git repo and symlink to source manually?

Thanks for taking a look!

@mustiikhalil
Copy link
Collaborator

Hey,

So it seems that the version you are trying to pick doesn't match the current tag within the repository. The minimum version that supports this is v22.9.29. i would also suggest using exact version.

@gibssa
Copy link
Author

gibssa commented Nov 9, 2022

(Sorry if I'm being a bit thick, I'm new-ish to iOS dev, even though I'm now doing it full-time)

Yup, I switched from v2.0.8 -> v22.10.26 and an "exact version" in XCode and the SPM import looks good now:
image

I also switched to manually grabbing the pre-built v22.10.26 version of the flatc binary from Releases here (I think brew install flatbuffers is out of date at v2.0.8 at the moment).

But, it seems that the FlatBuffers Swift module isn't found by my XCode project:
image

Am I just being thick here with some other piece of XCode SPM setup required here?

(btw, thanks for the very quick response time!)

@mustiikhalil
Copy link
Collaborator

mustiikhalil commented Nov 9, 2022

@gibssa So i'm not sure what's exactly happening here. There might be multiple issues:
1- But knowing Xcode have you tried cleaning the build directory, and reopening it?
2- In the project > general tab > Frameworks, Libraries and embedded content. Do you see the flatbuffers lib present?
Screenshot 2022-11-09 at 5 09 20 PM

Screenshot 2022-11-09 at 5 13 13 PM

@gibssa
Copy link
Author

gibssa commented Nov 9, 2022

  1. Yup, I've been doing lots of "Clean Builds" (lots of cmd+shift+k) and re-opening XCode (this has worked for several other things before)
  2. Interesting, on my version of XCode that "Frameworks, Libraries, and Embedded Content" I think has been renamed to just "Embedded Content":

image

image

FlatBuffers lib isn't embedded as a library (I remember this from my Unity iOS protoype months back). But "FlatBuffers" also doesn't show up as a library when trying to add it here:
image
image
image

I also tried removing the Project-level code dependency and using "Add Local" from within Target -> "Embedded Content" -> "Add Package Dependency", but that seemed to re-introduce the Swift code dependency and not actually add FlatBuffers as a library (i.e. back to the state from just adding Swift package directly in SPM wizard):
image
image

That brings up a question: should my .xcodeproject using Swift FlatBuffers be importing some pre-built static lib or .framework alongside the Package.swift?

@mustiikhalil
Copy link
Collaborator

should the .xcodeproject for Swift FlatBuffers be importing some pre-built static lib or .framework alongside the Package.swift?

It shouldn't it should just work directly.

Screenshot 2022-11-09 at 5 31 26 PM

flatbuffers.mov

Would it be possible to put this project on Github and share it here? or at least an example project similar to it with the same issue?

@gibssa
Copy link
Author

gibssa commented Nov 9, 2022

Okay this is good, I created a new Xcode project from scratch (just like your attached video) and the "Embedded Content" library shows up fine:
image

What's more, the section actually is renamed to "Frameworks, Libraries and Embedded Content" on this fresh Xcode project 🤷

I'll re-create my own project as a fresh Xcode project, get it to all link together, and close the loop on this Issue if it ends up working fine after re-creating everything.

(thanks again for the very quick turnaround time)

@mustiikhalil
Copy link
Collaborator

Hahah welcome to Xcode, where it never works the same 😄

Did you create your project through xcode earlier? and was it the latest xcode when you created it?

@gibssa
Copy link
Author

gibssa commented Nov 9, 2022

Hm, honestly I can't remember. I think I created my current version of this Xcode project around August, but I remember following instructions to manually download (the latest) Xcode app binary from https://apple.com instead of the macOS App Store because of a bug in Xcode at the time...

🤷 🤷

@gibssa
Copy link
Author

gibssa commented Nov 10, 2022

All done re-creating my project with FlatBuffers. Chalking this one up to Xcode shenanigans.

Thanks @mustiikhalil for the fast help!

@gibssa gibssa closed this as completed Nov 10, 2022
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

No branches or pull requests

2 participants