But it is weird. In my C header, there are still some complex macros can be compiled. This is another complex macros code in C, but they can be compiled.
Those are not complex. Those are just type aliases. What makes you original macro complex is the value assignment. Swift's handling of C macros does not seem to allow procedural code substitution, even if it's not really procedural (you're defining an enum). The Swift compiler does not operate the same as the C-preprocessor, it's not just a strict text substitution pass like it is in C.
Hmm. Well, it could still be what I'm thinking of, though those are some obtuse errors. Swift expects C libraries to be modules in the Clang sense, with a module map that's generated by Xcode or SwiftPM. But you can also provide one explicitly, which will let you mark ion_error_codes.h as a textual header, rather than one that's meant to be included directly. That'll look something like this: