Git Product home page Git Product logo

Comments (24)

stephencelis avatar stephencelis commented on June 19, 2024

I'm in favor of this, but am not sure it's possible at the moment. SQLite.swift uses a bridging header to #include <sqlite3.h>, which typically isn't allowed in framework targets. I tested a podspec briefly and found that because it generates its own targets, umbrella header, etc., it fails to build.

See: CocoaPods/swift#8.

Meanwhile, it's possible to import sqlite3 using a custom modulemap file, but this is problematic because the modulemap must have a hard-coded path to the specific linked/includes header, meaning it would have to generate this map dynamically and/or maintain different import paths for iphoneos, iphonesimulator (perhaps multiple, one per Xcode build), and macosx. CocoaPods would somehow need to have the ability to manage this generation, and SQLite.swift would likely be littered with #if os(...) directives.

An alternative would be to link to libsqlite3.dylib, but maintain our own, public #include "sqlite3.h", but this seems especially problematic and has a high maintenance cost.

In the end this is a deficiency on Apple's end that will hopefully be resolved with the next major developer release, if only with the inclusion of more core system modulemaps.

Here's the spec I tried if others are interested in trying to tackle this:

Pod::Spec.new do |s|
  s.name = 'SQLite.swift'
  s.module_name = 'SQLite'
  s.version = '0.1.0'
  s.summary = 'A type-safe, Swift-language layer over SQLite3.'

  s.description = <<-DESC
    SQLite.swift provides compile-time confidence in SQL statement syntax and
    intent.
  DESC

  s.homepage = 'https://github.com/stephencelis/SQLite.swift'
  s.license = { type: 'MIT', file: 'LICENSE.txt' }

  s.author = { 'Stephen Celis' => '[email protected]' }
  s.social_media_url = 'https://twitter.com/stephencelis'

  s.library = 'sqlite3'

  s.source = {
    git: 'https://github.com/stephencelis/SQLite.swift.git',
    tag: s.version
  }

  s.source_files = 'SQLite Common/**/*.{swift,c,h,m}'

  s.xcconfig = {
    'SWIFT_OBJC_BRIDGING_HEADER' => 'SQLite-Bridging-Header.h'
  }
end

from sqlite.swift.

skrach avatar skrach commented on June 19, 2024

Thank you very much for your quick and detailed response! It wasn't clear to me that integrating Sqlite.swift in CocoaPods is non-trivial! It is clear that you've detailed knowledge of the problem. I'm sorry but I don't think that I can be of any help in solving it.

from sqlite.swift.

robconrad avatar robconrad commented on June 19, 2024

+1 for CocoaPods support!

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@robconrad Unfortunately I don't think it's possible right now, but feel free to file a duplicate radar at https://bugreport.apple.com asking for Apple to include a module map for sqlite3!

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

Alright, 0.37 let's us make this happen! 7627523

from sqlite.swift.

k7 avatar k7 commented on June 19, 2024

sorry, but I found this:

bugreport

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@k7 Could you please read the contributing guidelines and follow the instructions there? E.g. run a clean build, provide a lot more information, and, if possible, provide a reproducible project? I've installed via CocoaPods using the latest versions of Xcode several times in brand new projects and haven't encountered the issue you're seeing above.

from sqlite.swift.

k7 avatar k7 commented on June 19, 2024

I am sorry not replying earlier.
Just delete the Xcode Derived Data will fix my problem.

Thank you very much for you doing a lot of work on this.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

@stephencelis Did what you wrote and included the bridging header with: SWIFT_OBJC_BRIDGING_HEADER in the podspec file. I used in the pods bridging header:

#import <TestLib/SomeViewController.h>

After installing the pod the bridging header was not installed correctly the files from the pod where not found.

Here is a stackoverflow question on this: http://stackoverflow.com/questions/30608575/include-pods-bridging-header-to-build-settings

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller That's an ooold comment. Check out the current pod spec in the repo proper: https://github.com/stephencelis/SQLite.swift/blob/743530d1e56c86b5cd4df5153839a98ecb05bf5f/SQLite.swift.podspec

(Particularly the custom module map.)

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

This does not answer my question. Or could you please point to the correct position?

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller Not sure what you're asking. I linked directly to a working podspec. I also answered your StackOverflow question.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

Well, thank you. The Stackoverflow question is not about pod Swift frameworks. It is just about pure Objective pods. Could you please update your answer on that. Thank you so much.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller That's confusing. Bridging headers are for bridging code into Swift. They do not make any sense for pure Objective-C pods.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

My pod is pure Objective-C but the project the pod ist installed in is Swift.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

What I want to say is that there is just no Swift code in the Pod.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller Then why would you need a bridging header in your pod? Projects that use your pod just need to import your pod's headers in the project's bridging header to make them available to Swift.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

I want to skip the projects bridging header and ship the pod with a pre configured bridging header.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller You can't and shouldn't. End-developers, at the moment, are expected to manage their own bridging headers. As a pod maintainer you do not (and should not) have the ability to modify their bridging header or project settings.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

That is why I want to create a separate bridging header in my pod.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller I'm trying to explain that doing so (even if it were possible) would not give you the ability to do what you want.

Think of it this way: you are working on an app. It's written in Swift, mostly, and you want to use an Objective-C pod. You install the pod and manually type #import <ThePod/ThePod.h> into your bridging header, as instructed by the pod's installation instructions.

The pod, if it could include a bridging header, would use it to import private Objective-C code directly into Swift. This is not currently possible, but it also doesn't accomplish what you want to do. A pod's bridging header would not propagate down into your app. The modules are separate.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

Okay so it is impossible?

from sqlite.swift.

stephencelis avatar stephencelis commented on June 19, 2024

@steffimueller Nope. Clarified in previous comment.

from sqlite.swift.

steffimueller avatar steffimueller commented on June 19, 2024

Thanks for help.

from sqlite.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.