Home Features Docs Blog Support GitHub

XCode 9 build error "Type redefinition 'uint_least16_t'" on Swift header import

Hi,

In XCode 9 (running the app from XCode) I am getting this build error:

Typedef redefinition with different types (‘uint_least16_t’ (aka ‘unsigned short’) vs ‘char16_t’)

On the line of import of the generated [Target]-Swift.h header (we have swift code used in obj-c code).

I tried changing the “C++ Language Dialect” from “Compiler Default” to anything above C++ 98 and it solved the build issue in XCode, but now the gradle build fails with this error:

The following build commands failed:
CompileC /[path]/build/moe/xcodebuild/obj/Muvix.build/Release-iphoneos/[…].build/Objects-normal/armv7/[…].o [path]/[…].m normal armv7 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

:[…]:moeMainReleaseIphoneosXcodeBuild FAILED

So, what compiler dialect should I choose and how do I make it work in gradle too?

Thank you,
Alex.

Hi,

we are working on adding Xcode 9 support, we will release an updated MOE 1.3 build as soon as we have one.

Best Regards,
Gergely

ok, please let me know when it’s out.

Are we getting close now? I can’t install on iOS11 through MOE plugin.

For Libgdx MOE requires updates as well. See https://github.com/libgdx/libgdx/issues/4899. https://github.com/libgdx/libgdx/pull/4902 has update for Robovm.

Hi, @Noisyfox,

We are updating libimobiledevice in MOE to fix this issue.

Best Regards,
Gergely

Check out the new release here:

Thanks. Can I test with our project or only the samples?

Sure, you should test with your project.

It’s not so clear in the explanation… it says to download the samples first… And then it says “Import the project into your favorite IDE”, do I need to re-import?

It was for the samples only.

If you are testing your project, just update the moe-gradle plugin version to 1.4.+, and then call gradlew moeUpdateXcodeSettings. If you are using Maven, you should also update it to 1.4.0.

After this, your app should work with MOE 1.4 and Xcode 9. If not, please let us know.

Best Regards,
Gergely

Still getting the same error when running gradlew moeIpaBuild from command line:

The following build commands failed:
CompileC /[path]/build/moe/xcodebuild/obj/Muvix.build/Release-iphoneos/[…].build/Objects-normal/armv7/[…].o [path]/[…].m normal armv7 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

And BTW, the moeUpdateXcodeSettings didn’t change anything in my files… was it supposed to?

BTW 2, the simple ‘gradlew build’ succeeds… only the moeIpaBuild fails.

I deleted the ‘build’ folder before building, if that matters.

Also, archiving from Xcode works (after changing the compiler to gnu 17)

We will take a look.

Where do you import this Swift header? In ObjC code? Can you regenerate it with Xcode 9?

Could you provide a short Swift code snippet that is similar to the one you try to interface into ObjC and causes this error with moeIpaBuild? This would be a great help for us to reproduce this issue.

Thank you,

Yes, in ObjC code. I think it’s regenerated every time I build, no?
Anyway, when I change the compiler dialect to “gnu 17” in xcode settings then I don’t get this error, but I get an error in command line build.

I will try to make you a sample. should I change the compiler dialect to “gnu 17” or leave it on “default” in my project?

Thanks.

Please configure the project in a way, that shows the problem: fails on the command line but works from Xcode.

I think this is happening because we have set in the build settings “Compile Sources As = Objective-C++” (without that we get a million build errors).

If I set this setting in a vanilla MOE project, I get the compile error in Xcode, but when I change the Compiler Dialect to gnu11 then it works both in Xcode and the command line.

Ok, I was able to reproduce it in a vanilla MOE project after I added the UIImageEffects third party that we are using.
Will upload the sample now.

See the sample project attached bellow.
As you can see running gradlew moeIpaBuild will fail with the error I mentioned. This worked in Xcode 8.

moeXcode9Swift.zip (110.3 KB)

Any progress with the sample project guys?

Hi!

I opened moeXcode9Swift sample with xcode 9 and saw errors in the UIImageEffects.m file. After fixed this erros, ipa build was worked.

Best Regards,
Roland