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

Missing required module 'SQLiteObjc' when using Carthage #1205

Closed
aivcec opened this issue May 13, 2020 · 18 comments
Closed

Missing required module 'SQLiteObjc' when using Carthage #1205

aivcec opened this issue May 13, 2020 · 18 comments
Labels
apollo-sql Issue with the SQL sub-project dependency-management Issues with CocoaPods, Carthage, or SPM integration

Comments

@aivcec
Copy link
Contributor

aivcec commented May 13, 2020

Something strange is happening when integrating ApolloSQLite framework using Carthage, starting from apollo-ios version 0.23.x upwards (0.22.x works fine.)

Starting from 0.23.0, Cartfile.private was removed so I removed explicit reference to SQLite as well as Starscream from my application's Cartfile. However, I can't get the application to build whenever I import ApolloSQLite framework, due to the compiler error.
Also, on later versions (I checked only 0.27.1) the problem appears only when targeting a device.

Are there any migration steps I may have missed?

Versions:

macOS 10.15.4
Xcode 11.4 and 11.4.1
Carthage 0.34.0
apollo-ios 0.23.x or higher
Tested only on ios builds.

Reproduction:

  1. Create an empty Xcode project
  2. Add Cartfile with apollo-ios 0.23.0 or higher: github "apollographql/apollo-ios" ~> 0.23
  3. Run carthage update --platform ios
  4. Add Apollo and ApolloSQLite frameworks to project
  5. Import ApolloSQLite anywhere
  6. Build app for a device
  7. Swift Compiler Error - "Missing required module 'SQLiteObjc'"

Screen Shot 2020-05-13 at 9 56 00 pm

@designatednerd
Copy link
Contributor

I've run into this repeatedly testing out new releases for Carthage - I genuinely can't figure out what the series of steps necessary to get Carthage to actually build that module for iOS.

Here are things I've done that, in some combination but never a consistent one, will eventually get that module built:

  • Call carthage update, then stop after checkout and before build, and run carthage build instead
  • Delete the existing framework before running carthage update
  • Run carthage update to completion, delete and regenerate the framework with carthage build
  • Remove the framework from the application, then re-add it without changing anything, and have it completely inexplicably work.

These are the things I would recommend trying:

  • Mess around with above combinations
  • Putting SQlite.swift back into your own Cartfile - there may be something happening where things are being built correctly for direct dependencies but not transient dependencies
  • Switching to either Swift Package Manager or Cocoapods

To be honest I'm planning to drop official Carthage support as soon as reasonably possible (and that may be as soon as Swift 5.3, if the couple of SE proposals they implemented for that wind up working as expected), so longer-term the last option may be your best.

@designatednerd designatednerd added apollo-sql Issue with the SQL sub-project dependency-management Issues with CocoaPods, Carthage, or SPM integration labels May 13, 2020
@aivcec
Copy link
Contributor Author

aivcec commented May 14, 2020

This is really bizarre, even if I get it to work its gonna be a nightmare to reproduce on a ci pipeline.

Thanks for the heads up, Carthage really feels like a sinking ship atm.
Swift 5.3 can't come soon enough.

@designatednerd
Copy link
Contributor

I think adding it to your Cartfile directly (as long as it's the same version we specify) would give you something that works on CI since it seems like the issue is with transient rather than direct dependencies, but I can't make guarantees.

I've made my personal position on Carthage pretty clear for a while, but I appreciate that for some there isn't a realistic option until some of those changes to SPM land.

@designatednerd
Copy link
Contributor

I'm gonna close this out - @aivcec please feel free to reopen if you have more questions. Anyone else having similar problems, please open a new issue so we can troubleshoot your specific setup. Thanks!

@soffes
Copy link
Contributor

soffes commented Jun 9, 2020

I'm hitting this with SPM. I added SQLite directly to my project and added the SQLite target as a depenency next to Apollo and ApolloSQLite. It always says missing required module 'SQLiteObjc' for me locally. Saw you said open a new issue. Will do.

Actually the issue for me with SPM was only adding it to the "Dependencies" build phase but not the "Link Binary With Libraries" build phase. If a package just has Swift code, this doesn't seem to be required. For ApolloSQLite this is required though. (Turns out XcodeGen doesn't support linking packages though 😅)

This was incorrect. You shouldn't link static libraries to static libraries.

@designatednerd
Copy link
Contributor

designatednerd commented Jun 9, 2020

@soffes Cool, thanks for updating with the solution - probably worth throwing a note in somewhere about it, I'll figure out where 🙃

Update: Weird, when I tried to do this in a scratch project to update the docs, it added the libs to Link Binaries With Libraries but not Dependencies:

Screen Shot 2020-06-09 at 6 54 39 PM

@danl3v
Copy link

danl3v commented Jun 11, 2020

@designatednerd Did some investigation with the repro steps in the description of this issue.

  1. Followed the steps in the description and hit the failure as described
  2. Made sure the Apollo and ApolloSQLite were in the carthage copy-frameworks phase
  3. Went into Carthage/Checkouts/SQLite.swift and rebuilt the project using swift package generate-xcodeproj, which generated SQLite.swift.xcodeproj
  4. Deleted SQLite.xcodeproj
  5. carthage build --platform ios
  6. Run and it worked for me

If you inspect SQLite.xcodeproj vs SQLite.swift.xcodeproj, you will notice that in SQLite.xcodeproj, the scheme does not indicate to build SQLiteObjc, where as the newly generated SQLite.swift.xcodeproj does.

Let me know if this works for folks!

@designatednerd
Copy link
Contributor

The fact that this is the workaround is kind of bananas, but I hope it helps those of you stuck to carthage!

@danl3v
Copy link

danl3v commented Jun 11, 2020

Well, I think if it works, a PR on SQLite.swift is in order. Just seems like the project file checked into their repo is out of date. I can raise the PR on their repo

@designatednerd
Copy link
Contributor

Certainly possible - one thing I'd be worried about with SQLite.swift is breaking either their local build or their Swift Package Manager/CocoaPods setup - I can definitely confirm that maintaining for three package managers is a bit of a house of cards 😆

@soffes
Copy link
Contributor

soffes commented Jun 12, 2020

So I couldn't figure this out. The root problem is the Objective-C product of SQLite.swift doesn't seem to work if you get it from SPM with Xcode and try to use it with a static library. I ended up copying ApolloSQLite to my project and using it with SQLite.swift from Carthage instead of SPM. I'm pretty confident if ApolloSQLite didn't have any transitive Objective-C dependencies this would all work just fine.

@soffes
Copy link
Contributor

soffes commented Jun 12, 2020

Another workaround is to add ApolloSQLite to an app target and not a static library target.

@designatednerd
Copy link
Contributor

I'm pretty confident if ApolloSQLite didn't have any transitive Objective-C dependencies this would all work just fine.

This is hilariously ironic given that the transitive dependency is for SQLite.swift 🙃

Thanks for the clarification that you're using this with a static library - I think most of the testing I have set up is making sure things work with apps and dynamic libraries, so i may need to add some stuff around this.

@designatednerd
Copy link
Contributor

designatednerd commented Jul 1, 2020

For anyone who's been having trouble with this, I recommend updating to the new version of Carthage, 0.36 0.35. In preparing for the 0.29.0 release it built the iOS SQLite library correctly on the first try, something it has literally never done before. Might have been a fluke, but worth a shot.

@danl3v
Copy link

danl3v commented Jul 1, 2020

Definitely hope this works for folks and that Apollo can continue to support Carthage! Thanks for posting this

@designatednerd
Copy link
Contributor

I make 0️⃣ promises, particularly once Xcode 12 lands with Swift 5.3 and the fixes to SPM most people seem to be waiting on to switch, but if Carthage can use this as a jumping off point to get themselves to being only mildly painful to support instead of excruciatingly painful to support, I'd feel a lot less urgency in terms of dropping official support for it.

@teodorpenkov
Copy link

For anyone who's been having trouble with this, I recommend updating to the new version of Carthage, 0.36. In preparing for the 0.29.0 release it built the iOS SQLite library correctly on the first try, something it has literally never done before. Might have been a fluke, but worth a shot.

Isn't 0.35.0the latest version? The first time I tried bootstrapping with 0.35.0 I experienced the issue.

@designatednerd
Copy link
Contributor

Ah! good catch. Yes 0.35 is the newest version.

And sorry to hear that - I have not had issues with carthage build or carthage update fwiw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-sql Issue with the SQL sub-project dependency-management Issues with CocoaPods, Carthage, or SPM integration
Projects
None yet
Development

No branches or pull requests

5 participants