How to use an SPM library in an (Xcode based) iOS project?


(Georgios Moschovitis) #1

I have created a nice little library with SPM ($ swift package init --type=library).
The library includes some utility classes and associated tests.
It works as expected.

Now, I would like to use this library within an iOS application.
AFAIK, SPM doesn't support iOS at the moment.

I am wondering, what is the best way to include my library in the iOS Xcode project/build?

thanks,
-g.


(Pierre Monod-Broca) #2

Hi,

swift package has a nice option for that : generate-xcodeproj (not sure about the exact spelling) which generate a proper Xcode project bundle.

You can then reference it from another Xcode project or workspace.

Pierre

···

Le 19 janv. 2017 à 11:22, Georgios Moschovitis via swift-users <swift-users@swift.org> a écrit :

I have created a nice little library with SPM ($ swift package init --type=library).
The library includes some utility classes and associated tests.
It works as expected.

Now, I would like to use this library within an iOS application.
AFAIK, SPM doesn't support iOS at the moment.

I am wondering, what is the best way to include my library in the iOS Xcode project/build?

thanks,
-g.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Georgios Moschovitis) #3

You can then reference it from another Xcode project or workspace.

I am aware of `generate-xcodeproj` but can you provide a link with details about the ‘reference’ part?
As an Xcode newbie, it’s not obvious to me how to do it.

thanks,
George.


(Pierre Monod-Broca) #4

Alright.

Typically I create a workspace (menu File > New > Workspace) and add both the app's project and the library project to the workspace (menu File > Add Files).

Then you can follow that guide to embed the framework in the app (which will also link it):
https://developer.apple.com/library/prerelease/content/technotes/tn2435/_index.html#//apple_ref/doc/uid/DTS40017543-CH1-EMBED_SECTION

Pierre

···

Le 19 janv. 2017 à 18:44, Georgios Moschovitis <george.moschovitis@icloud.com> a écrit :

You can then reference it from another Xcode project or workspace.

I am aware of `generate-xcodeproj` but can you provide a link with details about the ‘reference’ part?
As an Xcode newbie, it’s not obvious to me how to do it.

thanks,
George.


(Georgios Moschovitis) #5

Thank you, will check it!

George