問題タブ [objective-c-swift-bridge]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
2309 参照

ios - Objective-C 呼び出し Swift 関数

MySwift.swiftファイルで定義された Swift 関数:

SomeSwift()はどの Swift クラスでも定義されておらず、純粋な関数です。

CMD+の後B、プロジェクトをビルドして開くProject-Swift.hと、SomeSwift()そこには表示されません。

Swift の関数は、いくつかの Swift クラスで定義する必要がありますか? と@objcマーク付き?

次のように:

0 投票する
1 に答える
510 参照

objective-c - Objective-C コード Swift-framework-internal

Swift フレームワークには次の構造があります。

残念ながら、ClassA内にアクセスできませんFrameworkA.swift。エラーは次のとおりです。

未解決の識別子「ClassA」の使用

ClassA保護/フレームワーク内部にする必要があります。

私は何を間違っていますか?

0 投票する
1 に答える
100 参照

objective-c - Cannot access Swift vars from objective-c, Xcode 8

I have looked at a lot of posts on this topic, and I still can't see what I am doing wrong. I have a view controller in objective-c that is trying to access an NSObject code snippet in Swift. I have Debugs Module YES and both the objective-c Bridging Header and the Swift header are at the correct places in Build Settings. Here are the relevant parts of the code:

Swift code:

In ViewController.m, starting to type MyClass receives the following warning from the compiler:

/Users/nelson/swiftTest/swiftTest/ViewController.m:20:5: Use of undeclared identifier 'MyClass'.

Note that I declare the Swift class as @objc and public. My understanding from Apple's documentation is that this should make any vars and functions visible to objective-c code in the same target. Project module name is 'swiftTest.'

Can anyone shed some light on this? I've been trying to get it to work for almost an entire day. Thanks!