Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX and iOS shared swift module

I have created swift based Cocoa Touch Framework project named TestLib then I have added new target for Cocoa Framework named TestLibOSX. When I use the framework on iOS app it seems to be working without any issue, but when I create OSX console application it XCode is complaining that it couldn't find TestLibOSX module. Am I missing something ?

P.S This is not the same :)

EDIT: Seems this must be possible since I can see Lister is implemented that way.

like image 455
Tamerlane Avatar asked Dec 30 '14 23:12

Tamerlane


1 Answers

If you wish to create a single dynamic framework binary, here are the steps you can follow (as outlined in http://colemancda.github.io/programming/2015/02/11/universal-ios-osx-framework/):

1. Change the project's valid architectures and supported platforms.

This should change your framework's and test unit's valid architectures and supported platforms as well. If not, then manually change them to inherit from the project's build settings.

Step One

  • Base SDK: I recommend OS X, but it will work with iOS too. Note that with with iOS as the base SDK, "My Mac" target is separated into 3 different targets.

  • Supported Platforms: macosx iphoneos iphonesimulator

  • Valid Architectures: arm64 armv7 armv7s i386 x86_64

2. Change the search paths for the Unit Test bundle

Step Two

  • Runpath Search Paths: $(inherited) @executable_path/Frameworks @loader_path/Frameworks @executable_path/../Frameworks @loader_path/../Frameworks

  • Framework Search Paths: $(SDKROOT) $(inherited)

This will allow you to import it as import MyFramework instead of

#if os(iOS)
    import MyFramework
#else
    import MyFrameworkOSX
#endif
like image 197
ColemanCDA Avatar answered Oct 14 '22 00:10

ColemanCDA