SwiftKafka
SwiftKafka copied to clipboard
Using SwiftKafka for watchOS
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:
- Warnings:
- ignoring file /usr/local/Cellar/librdkafka/1.3.0/lib/librdkafka.dylib, building for watchOS-arm64_32 but attempting to link with file built for macOS-x86_64
- Errors: Undefined symbol: _rd_kafka_produce Undefined symbol: _rd_kafka_poll Undefined symbol: _rd_kafka_conf_dump Undefined symbol: _rd_kafka_topic_name Undefined symbol: _rd_kafka_consumer_close Undefined symbol: _rd_kafka_consumer_poll Undefined symbol: _rd_kafka_flush Undefined symbol: _rd_kafka_brokers_add Undefined symbol: _rd_kafka_commit Undefined symbol: _rd_kafka_topic_partition_list_new Undefined symbol: _rd_kafka_topic_partition_list_destroy Undefined symbol: _rd_kafka_message_destroy Undefined symbol: _rd_kafka_topic_new Undefined symbol: _rd_kafka_topic_partition_list_add Undefined symbol: _rd_kafka_subscribe Undefined symbol: _rd_kafka_conf_set_dr_msg_cb Undefined symbol: _rd_kafka_conf_set Undefined symbol: _rd_kafka_conf_dup Undefined symbol: _rd_kafka_conf_new Undefined symbol: _rd_kafka_conf_destroy Undefined symbol: _rd_kafka_conf_dump_free Undefined symbol: _rd_kafka_poll_set_consumer Undefined symbol: _rd_kafka_topic_destroy Undefined symbol: _rd_kafka_assign Undefined symbol: _rd_kafka_new Undefined symbol: _rd_kafka_destroy
What I did:
- Installed librdkafka
- brew install librdkafka
- 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
- Build the App -> Build failed with above errors
I tried with the AppleWatch simulators and a real AppleWatch Series 4 as target device.
To compile librdkafka with Xcode, do these two things:
brew install librdkafka- add this to the
targetsection of yourPackage.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