I have to make use of the Azure IoT Hub SDK for C in a Swift iOS app that I’m engaged on to connect with the Azure hub and pay attention for cloud messages. It appears that there have been Pods for this objective however they have been deprecated a while in the past so I’ve been wanting into making a static library construct that I can combine myself nonetheless I’m having problem getting my constructed lib information to work.
Regardless of seemingly following the proper steps for constructing the libs with CMake to be used in iOS, when I attempt to run my app in Xcode I get an error saying:
Constructing for ‘iOS’, however linking in object file (Path/To/My/Challenge/AzureIoT/lib/libiothub_client.a[arm64]5) constructed for ‘macOS’
I’ve tried varied config in my ios.toolchain.cmake file such because the one beneath however getting the identical error. Have additionally tried targetting the iPhone Simulator/x86_64 but in addition with the identical end result. I’m doing all of this on a Mac Mini M2.
# Toolchain file for constructing iOS static libraries
# Set the goal system identify and platform
set(CMAKE_SYSTEM_NAME iOS)
set(CMAKE_OSX_SYSROOT iphoneos)
# Minimal deployment goal for iOS
set(CMAKE_OSX_DEPLOYMENT_TARGET "15.0")
# Architectures to construct (arm64 for iOS gadgets)
set(CMAKE_OSX_ARCHITECTURES "arm64")
# Specify the C and C++ compilers
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
# Configure output paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Allow Bitcode (required for iOS App Retailer submissions)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
# Disable shared libraries (non-compulsory if solely static libraries are wanted)
set(BUILD_SHARED_LIBS OFF)
find_package(OpenSSL REQUIRED)
find_package(CURL REQUIRED)