3

I am trying to integrate ios-ntp into my project, which I develop using Xcode 7, swift 2.0 and cocoapods. I am adding the library as a pod. But when I try to add <ios-ntp/ios-ntp.h> to my app-BridigingHeader.h, Xcode doesn't recognize it. When I try to simply import the module and use it by #import ios_ntp ; Xcode complains that he is not able to build module 'ios_ntp'. Am I doing smth wrong?

upd. Actually Xcode is not able to build the module due to the error

'GCDAsyncUdpSocket.h' file not found

but that framework is present and added in 'ios-ntp' pod spec as dependent.

Community
  • 1
  • 1
Nik Yekimov
  • 2,657
  • 2
  • 24
  • 34

2 Answers2

1

You shouldn't need to #import the library in your bridging header, Cocoapods should take care of making your pods available in Swift.

In your Swift files, have you tried import ios_ntp to import the library?

EDIT: Think I got it. Not 100% sure on why this is happening, but my hunch is that it's related to Cocoapods and ios-ntp's dependency on CocoaAsyncSocket. Something about ios-ntp's import of a CocoaAsyncSocket header is creating a circular dependency, which is borking ios-ntp's build.

Solution: https://github.com/ruddct/ios-ntp should do the trick, that branch contains a few very minor header changes to forward declare the CocoaAsyncSocket stuff in ios-ntp's headers, which fixes the issue.

See How to prevent circular reference when Swift bridging header imports a file that imports Hopscotch-Swift.h itself for more background on this issue.

Community
  • 1
  • 1
rudd
  • 846
  • 7
  • 17
  • Xcode autocomplete offers me to import ios_ntp, but even if I use import ios-ntp, Xcode is unable to build the module. And I don't add iOS-ntp to bridgingHeader.h file. – Nik Yekimov Oct 06 '15 at 20:31
  • thanks man, still had no chance to test your solution, but it sounds reasonable. – Nik Yekimov Oct 08 '15 at 14:44
  • @rudd your fork worked for me. Thanks :-) Are you going to issue a pull request? You're a few commits behind now. – Morgz Dec 04 '15 at 09:24
  • @rudd how do I install your pod over the regular one, as I am still getting this error with swift 3 – joshLor Apr 26 '17 at 01:10
  • @rudd sorry I am new to ios developing so I don't completely understand what you mean – joshLor Apr 29 '17 at 00:23
1

When you use Pods, you have to:

  1. Open Pods.xcodeproj
  2. In Targets select ios-ntp
  3. Select 'Build Phases' tab
  4. Add GCDAsyncSocket.h and GCDAsyncUDPSocket.h to Compile Sources and Headers
  5. Remember to set 'Allow Non-modular includes in Framework Modules' to Yes in ios-ntp

For me, this works.

B2D
  • 161
  • 1
  • 4