Search code examples
iosxcodecocoapods

Xcode "no such module" error on all cocoapods pods in Mac M1


I'm trying to compile an app with cocoapods and a lot of pods in Xcode 14 on a mac with M1 processor. The project haves cocoapods and worked perfectly on an old mac.

When compiling, I'm receiving this error on my imports:

no such module 'devicekit'

If I remove the import, I get the same error for every pod in their imports. When I remove the imports, I get this:

Cannot find type X in scope Value of type X has no member Y

I tried every solution I found in posts like this: Getting error "No such module" using Xcode, but the framework is there

None of these solutions worked, so I'm sure this must be caused for using a M1 mac.


Solution

  • Finally I discovered the issue.

    In Pods project or in every pod build config you can see that Cocoapods is forcing the "debug" Build active architecture only property to YES.

    'Build active architecture only = YES'
    

    Changing it manually to NO in every pod, did the trick, but that is not a good way to solve it.

    You must go to your podfile and add this in the bottom part:

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            end
        end
    end
    

    That will force NO to every pod in Build active architecture only and the project will start compiling in your M1 mac.