Quantcast
Channel: Package Manager - Swift Forums
Viewing all articles
Browse latest Browse all 166

Swift Doesn’t See ObjC id Properties When Protocol is Defined in a Swift Package

$
0
0

Hello! Going through the process of modularizing some code from a mixed ObjC/Swift codebase by putting into local packages. Facing an issue where Swift is not recognizing an ObjC id<Protocol> property where the Protocol was defined in Swift in a Swift Package.

SamplePackage

SampleProtocol.swift

@objc public protocol SampleProtocol: NSObjectProtocol {
    func doSomething()
}

SampleApp

ViewController.h

@protocol SampleProtocol;

@interface ViewController : UIViewController

@property id<SampleProtocol> sampleProperty;

@end

ViewControler+Extension.swift

import SamplePackage

extension ViewController {
    func doSomethingElse() {
        sampleProperty.doSomething() // Error: `Cannot find 'sampleProperty' in scope` 
    }
}

The project compiles fine without the swift usage so I believe it has been correctly set up otherwise.

Here is a sample project with the setup: GitHub - nikitaame/SampleApp

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 166

Trending Articles