I have a Usecase where I want to pass user-defined swift class instance from Swift to C++ as argument to the C++ Function. In the documentation it's
mentioned that swift exposes these classes to c++.
Swift Code
public class MyClass {
public init (_ pValue : Int32) {
uValue = pValue
}
public var uValue : Int32
}
var obj = MyClass (20)
//Invoke C++ Method and pass the class Instance
CppClass.GetSwiftClassInstance(obj)
C++ Class Skeleton
// Header required to expose Swift Class to C++
#include "Test_Interop-Swift.h"
class CppClass{
public:
static void GetSwiftClassInstance (Test_Interop::MyClass pObj) noexcept ;
};
void
CppClass::GetSwiftClassInstance(Test_Interop::MyClass pObj) noexcept {
std::cout << pObj.getUValue() << std::endl;
}
I am getting this build error:
Cycle inside Test_Interop; building could produce unreliable results.
Cycle details:
→ Target 'Test_Interop' has Swift tasks blocking downstream compilation
○ Target 'Test_Interop': SwiftMergeGeneratedHeaders /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/DerivedSources/Test_Interop-Swift.h /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/Test_Interop-Swift.h
○ Target 'Test_Interop' has Swift tasks blocking downstream compilation
Raw dependency cycle trace:
target: ->
node: <all> ->
command: <all> ->
node: <Linked Binary /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Products/Debug/Test_Interop> ->
command: P2:target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452-:Debug:Ld /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Products/Debug/Test_Interop normal ->
node: /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/CppClass.o ->
command: P1:target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452-:Debug:CompileC /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/CppClass.o /Users/veerdutta/Desktop/Test_Interop/Test_Interop/Test_Interop/CppClass.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler ->
node: <target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452--swift-generated-headers> ->
command: P0:::Gate target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452--swift-generated-headers ->
node: /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/Test_Interop Swift Compilation Requirements Finished ->
CYCLE POINT ->
command: P2:target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452-:Debug:SwiftDriver Compilation Requirements Test_Interop normal arm64 com.apple.xcode.tools.swift.compiler ->
node: /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/DerivedSources/Test_Interop-Swift.h ->
command: P2:target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452-:Debug:SwiftMergeGeneratedHeaders /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/DerivedSources/Test_Interop-Swift.h /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/Test_Interop-Swift.h ->
node: /Users/veerdutta/Library/Developer/Xcode/DerivedData/Test_Interop-dihkjxspmvnppoacxcjsucbgoxsb/Build/Intermediates.noindex/Test_Interop.build/Debug/Test_Interop.build/Objects-normal/arm64/Test_Interop-Swift.h ->
command: P2:target-Test_Interop-499ad222fd1c24676066f175e82857e362dda2ed35810dcf4925033fd0364452-:Debug:SwiftDriver Compilation Requirements Test_Interop normal arm64 com.apple.xcode.tools.swift.compiler
How can I achieve my outcome?