SnapKit icon indicating copy to clipboard operation
SnapKit copied to clipboard

No Such module Snapkit Error

Open snibble-manan opened this issue 3 years ago • 40 comments

New Issue Checklist

🚫 If this template is not filled out your issue will be closed with no comment. 🚫

  • [x ] I have looked at the Documentation
  • [x ] I have read the F.A.Q.
  • [x ] I have filled out this issue template.

Issue Info

Info Value
Platform iOS
Platform Version 14.0
SnapKit Version 5.0.1
Integration Method cocoapods

Issue Description

I have an Screen Shot 2021-03-10 at 9 35 39 AM iOS project running on Xcode 12.2 with a minimum iOS version required 14.0. I get an error of No such module 'Snapkit' when I try to run the app on a simulator from the Xcode. Running on a physical device has no issues. Help me solve this issue, please.

snibble-manan avatar Mar 10 '21 14:03 snibble-manan

@snibble-manan do you work on m1 chip ? I think #687 is the same issue take a look at it .

mhmdzaid avatar Mar 11 '21 21:03 mhmdzaid

same issue for m1 chip -> Could not find module 'SnapKit' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator. no solution found on stackoverflow works.. SnapKit added with SPM

marcnpopa avatar Mar 17 '21 00:03 marcnpopa

I'm having a look at this now :)

robertjpayne avatar Apr 21 '21 22:04 robertjpayne

Hey all, I cannot replicate this using Cocoapods (latest) or Swift PM. Is this still an issue for anyone?

robertjpayne avatar Apr 21 '21 22:04 robertjpayne

I had the same problem

Jissbon avatar May 14 '21 03:05 Jissbon

same issue on xcode 12.2,Is there a solution?

joeZheng3 avatar May 17 '21 04:05 joeZheng3

same issue on xcode 12.2,Is there a solution? stp 1 : pod stp 2 : build stp 3 : import

Jissbon avatar May 17 '21 05:05 Jissbon

I have the same problem on m1.

There is any solution?

paulocoutinhox avatar Aug 17 '21 22:08 paulocoutinhox

Same problem @paulo-coutinho on M1 Any solutions everyone?

pulpcorn avatar Sep 10 '21 05:09 pulpcorn

Hi, no.

I think that this was abandoned.

paulocoutinhox avatar Sep 10 '21 07:09 paulocoutinhox

@paulo-coutinho @pulpcorn @cguess

This isn't abandoned it's just that nobody has been able to provide me with workable project files that exhibit the bug reported. I've repeatedly tested this and have not found any issue to fix.

I've just now created a brand new project in Xcode 12, created a pod file and installed it and it has no issues. I've attached it below if anyone can let me know what I'm missing project configuration wise I'm more than happy to look at it but from my perspective this is an issue with project configurations outside of my control.

SnapKitTester.zip

robertjpayne avatar Sep 15 '21 04:09 robertjpayne

Also here is a test project using SPM that also does not exhibit the issue:

SnapKitTesterSPM.zip

robertjpayne avatar Sep 15 '21 04:09 robertjpayne

Hi,

This happen on M1.

Did you tested on M1 machine (device and simulator)?

Thanks.

paulocoutinhox avatar Sep 15 '21 05:09 paulocoutinhox

@paulo-coutinho Yep I have a M1 MacBook Pro I've been using. I've tested the builds for both device and simulator but can't see the issue.

I'm really happy to dig into this further but I need a sample project that exhibits the bug.

robertjpayne avatar Sep 15 '21 08:09 robertjpayne

Ok,

When i back from vacation i will make one and will post here the zip.

paulocoutinhox avatar Sep 15 '21 16:09 paulocoutinhox

Same issue here, I use code below to fix it.

in your Podfile, add below lines.

# for Mac M1
  post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end

Haibo-Zhou avatar Sep 21 '21 05:09 Haibo-Zhou

I am experiencing this problem as well on my M1 Mac, and I installed SnapKit via SPM. My workaround is to use Rosetta. When I run Xcode under Rosetta, I can run my app in a simulator just fine, and everything else works. This is how I enabled it:

  1. Close Xcode.
  2. Find Xcode.app in the Applications folder.
  3. Secondary click and select "Get Info".
  4. Enable "Open using Rosetta".
  5. Open Xcode.

This option probably incurs a small Xcode performance penalty since you are running the Intel binaries translated to ARM by Rosetta, but it works for now.

ebelinski avatar Oct 10 '21 15:10 ebelinski

@robertjpayne I tried to create a sample Xcode 13 project for you, but found that I was unable to. Here are the differences between my various projects:

  • My project with many dependencies, including SnapKit installed via SPM, and multiple other dependencies (some very old) installed via CocoaPods: Fails to build for simulator (Could not find module 'SnapKit' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator, at: /Users/eb/Library/Developer/Xcode/DerivedData/Explorer-bfuqohdbnqzfnmedduxlyflpkrbk/Build/Products/Debug-iphonesimulator/SnapKit.swiftmodule)
  • My other old project with only one dependency, SnapKit installed via SPM: No issues whatsoever.
  • A sample project I just created with SnapKit installed via SPM: No issues whatsoever.
  • Another sample project I created with SnapKit installed via SPM and an old dependency (Haneke) installed via CocoaPods: No issues whatsoever.

This leads me to suspect that maybe the problem is not with SnapKit or the way I installed SnapKit, but something else entirely, like maybe my build settings or some other dependency, and maybe the only reason the error mentions SnapKit is because of how often SnapKit is imported in my project compared to other dependencies.

These are my SPM dependencies:

image

This is my Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!

workspace 'Explorer/Explorer.xcworkspace'

project 'Explorer/Explorer.xcodeproj'

target 'Explorer' do
  project 'Explorer/Explorer.xcodeproj'

  pod 'MeridianSDK', '~> 6.6.0'
  pod 'MagicalRecord', :git => 'https://github.com/magicalpanda/MagicalRecord', :tag => 'v2.3.3'
  pod 'iCarousel', :git => 'https://github.com/Dschee/iCarousel.git', :commit => '6f239439e52a93c8e86ded9bc58ef1441ceb3a94'
  pod 'Masonry', '1.1.0'
  pod 'lottie-ios', '2.5.3'
  pod 'FMDB', '2.7.5'
  pod 'GLTF', :git => 'https://github.com/ubiquity6/GLTFKit', :commit => '7a1d386b20ebdbdfe5ba9d5b51ed2b1754870f6d'
  pod 'GLTFMTL', :git => 'https://github.com/ubiquity6/GLTFKit', :commit => '7a1d386b20ebdbdfe5ba9d5b51ed2b1754870f6d'
  pod 'GLTFSCN', :git => 'https://github.com/ubiquity6/GLTFKit', :commit => '7a1d386b20ebdbdfe5ba9d5b51ed2b1754870f6d'
  pod 'Haneke', '~> 1.0.2'
end

# Fix for the Xcode warning about differing deployment targets.
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

And these are my build settings:

image image image image

@robertjpayne I have no idea what your schedule looks like, but if you have time I'd be happy to pair with you and let you look at my project to see what the issue might be and if we can resolve this for others. I'm in the Central timezone (Chicago). No worries if not though, I can continue using the Rosetta workaround.

ebelinski avatar Oct 10 '21 15:10 ebelinski

@robertjpayne I actually managed to put together a sample project with the issue. First I added SnapKit via SPM, and I tried to build for a simulator on Xcode 13 on my M1 MacBook Pro without using Rosetta. It worked just fine.

Then I added a pod called MeridianSDK via CocoaPods. MeridianSDK is a closed source library, it's officially distributed via CocoaPods as an executable binary, and the version I used was 7.4.0 (released September 22, 2021). When I tried to do the same build for a simulator, I got this error:

Screen Shot 2021-10-10 at 1 25 30 PM

If I comment out import SnapKit, it builds fine again. If I remove MeridianSDK, it also builds fine. So it seems that my sample project works fine with one framework, but not the other. My understanding of multiple architectures is limited, so I don't know if the problem lies with SnapKit or MeridianSDK, but it seems to me that for whatever reason, SnapKit doesn't work with other dependencies distributed as binaries on M1 yet. I will contact the maintainers of MeridianSDK and see what they say.

Also, I noticed that if I install MeridianSDK first, then SnapKit via SPM, the SPM interface in Xcode gives me the option to choose either "SnapKit" or "SnapKit-Dynamic". But I still got the same error after choosing "SnapKit-Dynamic".

Edit: For what it's worth, here is another sample project where I tried the same thing but with Alamofire instead of SnapKit. I got the same error message as before. So it seems not to be a problem with SnapKit per se, but with binary dependencies that perhaps aren't fully up-to-date for M1 Macs.

ebelinski avatar Oct 10 '21 18:10 ebelinski

Make sure you are opened the yourproject.xcworkspace instead of yourproject.xcodeproj worked for me.

rajada1 avatar Oct 11 '21 20:10 rajada1

I was also encountered similar issues on M1, but i resolved by doing following steps, my system configs are as below, Screenshot 2021-10-28 at 5 19 54 PM Xcode 13,

  1. Add source 'https://github.com/CocoaPods/Specs.git' on pod file
  2. Add one of the following on pod file: post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings['VALID_ARCHS'] = 'arm64, arm64e, x86_64' end end or post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end
  3. Clean the build folder,
  4. Remove Podfile.lock file and pod generated .xcworkspace file
  5. Update cocoa pods,
  6. Now run the command pod install or arch -x86_64 pod install

This will install all new fresh pods, build the project and start using.

prem0423 avatar Oct 28 '21 11:10 prem0423

Everything was working fine with our app until today. We updated to Xcode 13.2 to deal with the missing framework issue and now can't build.

I tried the suggestions in this discussion, but none of them appear to work.

William-Froelich avatar Dec 16 '21 03:12 William-Froelich

@William-Froelich What is the specific error message you're encountering now? If it's the missingPackageDescriptionModule error, it's a known issue with Xcode 13.2 when installed from the App Store. Apple currently recommends downloading Xcode 13.2 directly from the Apple Developer site as workaround.

ebelinski avatar Dec 16 '21 04:12 ebelinski

It fails on arm64 compilation for iPhone

error: no such module 'SnapKit'
import SnapKit
       ^

There's no other error message. Is there some place else I should check?

William-Froelich avatar Dec 16 '21 04:12 William-Froelich

@ebelinski not sure how I resolved it, but purging the cocoapod cache, and re-installing Xcode from Apple's download site seems to have gotten us building again.

I also made Apple's suggested change to linking flags and stripped the IPHONEOS_DEPLOYMENT_TARGET values from all the pods.

William-Froelich avatar Dec 16 '21 06:12 William-Froelich

Having the same issue here, i'm using M1 and XCode 13. Tried to reinstall cocoapods but still remains the error: No such module found with SnapKit. Any workarounds ? already tried all the suggetions above.

ktchaos avatar Dec 16 '21 19:12 ktchaos

Having the same issue with SnapKit installed via SPM with other dependencies. All dependencies installed via SPM

easydev991 avatar Feb 16 '22 13:02 easydev991

Having the same issue here, i'm using M1 and XCode 13. Tried to reinstall cocoapods but still remains the error: No such module found with SnapKit. Any workarounds ? already tried all the suggetions above.

For M1 chip and Xcode 13 I was able to resolve this by following the steps mentioned here

rada avatar Feb 20 '22 12:02 rada

It's really strange case. I've just resolved this issue by next steps:

  1. replace project by copy from git
  2. in build settings -> Build active architecture only: YES, Excluded architectures: clear (arm64 was added)
  3. clean buildFolder, close Xcode
  4. clean derrivedData
  5. remove pods folder, pod file, podfile.lock and .xcworkspace file
  6. run pod init
  7. add pods to pod file
  8. add platform :ios, '13.0' to pod file
  9. run pod install

Also I tried to create new project with all my pods - it works fine. I have m1 max chip

ArturRuZ avatar Mar 12 '22 13:03 ArturRuZ

I have the same issue BUT importing SnapKit in my Swift package (module). This is my Package.swift

// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "TestModule",
    platforms: [.iOS(.v13)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "TestModule",
            targets: ["TestModule"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "5.0.0")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "TestModule",
            dependencies: [
                .product(name: "SnapKit", package: "SnapKit")
            ]),
        .testTarget(
            name: "TestModuleTests",
            dependencies: ["TestModule"]),
    ]
)

And this is my TestModule.swift inside Sources/TestModule:

import SnapKit // No such module SnapKit
import UIKit

public struct TestModule {
    public private(set) var text = "Hello, World!"

    public init() {
    }
}


public extension UIView {
    func addSubviewWithConstraints(_ view: UIView, _ closure: (ConstraintMaker) -> Void) {
        addSubview(view)
        view.snp.makeConstraints(closure)
    }
}

Problem: No such module SnapKit

BTW: I have Intel chip

shatodj avatar Aug 09 '22 08:08 shatodj