Objective-C App using Swift Universal Static Library

Hi,


The thing is that I have an universal static library implement using Swift + Objective-C. This library has been integrated successfully in pure Objective-C applications, in the same way than in Swift (or Swift + Objective-C) applications.


My problem is that after upgrading to Xcode 10.2 and Swift 5.0, I am getting the following exception on running my Objective-C testing application. I have to say, that everything works properly when running other testing applications implemented using Swift or Objective-C + Swift.


This copy of libswiftCore.dylib requires an OS version prior to 12.2.0.


A workaround would be to include a simple empty Swift file in my Objective-C testing application (I have tested and it works), but I think that it is not the way of dealing with the problem.


Any help would be appreciated.


Regards,

The thing is that I have an universal static library …

What do you mean by “universal static library”?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi,


I mean a static library with a run scrip build phase to smash static library versions for different architectures into one fat binary and store it in a .framework (i.e. using lipo -create).


I have to tell you that I achieved to fix the problem including the following path /usr/lib/swift in the runpath search paths of the build settings in the target testing app.


Regards,

I mean a static library with a run scrip build phase to smash static library versions for different architectures into one fat binary

Different architectures (for example, 32-bit Arm and 64-bit Arm)? Or different _platforms (for example, iOS and the iOS Simulator)?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi,


Different platforms, sorry (i.e. iphoneos and iphonesimulator).


Regards,

OK, you are labouring under a common misconception here. As things currently stand, all the ‘slices’ of a universal binary must be for the same platform. Trying to mix two platforms in the same binary works in some circumstances, but you inevitably run into problems down the line. You can find more background to this on this thread.

That thread is about frameworks, which is the harder case. For static libraries you don’t have to worry embedding (the static library gets embedded automatically by the linker), so there should be a reasonable solution available to you.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi,


Thanks for your answer. The thing is that I am not talking about universal frameworks, but about univeral static libraries.


As I said before, the only problem was integrating our fat static library built using Swift + Objective-C in a pure Objective-C application. As commented, the solution in our side was the following (it works perfectly).


I have to tell you that I achieved to fix the problem including the following path /usr/lib/swift in the runpath search paths of the build settings in the target testing app.


I think that in previous versions of Swift those libraries were included automatically by the linker, but starting from Swift 5.0 we have had to include manually the path in which can be found. Is my assumption right?


Regards,


The thing is that I am not talking about universal frameworks, but about univeral static libraries.

Right, and this restriction applies there too.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Objective-C App using Swift Universal Static Library
 
 
Q