Since the update to Xcode 7.3 with Swift 2.2 I am not able to access variables from an external Objective-C Library.
Since today I was able to access this variables:
extern NSString* const DEFAULT_URL;
This is defined in an Objective-C Header file from a precompiled .a framework.
In my swift code I only had to call
Since Swift 2.2 I get the following errror:
Use of unresolved identifier 'DEFAULT_URL'
I am able to access the classes and methods of this framework, but I can’t access
Any ideas how to fix this?
@patrickS I had this for a silly reason, my extern const was defined inside an @interface in my .h file. This seems to have made it private to Swift code with this version of XCode / Clang. It applies to all extern consts not just NSString *.
//In Foo.h extern const int kBlah @interface Foo ... @end
//In Foo.h @interface Foo extern const int kBlah ... @end
I had the same problem and as in the question, the ext strings were in my case in a dependency-managed (cough pod cough) third party library. So I could not easily move them around without messing everything up in the long run.
I found two solutions:
- copy-paste the ext declaration to (the bottom of) your bridging
- write your own static helper class in objective c that
provides the ext strings as class methods (and make this static helper available to Swift)
I leave it up to you which of the two solutions you deem less hacky (I went with solution 1, as I am lazy).