Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Can this library be used from Swift on macOS? #9

Closed
ejsarge opened this issue Feb 4, 2017 · 4 comments
Closed

Can this library be used from Swift on macOS? #9

ejsarge opened this issue Feb 4, 2017 · 4 comments

Comments

@ejsarge
Copy link

ejsarge commented Feb 4, 2017

Great looking library - I think it would solve a problem I have very well.

I'm trying to use it from Swift and I can't get it to link. (I normally program in another language so I don't know what I'm doing here.) I followed the instructions to install CocoaPods and add this library. I also added CocoaImageHashing to the Linked Frameworks and Libraries.

When I attempt to run the default Hello World swift I get

dyld: Library not loaded: @rpath/CocoaImageHashing.framework/Versions/A/CocoaImageHashing
Referenced from: /Users/sarge/Library/Developer/Xcode/DerivedData/PHashTest-cdongczzcrynrfclysczwalanrlq/Build/Products/Debug/PHashTest
Reason: image not found
(lldb)

If I remove the use_frameworks! from the Podfile I get

Framework not found CocoaImageHashing

My Podfile

platform :osx, '10.12'
target 'PHashTest' do
    use_frameworks!
    pod 'CocoaImageHashing', :git => 'https://github.com/ameingast/cocoaimagehashing.git'```
end

Many thanks for any help or documentation updates you might provide.

@ejsarge ejsarge changed the title Can this library be used from Swift? Can this library be used from Swift on macOS? Feb 4, 2017
@ameingast
Copy link
Owner

ameingast commented Feb 6, 2017

The combination of Cocoapods and Objective-C works, but I'm not sure about Swift and Cocoapods.

I'm currently using CocoaImageHashing in a large macOS project (100% Swift) through Carthage and it works just fine.

@nicoara
Copy link

nicoara commented Feb 23, 2017

Any update on this? I have the following problem trying to use the library in Swift:
http://stackoverflow.com/questions/42394692/swift-use-of-undeclared-type-for-objective-c-library?noredirect=1#comment71937205_42394692

--
update: solved the issue. Cocoapods does not install this library correctly in Xcode 8.2.
At Target level, in Build Settings -> Search Paths -> Header Search Paths: there is a path generated by Cocoapods that does not correspond to any actual folder structure: "${PODS_ROOT}/Headers/Public/CocoaImageHashing" when the /Headers/Public structure does not exist. I removed that and remained with ${PODS_ROOT}/CocoaImageHashing , corresponding to the folder Projectname/Pods/Pods-Projectname.debug.xcconfig and now the library was seen.
as an aside, the #import <CocoaImageHashing/CocoaImageHashing.h> is imported inside the Bridging Header file.

@ejsarge
Copy link
Author

ejsarge commented Feb 23, 2017

@ameingast Thanks. I tried Carthage and I, too, found it worked just fine too.
Perhaps I might suggest the installation instructions in the Readme be updated to include Carthage instructions?
This is especially for people new to Swift who don't know the build tool options and just blindly follow what the library says...

The hashing worked great, btw.

@ameingast
Copy link
Owner

The documentation was updated by @sarah-j-smith.

I'm closing this for now. If there's any more trouble with Swift + Cocoapods, please open another issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants