MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.61k stars 624 forks source link

building for macOS-arm64 but attempting to link with file built for unknown-x86_64 #1885

Open rgbworld opened 4 years ago

rgbworld commented 4 years ago

Unable to build target mailcore osx

Platform(s)

MacOS 11, Xcode 12 beta 3, Rosetta

I successfully build the target static mailcore2 osx, however building the mailcore osx framework, fails with the error:

Link MailCore (arm64) Ld: warning: ignoring file /Users/ME/Library/Developer/Xcode/DerivedData/mailcore2-fvvrkiycybjeqjevlwwzppotismq/Build/Products/Debug/libctemplate.a, building for macOS-arm64 but attempting to link with file built for unknown-x86_64ignoring file /Users/ME/Library/Developer/Xcode/DerivedData/mailcore2-fvvrkiycybjeqjevlwwzppotismq/Build/Products/Debug/libetpan.a, building for macOS-arm64 but attempting to link with file built for unknown-x86_64

I believe the linking fails because the Externals (libctemplate and libetpan) were not built with Rosetta, so there are mixed architectures.

How can I resolve unknown-x86_64 architecture? Do the dependencies need to be rebuilt so they match arm64 and x86_64?

Thanks for any suggestions - even a temporary fix :-)

rgbworld commented 4 years ago

Didn't mean to mark as a bug. Unable to remove the label.

glorysaber commented 4 years ago

+1

GF106 commented 3 years ago

+1

sl2qf commented 3 years ago

I'm also having the same issue. I tried building MailCore2 with ARM, but it also uses libctemplate and libetpan, which I could not figure out how to build.

ikemuc commented 3 years ago

I have the same problem.

platform: MacBook Pro 2020 (M1) macOS 11.0.1 Xcode 12.3 RC

dinhvh commented 3 years ago

Oh. I think we need to rebuild all the prebuilt dependencies :/ Meanwhile, you can take a look at https://github.com/MailCore/mailcore2/tree/master/scripts

demodit commented 3 years ago

With the scripts I could compile Libetpan, Ctemplate and the mailcore (libmailcore.a) on Mac Mini M1 for both architectures but after implementing them in my project at least 100 compiler errors happen. Here some of them:

Undefined symbols for architecture arm64: "ctemplate::TemplateDictionary::AddSectionDictionary(ctemplate::TemplateString)", referenced from: fillTemplateDictionaryFromMCHashMap(ctemplate::TemplateDictionary*, mailcore::HashMap*) in libMailCore.a(MCHTMLRenderer.o) "ctemplate::TemplateDictionary::SetValue(ctemplate::TemplateString, ctemplate::TemplateString)", referenced from: fillTemplateDictionaryFromMCHashMap(ctemplate::TemplateDictionary*, mailcore::HashMap*) in libMailCore.a(MCHTMLRenderer.o) "ctemplate::TemplateDictionary::TemplateDictionary(ctemplate::TemplateString const&, ctemplate::UnsafeArena*)", referenced from: renderTemplate(mailcore::String*, mailcore::HashMap*) in libMailCore.a(MCHTMLRenderer.o) "ctemplate::TemplateDictionary::~TemplateDictionary()", referenced from: renderTemplate(mailcore::String*, mailcore::HashMap*) in libMailCore.a(MCHTMLRenderer.o) "ctemplate::default_template_cache()", referenced from: ctemplate::Template::ExpandWithData(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, ctemplate::TemplateDictionaryInterface const*, ctemplate::PerExpandData*) const in libMailCore.a(MCHTMLRenderer.o) "ctemplate::StaticTemplateStringInitializer::StaticTemplateStringInitializer(ctemplate::StaticTemplateString const*)", referenced from: __GLOBAL__sub_I_MCHTMLRenderer.cpp in libMailCore.a(MCHTMLRenderer.o) "ctemplate::Template::StringToTemplate(ctemplate::TemplateString const&, ctemplate::Strip)", referenced from: renderTemplate(mailcore::String*, mailcore::HashMap*) in libMailCore.a(MCHTMLRenderer.o) "ctemplate::Template::ExpandWithDataAndCache(ctemplate::ExpandEmitter*, ctemplate::TemplateDictionaryInterface const*, ctemplate::PerExpandData*, ctemplate::TemplateCache const*) const", referenced from: ctemplate::Template::ExpandWithData(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, ctemplate::TemplateDictionaryInterface const*, ctemplate::PerExpandData*) const in libMailCore.a(MCHTMLRenderer.o) "_carray_add", referenced from: mailcore::AutoreleasePool::AutoreleasePool() in libMailCore.a(MCAutoreleasePool.o) mailcore::AutoreleasePool::add(mailcore::Object*) in libMailCore.a(MCAutoreleasePool.o) mailcore::Array::addObject(mailcore::Object*) in libMailCore.a(MCArray.o) "_carray_delete_slow", referenced from: mailcore::AutoreleasePool::~AutoreleasePool() in libMailCore.a(MCAutoreleasePool.o) mailcore::Array::removeObjectAtIndex(unsigned int) in libMailCore.a(MCArray.o) "_carray_free", referenced from: mailcore::AutoreleasePool::~AutoreleasePool() in libMailCore.a(MCAutoreleasePool.o) mailcore::AutoreleasePool::destroyAutoreleasePoolStack(void*) in libMailCore.a(MCAutoreleasePool.o) mailcore::Array::~Array() in libMailCore.a(MCArray.o) "_carray_new", referenced from: mailcore::AutoreleasePool::AutoreleasePool() in libMailCore.a(MCAutoreleasePool.o) mailcore::AutoreleasePool::createAutoreleasePoolStackIfNeeded() in libMailCore.a(MCAutoreleasePool.o) mailcore::Array::Array() in libMailCore.a(MCArray.o) mailcore::Array::init() in libMailCore.a(MCArray.o) mailcore::Array::Array(mailcore::Array*) in libMailCore.a(MCArray.o) "_carray_set_size", referenced from: mailcore::Array::insertObject(unsigned int, mailcore::Object*) in libMailCore.a(MCArray.o) mailcore::Array::removeAllObjects() in libMailCore.a(MCArray.o) "_chash_delete", referenced from: removeFromPerformHash(mailcore::Object*, void (mailcore::Object::*)(void*), void*, void*) in libMailCore.a(MCObject.o)

I also tried to use Mac framework instead Mac static library, but when following installation instruction it does not work. So after many hours I will give up :-(

Would be great if arm64 compatible Mailcore would be available with CocoaPods.

janek commented 3 years ago

@dinhvh @haithngn I think this is causing any macOS app that uses MailCore to fail to build for release on any current or recent version of Xcode (reported in #1907 with a bit more detail).

It's a pretty insidious problem because debug builds work fine (if you have an Intel Mac). That means someone can assume they can use this package and invest time, only to find out that they can't release their app with it. I hope it's something that won't be too hard to fix in the near future. Appreciate your work!

EDIT: I found a workaround that worked fine, so now the only problem is that my app would not work on Apple Silicon Macs. That's still something that needs to be fixed sooner or later in order to support Mac as a platform - but arguably less urgent than I thought initially.

KaiOelfke commented 3 years ago

I successfully followed the steps in this blog post to make iOS simulators work with MailCore on a M1 Mac. By adding arm64 to the excluded architectures I can build, run and archive a project on a M1 Mac as a Rosetta app. It should run on Intel Mac devices as well, but I didn't test this yet.

This is good enough for my local development needs. But of course native support would be better.

ikemuc commented 3 years ago

Oh. I think we need to rebuild all the prebuilt dependencies :/ Meanwhile, you can take a look at https://github.com/MailCore/mailcore2/tree/master/scripts

Hi,

I'm developing on a Apple Silicon MacBook Pro. For a while I had a workaround of compiling for Intel only and the App runs on the M1 using Rosetta. Did a SwiftUI evaluation for some time. Now I want to continue to develop my application and therefore I have to run unit tests also. The problem is, that in Xcode on a M1 Mac, unit tests run on ARM64 only, so Rosetta cannot be used. This means that my unit tests fail to compile because of mailcore2.

You pointed to the scripts folder.

Maybe you could give me some more detailed instructions on what has to be done to compile all dependencies on ARM64 so mailcore runs natively on all M1 Macs? Which scripts have to run? At what order? (Hint: I'm not really good at porting applications to other architectures, but I'll try...) I think it's absolutely worth to make mailcore2 run on ARM64 Macs natively as these are so much better than the INTEL Macs, so it's only a matter of time that they replace the INTEL Macs everywhere.

Your help is appreciated! :-)

ikemuc commented 3 years ago

Oh. I think we need to rebuild all the prebuilt dependencies :/ Meanwhile, you can take a look at https://github.com/MailCore/mailcore2/tree/master/scripts

Hi,

I'm developing on a Apple Silicon MacBook Pro. For a while I had a workaround of compiling for Intel only and the App runs on the M1 using Rosetta. Did a SwiftUI evaluation for some time. Now I want to continue to develop my application and therefore I have to run unit tests also. The problem is, that in Xcode on a M1 Mac, unit tests run on ARM64 only, so Rosetta cannot be used. This means that my unit tests fail to compile because of mailcore2.

You pointed to the scripts folder.

Maybe you could give me some more detailed instructions on what has to be done to compile all dependencies on ARM64 so mailcore runs natively on all M1 Macs? Which scripts have to run? At what order? (Hint: I'm not really good at porting applications to other architectures, but I'll try...) I think it's absolutely worth to make mailcore2 run on ARM64 Macs natively as these are so much better than the INTEL Macs, so it's only a matter of time that they replace the INTEL Macs everywhere.

Your help is appreciated! :-)

BTW: I use mailcore2 via the Swift Package Manager. Had several problems with Cocoapods and Carthage before...

vincedev commented 2 years ago

You may find my other comment of some interest

lionserdar commented 2 years ago

@vincedev would it be possible for you to create MailCore2 XCFramework for ios as well ? - looks like above only provide macos framework which doesn't work for iphone. Your help is appreciated!