I can build and run my app on my device, but when I tried to build archive, I got many errors. The errors are about my 3rd library - google protobuf. It showed that #error Host architecture was not detected as supported by protobuf. But what is the difference between archieve and normal build?? After all, I built successfully and ran my app on the device when I choose product=>run (cmd+R).
When you build to run, Xcode usually builds for the active architecture only. When you archive it builds all the architectures specified by the intersection of the Build Settings "Architectures and Valid Architectures".
So it's likely that Xcode is trying to build for some architecture that isn't supported by your protobuf library, e.g. Arm64.