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

XCode 10.1 + Carthage support #360

Merged
merged 13 commits into from
Feb 14, 2019
Merged

XCode 10.1 + Carthage support #360

merged 13 commits into from
Feb 14, 2019

Conversation

byuarus
Copy link
Contributor

@byuarus byuarus commented Jan 17, 2019

Tested with:

  • XCode 10.1 (Swift 4.2.1)
  • Carthage 0.31.2

Note:

  • Added scripts in pre-actions of the build action of SwiftGRPC-Package scheme of the SwiftGRPC-Carthage.xcodeproj:
cd ${PROJECT_DIR}
swift package resolve 
ruby fix-carthage-paths.rb SwiftGRPC-Carthage.xcodeproj

Script fix-carthage-paths.rb will fix paths to dependecies from ./build folder to match the paths in the SwiftGRPC-Carthage.xcodeproj file.

  • Updated patch-carthage-project.rb so you can re created the SwiftGRPC-Carthage.xcodeproj with make project-carthage

Copy link
Contributor

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

I tested it and it works for me. It stays in the same philosophy as the previous Carthage support, but this time it doesn't rely on an implementation detail of SwiftPM.

I had issues running the Pre-actions at first, because of swiftenv. But I believe it is a weird behavior not coming from this PR. I filed it here on the swiftenv repo.

Another solution may be to use XcodeGen instead of generating the xcodeproj through SwiftPM, but I did not manage to do it, so I would go for that in the meantime.

Note: it may not be compatible with Xcode 9, but that probably only means that people wanting it for Xcode 9 would have to use and older release, which I believe is acceptable.

Thanks a lot @byuarus for the work!

Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

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

Wow, thank you for this! It feels like a hack, and it sucks that we have to resort to this, but I guess that it’s the best way for a deterministically working Carthage support.

Looks good; just two nits. Also, are you (and or @JonasVautherin) willing to maintain this script in the future, in case it gets broken by future Swift or Carthage versions?

repoNameInXcodeproj = stringArray[0]

if !repoNameInXcodeproj.nil? and repoNameInXcodeproj.include? ".git-"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: extra newline


swift_protobuf_target.new_shell_script_build_phase
# 3) Adding to SwiftGRPC-Package.xcscheme a script to Pre-Actions of BuildAction.
# Script will resolve SPM dependecies and will fix paths issues for SwiftGRPC-Carthage.xcodeproj before everytime before build action
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could you fix the grammar of this sentence and explain that it fixes the issues by MOVING the existing files rather than changing the Xcode project?

@JonasVautherin
Copy link
Contributor

Also, are you (and or @JonasVautherin) willing to maintain this script in the future, in case it gets broken by future Swift or Carthage versions?

The DronecodeSDK depends on grpc-swift, and supports Carthage. So we will be using that support for a while. Also, Carthage may support SwiftPM projects at some point 🤞

Copy link
Contributor

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

Trying the suggestion feature of Github :-)

fix-carthage-paths.rb Outdated Show resolved Hide resolved
patch-carthage-project.rb Outdated Show resolved Hide resolved
patch-carthage-project.rb Outdated Show resolved Hide resolved
@byuarus
Copy link
Contributor Author

byuarus commented Jan 24, 2019

@JonasVautherin , thank you for the suggestions!

PS: Looks like the suggestion feature works :)

@JonasVautherin
Copy link
Contributor

Just built again with the new commits, and that's still working!

Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

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

Thanks for this, I’m glad we now have a deterministic solution for Carthage!

Leaving the merge to @rebello95 or @timburks provided they approve as well :-)

@JonasVautherin
Copy link
Contributor

Note: fixes #329.

@MrMage MrMage merged commit 99d3834 into grpc:master Feb 14, 2019
warrenfalk pushed a commit to warrenfalk/grpc-swift that referenced this pull request Feb 27, 2019
* XCode 10 support

* Fixed Carthage support

* Carthage support WIP

* Moved the fix-carthage-paths script  to pre-build actions

* Fixed patch-carthage-project script to support carthage

* Fix carthage build

* Changing SPM dependencies-state.json

* Recreated SwiftGRPC-Carthage.xcodeproj file with updated script

* More fixes for Carthage

* Code clean up

* Update patch-carthage-project.rb

Co-Authored-By: byuarus <[email protected]>

* Update fix-carthage-paths.rb

Co-Authored-By: byuarus <[email protected]>

* Update patch-carthage-project.rb

Co-Authored-By: byuarus <[email protected]>
@Renosi
Copy link

Renosi commented Mar 21, 2019

I'm a newbie to working with Carthage and Github in general. I followed the steps outlined but I keep getting the error:

Building scheme "SwiftGRPC-Package" in SwiftGRPC-Carthage.xcodeproj
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/renosimomoh/Drone\ Delivery\ /Medical\ Drone/Carthage/Checkouts/grpc-swift/SwiftGRPC-Carthage.xcodeproj -scheme SwiftGRPC-Package -configuration Release -derivedDataPath /Users/renosimomoh/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/grpc-swift/b7659e1031b441da2db60fa879e8157799730f02 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/_s/vpqkvyq96rl9q9kj_b50w1s80000gn/T/grpc-swift SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO

How do I make sure that the recreatedSwiftGRPC-Carthage.xcodeprojis used when I run the Carthage update?

@julianoes
Copy link

@Renosi please create an issue in https://github.com/Dronecode/DronecodeSDK-Swift and paste all the output that you get in and quote the code with ```, thanks.

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.

5 participants