"No member "snp" on type "UIView!" when trying to use imported SnapKit framework

IDE: Fire
Version: Version 10.0.0.2400 (develop) built on talax, 20190426-155608. Commit f04dec1.
Target (If relevant): iOS
Description:
I am wondering if it’s possible to use a Swift-based framework like SnapKit (see: https://github.com/SnapKit/SnapKit) within a Silver-based project? Should it work when I compile the library into a .framework file and then import it into Fire?

I have tried to import the framework but I am getting the compiler error and now I am not sure if what I am trying to do is actually supported by the compiler. I am not sure if the framework should be Objective-C based ones. My gut feeling thinks it should be :innocent:

Expected Behavior:
I would expect that the code will compile without any compiler errors and the constraints are working

Actual Behavior:
Compiler error: No member "snp" on type "UIView!" [/Users/x/Desktop/Bug/SnapKit/SnapKit/RootViewController.swift (16)]

Steps:
You can download my project code at: https://www.dropbox.com/s/fev5qjzt3sk4ucc/SnapKit.zip?dl=0

  1. Checked out the SnapKit project
  2. Build the framework for Generic iOS device and the iPhone XS-simulator device
  3. Navigated to the derived data directory and copied the .framework of each build to Frameworks/SnapKit directory in my Fire project
  4. Created a iOS and iOS Simulator directory inside and moved the respective framework file in each directory

Note: Here I am getting confused I am not sure which file I supposed to drag into the references section of my iOS project. The documentation suggests the tool will pickup the right .framework when you use the above structure. Only does this only refer when you use FXGen-tool or in general?

  1. Create a simple iOS project in Fire
  2. Drag the iOS's framework to the project
  3. Use some simple code to use the framework listed below
  4. Compile the project
  5. Notice the compiler error

Used RootViewController.swift

import UIKit
import SnapKit

@IBObject class RootViewController : UIViewController {

    public override func viewDidLoad() {

        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        let box = UIView()
        let container = UIView()

        container.addSubview(box)

        box.snp.makeConstraints { (make) -> Void in
            make.size.equalTo(50)
            make.center.equalTo(container)
        }
    }

    public override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

no. until Swift 5.2 has Module Stability, we cannot support importing or linking against Apple-Swift compiler frameworks.

1 Like

Thanks, logged as bugs://82475

that said, can you send me framework, for reference?

It’s this project: https://github.com/SnapKit/SnapKit (I used master-branch) and it’s being leveraged in the project at: https://www.dropbox.com/s/fev5qjzt3sk4ucc/SnapKit.zip?dl=0

Dan you do me a favor and send me the compiled .framework, zipped up?

It’s part of the Dropbox file:

Would this fulfil your request or do you want it separately?

DropBox won’t let me download it. can you just attach the zip?

1 Like

SnapKit.zip (1.0 MB)

Curious, there’s .h files in the .framework, but the one that has any interesting info is surrounded by a huge #if 0.

we’ll need to wait for Swift Module Stability to ship in 5.1 before we can look at importing/using Swift frameworks, but I fixed it to at least detect/warn about not being able to import a Swift framework, until then…

1 Like

Awesome, thank you! :slight_smile: