1
[Your First Cross-Platform Djinni App: Part 2, iOS][1]

I follow this guidline and everything works well if I create the new project with Object-C project. However, I want to use Swift project, so I changed the project language and create a bridge to connect Swift with Object-C. But it can't work.

if I try to call this function, error happens

  let hw = LipHelloWorld.create()

 Undefined symbols for architecture x86_64:
"std::__1::__shared_weak_count::__get_deleter(std::type_info const&) const", referenced from:
  vtable for std::__1::__shared_ptr_emplace<personalapp::HelloWorldImpl, std::__1::allocator<personalapp::HelloWorldImpl> > in libpersonalapp_objc.a(HelloWorldImpl.o)
  "std::__1::__next_prime(unsigned long)", referenced from:

Please help me!

hello_world.hpp

// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from personalapp.djinni

#pragma once

#include <memory>
#include <string>
namespace personalapp {

class HelloWorld {
public:
    virtual ~HelloWorld() {}
    static std::shared_ptr<HelloWorld> create();
    virtual std::string get_hello_world() = 0;
};
}  // namespace personalapp

HelloWorldImpl.hpp

 #pragma once 
 #include "hello_world.hpp"

namespace personalapp {

class HelloWorldImpl : public personalapp::HelloWorld{
public:
    HelloWorldImpl();

    std::string get_hello_world() override;
};
}

PersonalApp-Bridging-Header.h

#pragma once
#include "LipHelloWorld.h"
yeyimilk
  • 614
  • 2
  • 8
  • 18
  • Could you provide: - your implementation of std::shared_ptr HelloWorld::create(); - Objective-C Bridging Header content? – mkk Apr 25 '16 at 15:07
  • @mkk I have updated the question detail and answer, thank you. – yeyimilk Apr 26 '16 at 01:32

1 Answers1

2

Finally, I found the answer, click my project -> Build Settings --> All --> Linking --> Other Linker Flags, set its value to -lc++

yeyimilk
  • 614
  • 2
  • 8
  • 18
  • That makes sense, since the missing symbol is from the STL. I think you should be able to equivalently add libc++ to the "Link with Binary Libraries" build step, which might be a less hidden place to apply this setting. – Andrew May 01 '16 at 03:10