Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CommonCrypto and zlib dependencies mapping to custom module map #559

Merged
merged 4 commits into from
Oct 8, 2018

Conversation

turbulem
Copy link
Contributor

Details:
#520

commit 467334e
Author: Sergey Lem <[email protected]>
Date:   Fri Sep 28 10:47:53 2018 +0100

    Remove old file

commit 631c256
Author: Sergey Lem <[email protected]>
Date:   Fri Sep 28 09:51:15 2018 +0100

    Fix project settings

commit d629a65
Merge: 6371914 7f12731
Author: Sergey Lem <[email protected]>
Date:   Wed Sep 26 14:58:20 2018 +0100

    Merge branch 'master' of github.com:turbulem/Starscream

    # Conflicts:
    #	Starscream.xcodeproj/project.pbxproj

commit 6371914
Author: Sergey Lem <[email protected]>
Date:   Mon Sep 10 09:45:21 2018 +0100

    Add NSString+SHA1 to test target

commit 33846d1
Author: Sergey Lem <[email protected]>
Date:   Mon Sep 10 09:40:09 2018 +0100

    Fix project inclusion and add missing linker flag

commit 74e3c63
Author: Sergey Lem <[email protected]>
Date:   Wed Jul 25 10:47:16 2018 +0100

    Pull master branch from daltoniam/Starscream

commit 912e7da
Author: Sergey Lem <[email protected]>
Date:   Thu Jun 28 11:30:51 2018 +0100

    Fix return type for SHA1 digest and cast warning

commit 70234bc
Author: Sergey Lem <[email protected]>
Date:   Mon Jun 25 13:18:18 2018 +0100

    Add custom wrapper for SHA1 and custom modulemap for framework including module maps for CommonCrypto and zlib

commit 94f8d58
Author: Sergey Lem <[email protected]>
Date:   Thu Jun 14 18:52:14 2018 +0100

    Move CommonCrypto and zlib dependencies mapping to private module map

commit 7f12731
Author: Sergey Lem <[email protected]>
Date:   Mon Sep 10 09:45:21 2018 +0100

    Add NSString+SHA1 to test target

commit 8df9d1e
Author: Sergey Lem <[email protected]>
Date:   Mon Sep 10 09:40:09 2018 +0100

    Fix project inclusion and add missing linker flag

commit bd0732e
Merge: 138cfa7 70fd033
Author: Sergey Lem <[email protected]>
Date:   Wed Jul 25 10:48:22 2018 +0100

    Merge branch 'master'

    # Conflicts:
    #	Starscream.xcodeproj/project.pbxproj

commit 138cfa7
Author: Sergey Lem <[email protected]>
Date:   Wed Jul 25 10:47:16 2018 +0100

    Pull master branch from daltoniam/Starscream

commit ca783db
Author: Sergey Lem <[email protected]>
Date:   Thu Jun 28 11:30:51 2018 +0100

    Fix return type for SHA1 digest and cast warning

commit 8ca8df0
Author: Sergey Lem <[email protected]>
Date:   Mon Jun 25 13:18:18 2018 +0100

    Add custom wrapper for SHA1 and custom modulemap for framework including module maps for CommonCrypto and zlib

commit 98e1d62
Author: Sergey Lem <[email protected]>
Date:   Thu Jun 14 18:52:14 2018 +0100

    Move CommonCrypto and zlib dependencies mapping to private module map
@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

Can you look into why it doesn't build with Swift PM. I get this error:

Compression.swift:30:8: error: no such module 'Starscream.SSCZLib'
import Starscream.SSCZLib

just run

swift build

@turbulem
Copy link
Contributor Author

Sure, let me check

@turbulem
Copy link
Contributor Author

Looks like proposed solution cannot be adopted by SPM. It doesn't seem to support explicit modules. I will investigate what can be done here.

@nuclearace
Copy link
Contributor

I would see for SPM if you could just use Swift 4.2's system targets. They look something like this https://github.com/nuclearace/SwiftDiscord/tree/vapor3/Sources/Sodium and https://github.com/nuclearace/SwiftDiscord/blob/vapor3/Package.swift#L43

@turbulem
Copy link
Contributor Author

@nuclearace Thank you, it looks very relevant.
Also I think that in iOS12/Mojave CommonCrypto has system bindings in swift so if target is the latest SDK I can get rid of Obj-C helper

@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

Maybe this is the option we can aim. You can still use older release for lover Swift version.

@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

@turbulem looks like you're right about CommonCrypto https://stackoverflow.com/a/50690346

@fassko
Copy link
Collaborator

fassko commented Oct 1, 2018

In which version of Swift are these libraries included? I think need to explicitly set Swift 4.2 version in Package.swift and podspec file. .swift-version is going to be deprecated and isn't used anymore?

I actually also came up with similar solution myself during weekend and I was running some tests. Not on Linux though. But for linux I think Swift NIO might be a better solution from Vapor.

s.libraries = 'z'
s.source_files = 'Sources/**/*.{h,m,swift}'
s.module_map = 'Sources/modulemap/Starscream.modulemap'
s.private_header_files = 'Sources/modulemap/**/*.h'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we delete modulemap and header file then this is not needed anymore.

Test also with some sample project integrating this pod against https://websocket.org/echo.html

Package.swift Show resolved Hide resolved
@turbulem
Copy link
Contributor Author

turbulem commented Oct 2, 2018

@fassko I updated my solution. It only works with new SDK, which might not be the best option. However it solves the problem and seem to work fine with Pods/Carthage/SPM.

@fassko fassko merged commit 384b803 into daltoniam:master Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants