Home>
Thing I want to do

I want to run C ++ code on a Unity app that runs on an actual iOS device.
Therefore, I want to load the C ++ code as a Native Plugin in Unity, build it on iOS, and execute it.

Problems that are occurring

I get the following error and the build does not pass

Showing All Messages
CodeSign /Users/<username>/Library/Developer/Xcode/DerivedData/Unity-iPhone-gcvwgautdwehvhdjdhdmwwctijks/Build/Products/ReleaseForRunning-iphoneos/Unitytest2.app/Frameworks/framework_cpp_test.framework
    cd/Users/<username>/Documents/GitHub/Unity_test_2/ios
    export CODESIGN_ALLOCATE =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH = "/ Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin: /usr/local/bin:/ usr/bin:/bin:/usr/sbin:/sbin "
Signing Identity: "Apple Development:<your registered email address>"
   /usr/bin/codesign --force --sign 1BFE787A2D88CD0ADCFE9AB3F2E897A98B2B5332 --preserve-metadata = identifier, entitlements, flags --timestamp = none/Users/<username>/Library/Developer/Xcode/DerivedData/Unity-iPhone-gcvwgautdwehv Build/Products/ReleaseForRunning-iphoneos/Unitytest2.app/Frameworks/framework_cpp_test.framework
/Users/<username>/Library/Developer/Xcode/DerivedData/Unity-iPhone-gcvwgautdwehvhdjdhdmwwctijks/Build/Products/ReleaseForRunning-iphoneos/Unitytest2.app/Frameworks/framework_cpp_test.framework: replacing existing signature
/Users/<username>/Library/Developer/Xcode/DerivedData/Unity-iPhone-gcvwgautdwehvhdjdhdmwwctijks/Build/Products/ReleaseForRunning-iphoneos/Unitytest2.app/Frameworks/framework_cpp_test.framework: bundle format is ambiguous (could be app or framework)
Command/usr/bin/codesign failed with exit code 1


I think it's a certificate-related error, but I didn't know how to deal with it, so I asked.

Procedure
  • Create a framework project in XCode
  • Add the following .cpp file, build it, and create a framework file.
#include "cpp_test.hpp"
extern "C" {
int getNumber ();
}
int getNumber () {
    return 111;
}
  • UnityAssets/Plugins/iOSSet up a framework file under it
  • (I don't write the code to use because it happens only by being included in the project without using framework)
  • Create an iOS project by specifying iOS in Unity's Build Settings.
  • In the project TARGETS->Signing&Capabilities, specify the Team as your Personal Team.
  • Specify the Bundle Identifier.
  • Build.
Other things to check
  • Confirm that the build will pass if you do not install the framework file

*
I have no experience with both iOS and Unity, so I'm sorry if I said something strange at the root.
I would appreciate it if you could point out.

Usage environment, etc.
  • mac OS Catalina (10.15.6)
  • Unity: 2019.4.14f1
  • XCode: 12.1