owncloud / ios-library

MIT License
77 stars 90 forks source link

Import ios-library in Swift #127

Closed slashburn closed 8 years ago

slashburn commented 8 years ago

I'm new to Swift and I'm trying to import this library in Swift. Unfortunately I have no idea how it works.

I followed the instructions given here: https://doc.owncloud.org/server/8.2/developer_manual/ios_library/library_installation.html

In the last step, I added the following to the "Header Search Paths" (step 9) (similar as shown in the screenshot) to: $(PROJECT_DIR)/OCCommunicationLib/OCCommunicationLib

so that the compiler finds the headers. I also added (for testing purposes):

$(PROJECT_DIR)/OCCommunicationLib

so that the compiler should find the headers Whatever I try in my bridging header:

#import <OCCommunicationLib/OCCommunicationLib/OCCommunication.h>

or

#import <OCCommunicationLib/OCCommunication.h>

or

#import "OCCommunication.h

it tells me

OCCommunication.h file not found

How do I have to import the project so that I can use it or can we even make it available as a pod? That would probably be the easiest thing. But unfortunately as I mentioned, I have no idea how to do this.

javiergonzper commented 8 years ago

Maybe you have the OCCommunicationLib in other path and this is wrong: $(PROJECT_DIR)/OCCommunicationLib/OCCommunicationLib You can try to add that path absolute just to check if the problem it is there: /Users/user/...../OCCommunicationLib/OCCommunicationLib

Take into account that it is just for check if the problem it is there.

slashburn commented 8 years ago

Finally resolved the problem. You were right, thanks for your hint. Of course you have to copy the project first into your own project directory. Otherwise the compiler won't find the header file. My problem was, that I only drag and dropped the .xcodeproj into my project without copying the actual files. Im my bridging header I simply included:

#import "OCCommunication.h"

When using the library in Swift, no import statement is needed then.

javiergonzper commented 8 years ago

Great! Good luck with your project :+1: