Reputation: 864
I am trying to embed a unity project into an existing swift project. I am getting the following error:
duplicate symbol _main in: /Users/vikasroy/Library/Developer/Xcode/DerivedData/CaptainCreek-fohhjxvaawusmeeuopzkmqmiplys/Build/Intermediates.noindex/CaptainCreek.build/Debug-iphoneos/CaptainCreek.build/Objects-normal/arm64/main.o /Users/vikasroy/Library/Developer/Xcode/DerivedData/CaptainCreek-fohhjxvaawusmeeuopzkmqmiplys/Build/Intermediates.noindex/CaptainCreek.build/Debug-iphoneos/CaptainCreek.build/Objects-normal/arm64/AppDelegate.o ld: 1 duplicate symbol for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any idea what the problem can be?
When I delete the @UIApplicationMain
annotation from the AppDelegate file, it works but then Unity Player opens directly at the launch.
My App has got a different main screen.
Upvotes: 0
Views: 646
Reputation: 1311
The Unity generated code contains another main method in the file main.mm. This method must be renamed to resolve the error. Although you will need the code from the generated main to initialise the Unity Player.
Furthermore you need more steps to succeed in embedding the unity project:
- You will need to link all the required libraries and
- Save an instance of the UnityAppController in your AppDelegate and make it accessible via the UnityAppController.h
There is a project on GitHub where all those modifications are automated: https://github.com/jiulongw/swift-unity
Upvotes: 1