Using Swift with Kuzu C++ Api

Hi
I am new to swift (& apple dev) and i was trying to use Kuzu (C/C++ in-memory graph store) with Swift and after struggling to get the Kuzu lib into Xcode i hit some errors and don't know how to proceed.

Initially, without "SWIFT_IMMORTAL_REFERENCE", i got the following build error:

Type 'kuzu.main' has no member 'Database'

After adding "SWIFT_IMMORTAL_REFERENCE", i got the following build error instead

'kuzu.main.Database' cannot be constructed because it has no accessible initializers

But in the C++ code, there is an obvious Public Constructor - so why does the compiler say it has no accessible initializer ? Does this have anything to do with 'std::unique_ptr' attributes ?

Any clue on how to resolve this ?

BTW, i am using Swift 6.0 & XCode 16 (i believe RC1)

Part of the Kuzu C++ header is included below.

class  Database {
    friend class EmbeddedShell;
    friend class ClientContext;
    friend class Connection;
    friend class StorageDriver;
    friend class testing::BaseGraphTest;
    friend class testing::PrivateGraphTest;
    friend class transaction::TransactionContext;
    friend struct extension::ExtensionUtils;

public:
  
    KUZU_API explicit Database(std::string_view databasePath,
        SystemConfig systemConfig = SystemConfig());
    
    
    KUZU_API ~Database();

private:
    std::string databasePath;
    DBConfig dbConfig;
    std::unique_ptr<common::VirtualFileSystem> vfs;
    std::unique_ptr<storage::BufferManager> bufferManager;
    std::unique_ptr<storage::MemoryManager> memoryManager;
    std::unique_ptr<processor::QueryProcessor> queryProcessor;
    std::unique_ptr<catalog::Catalog> catalog;
    std::unique_ptr<storage::StorageManager> storageManager;
    std::unique_ptr<transaction::TransactionManager> transactionManager;
    std::unique_ptr<common::FileInfo> lockFile;
    std::unique_ptr<extension::ExtensionOptions> extensionOptions;
    std::unique_ptr<DatabaseManager> databaseManager;
    common::case_insensitive_map_t<std::unique_ptr<storage::StorageExtension>> storageExtensions;
    QueryIDGenerator queryIDGenerator;
} SWIFT_IMMORTAL_REFERENCE;

Thanks

1 Like