Kitura / SwiftKafka

Swift SDK for Apache Kafka
60 stars 19 forks source link

Using SwiftKafka for watchOS #9

Open MFabi23 opened 4 years ago

MFabi23 commented 4 years ago

I am developing a watchOS app, that uses data coming from a Kafkastream and I want to use this library for this purpose, but it keeps ignoring my local "librdkafka" library.

Detailed error description:

What I did:

  1. Installed librdkafka
    • brew install librdkafka
  2. Created app
    • Created a new watchOS standalone app in Xcode
    • Added a new SwiftPackage with the built-in SPM from Xcode using the URL from your GitHub SwiftKafka project
    • Added SwiftKafka to "Link Binary With Libraries" in my WatchKit Extension
  3. Build the App -> Build failed with above errors
MFabi23 commented 4 years ago

I tried with the AppleWatch simulators and a real AppleWatch Series 4 as target device.

winsmith commented 2 years ago

To compile librdkafka with Xcode, do these two things:

  1. brew install librdkafka
  2. add this to the target section of your Package.swift:
linkerSettings: [
    .unsafeFlags(["-Xlinker", "-L/usr/local/lib"], .when(platforms: [.macOS]))
]

I know this comment is old but I just finally figured this out and I'm overjoyed to share!

source: https://github.com/Kitura/SwiftKafka/issues/11#issuecomment-947528301