我正在尝试在iOS Objective-C应用程序中使用流行的Swift库this helpful answer。我已经将该库作为使用cocoapods的框架进行了包含,我先运行=SUMPRODUCT(--(Table2[Name]=$E$2);--(ISNUMBER(SEARCH($F$2;Table2[Source])));Table2[Age])
,然后运行pod init
,并添加了一个类似的podfile:
pod install
我已经将快速代码导入到AppDelegate.m文件中,如下所示:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'MyObjectiveCApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for MyObjectiveCApp
pod 'Siren'
end
我现在可以访问#import <Siren/Siren-Swift.h>
类,但是我似乎无法引用Siren
类上的shared
静态属性。我已经尝试过Siren
和[Siren shared]
,但是都没有用。这是Siren.shared
类的前几行:
Siren
是否有任何文档或在Objective-C iOS应用程序中使用Siren的示例?这可能吗?我知道我可以使用Harpy,但是由于不再受支持,因此我尝试尽可能避免使用它。我已经研究过在Objective-C代码中使用Swift,但是找不到与访问类上的import UIKit
/// The Siren Class.
public final class Siren: NSObject {
/// Return results or errors obtained from performing a version check with Siren.
public typealias ResultsHandler = (Result<UpdateResults, KnownError>) -> Void
/// The Siren singleton. The main point of entry to the Siren library.
public static let shared = Siren()
属性特别相关的任何东西。我找到了This is a screenshot of the line I wrote,但它提到的是全局变量,而不是静态类属性。
答案 0 :(得分:1)
之所以无法访问fseek(fp, 0L, SEEK_SET)
属性,是因为它没有导出到shared
头文件(您可以检查生成的头文件)。
这是因为Siren类未明确标记为Siren-Swift.h
。
该类本身是导出的,因为它是@objc
的子类,但是默认情况下不导出属性。我认为我们无法独自解决。
我们可以做的是一种解决方法:
NSObject
的内部指针,复制并粘贴所有来自Siren的getters-setter,代理调用为真实的{{ 1}}; Siren.shared
;