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 #520

Closed
wants to merge 18 commits into from

Conversation

turbulem
Copy link
Contributor

@turbulem turbulem commented Jun 14, 2018

Hi!
I faced an issue similar to this and this this.
In my project I use Carthage and commit my artefacts into my repo. And CI(and any other machine) is not able to compile it without running 'carthage update'.
Basically the problem that to link Starscream.framework with other app or library you should provide module.map similar to the one, located in /zlib folder (but without header, which is required only for build).
To make this work I created new custom module map and added a wrapper for SHA1 algorithm used by Starscream. Also updated cocoapods spec to add custom module map + private headers.

Please consider this PR as a possible way of resolving issues linked above and also I'd be happy to hear from you any suggestions on this.

Thank you!
Cheers!

@kotsaarev
Copy link

Hello @turbulem.

Thank you for your solution! But I still have a problem.

I use GitLab CI, two build machines, cache server and Carthage. When I create cache on the first machine, and then use it on the second one, I get an error

Missing required modules: 'SSCZLib', 'SSCommonCrypto'

@turbulem
Copy link
Contributor Author

@kotsaarev Thank you for feedback. Let me check

@turbulem
Copy link
Contributor Author

I double checked. You're right. Looks like it actually doesn't solve an issue.
I have an alternative solution and will update this PR with it later this week.

@turbulem turbulem changed the title Move CommonCrypto and zlib dependencies mapping to private module map Move CommonCrypto and zlib dependencies mapping to custom module map Jun 25, 2018
@JeanAzzopardi
Copy link

Just to add my 2c, I'm getting the same issue with Starscream on CircleCI - where I'm building carthage dependencies on a different lane and then using the cached dependencies for the test suite, and I get the same error: missing required modules: 'SSCZLib', 'SSCommonCrypto'

@turbulem
Copy link
Contributor Author

@JeanAzzopardi Did you check the most recent version?
The latest version in my repo should work fine:
turbulem@8ca8df0

@JeanAzzopardi
Copy link

I haven't checked your version @turbulem, will try it out now and let you know how it goes.

@JeanAzzopardi
Copy link

@turbulem - I can confirm your solution works on CircleCI

@turbulem
Copy link
Contributor Author

@JeanAzzopardi Thank you! Hope this PR will help you to fix the issue

@JeanAzzopardi
Copy link

JeanAzzopardi commented Jun 27, 2018

However @turbulem , I just tested on device (compiled on my machine with Xcode 9.3) and swift 4.1.2, running on iOS 11, and I am getting a crash:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteData _fastCStringContents:]: unrecognized selector sent to instance 0x1c4237600'

Crash is occurring in these lines:

private extension String {
    func sha1Base64() -> String {
        return (self as NSString).ss_SHA1Base64Digest()
    }
}

@turbulem
Copy link
Contributor Author

@JeanAzzopardi Does this happen only on real device? Let me check later today on device. Thank you for your feedback!

@JeanAzzopardi
Copy link

JeanAzzopardi commented Jun 27, 2018 via email

@turbulem
Copy link
Contributor Author

@JeanAzzopardi It may be related to the ss_SHA1Base64Digest function that I added in my PR. This is small wrapper around CC, but all tests passed and I didn't check on device. I will have some time later this week or on a weekend.
But if you can check, that would be wonderful!

@JeanAzzopardi
Copy link

@turbulem So I downloaded your branch and checked it out, the tests do pass, but trying the SimpleExample with the local websocket server on simulator gives me the same error.

@turbulem
Copy link
Contributor Author

turbulem commented Jun 28, 2018

Actually yes, I made a mistake. I return NSData instead of NSString and somehow compiler let me get away with it, producing a warning I didn't pay attention to :(
I fixed it and updated PR.
Silly mistake, now it works well.
Thank you for your efforts to help!

@JeanAzzopardi
Copy link

Yes, it's working now, that was the issue!

No problem, glad to help out, looking forward for this P.R. to be merged.

@JeanAzzopardi
Copy link

@turbulem @daltoniam would it be possible to merge this? It's the last thing holding me back from upgrading to Starscream 3 <3

# Conflicts:
#	Starscream.xcodeproj/project.pbxproj
@turbulem
Copy link
Contributor Author

I've updated my branch with new changes

@kotsaarev
Copy link

Hello @turbulem!
I think the problem with sha1Base64 still here, but occurs only in DEBUG mode. I checked out bd0732e and

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._NSContiguousString ss_SHA1Base64Digest]: unrecognized selector sent to instance 0x108b21050'

Crash is occurring in same lines

private extension String {
    func sha1Base64() -> String {
        return (self as NSString).ss_SHA1Base64Digest()
    }
}

I tested with iOS 11.4, Xcode 9.4.1, Swift 4.1. For more info see crash file.

@turbulem
Copy link
Contributor Author

@kotsaarev I will double check later this week. Thank you.

@kotsaarev
Copy link

@turbulem
I have more information. This occurs not only in DEBUG. This is after pull and merge master because with ca783db all fine.

@turbulem
Copy link
Contributor Author

@kotsaarev So the final version should work fine. Let me know if I can help you anyhow.

@dive
Copy link

dive commented Aug 3, 2018

@kotsaarev, any chance that it will be merged in the near future?

@JeanAzzopardi
Copy link

@daltoniam Any chance that this could be merged? It's the only blocker preventing me from releasing an update as I use CircleCI for releases.

@czater
Copy link

czater commented Sep 3, 2018

any chance to merge?

@gregiOS
Copy link

gregiOS commented Sep 6, 2018

Two things are missing here:
NSString+SHA1.m need to be added into Starscream (and test target)
Current solution is making app to crash /
screen shot 2018-09-06 at 12 08 23
Other linkers flag need to contains -all-load
screen shot 2018-09-06 at 12 09 23
https://github.com/gregiOS/Starscream/pull/1/
Here you can check those changes with tests

@turbulem
Copy link
Contributor Author

@gregiOS Thank you for review. I made necessary changes. Now should be fine.

@gregiOS
Copy link

gregiOS commented Sep 26, 2018

Any chance for rebase @turbulem, and merge @daltoniam?

@fassko
Copy link
Collaborator

fassko commented Sep 27, 2018

@turbulem Can you please take a look on these merge conflicts. It will be easier to merge these changes. Thanks!

@turbulem
Copy link
Contributor Author

Hi, I updated my branch, however there are some issues with new Swift and tests need to be updated. I will do this later this week.

@fassko
Copy link
Collaborator

fassko commented Sep 27, 2018

OK let me know when I can check again.

@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

@turbulem please check:

  • SSLClientCertificate.swift included twice in Sources folder
  • Xcode project doesn't have files from Sources/Starscream to build

@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

File SSLClientCertificate.swift is in Sources and Sources/Starscream. I guess it should be just once in project. Thanks!

.library(name: "Starscream", targets: ["Starscream"])
],
dependencies: [
.package(url: "https://github.com/daltoniam/zlib-spm.git", from: "1.1.0"),
Copy link
Collaborator

@fassko fassko Sep 28, 2018

Choose a reason for hiding this comment

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

I'm being picky here, but for consistency let's use same format without .git :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is some merge issue, I will update my branch and discards this changes.
I had no intention to change SPM config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it's some GH issue, because these files are equal:

https://github.com/daltoniam/Starscream/blob/master/Package.swift
https://github.com/turbulem/Starscream/blob/master/Package.swift

I will make another branch and refresh this PR in order to make it clear.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, I can adjust it later myself.

@turbulem
Copy link
Contributor Author

@fassko Thank you for your instant reviews 👍

@fassko
Copy link
Collaborator

fassko commented Sep 28, 2018

@turbulem Let me know when you're done and I will merge this.

@turbulem
Copy link
Contributor Author

@fassko I opened new PR, please take a look.

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.

None yet

9 participants