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

Question: what are the best practices that you recommend to debug a carthage framework? #1326

Closed
TofPlay opened this issue Jun 1, 2016 · 15 comments
Labels

Comments

@TofPlay
Copy link

TofPlay commented Jun 1, 2016

Hi,
I did not see relevant information in the file README.md and I wish to know what are the best practices that you recommend to develop and debug a framework before it release as a carthage framework.
Do I have to include my framework as a sub-project on my application?
Is there a configuration to set up in the project that include this sub-project?

@mdiep mdiep added the question label Jun 1, 2016
@mdiep
Copy link
Member

mdiep commented Jun 1, 2016

I would typically use --use-submodules, include my framework as a sub-project, and develop that way.

Just be aware that if you run a Carthage command, the changes to your dependency could be lost. So commit and push frequently!

@TofPlay
Copy link
Author

TofPlay commented Jun 1, 2016

Hi Matt. Thanks for your reply 😊
I have some more questions... 😉

Question 1: When I use --use-submodules all dependencies are declared in the .gitmodules. But I just need submodules for my own frameworks not all frameworks. Can I specify that I want only my frameworks as submodules?

Question 2: On the project section General > Linked Frameworks and Libraries what framework I must take? The one in Carthage/Build/iOS/MyFramework.framework or in Xcode MyApplication.xcworkspace > MyFramework.xcodeproj > Products > MyFramework.framework?

Question 3: On the project section Build Phases > Run Script do I have to let /usr/local/bin/carthage copy-frameworks and in section Input Files all frameworks used by my project?

@mdiep
Copy link
Member

mdiep commented Jun 2, 2016

Question 1: When I use --use-submodules all dependencies are declared in the .gitmodules. But I just need submodules for my own frameworks not all frameworks. Can I specify that I want only my frameworks as submodules?

No.

Question 2: On the project section General > Linked Frameworks and Libraries what framework I must take? The one in Carthage/Build/iOS/MyFramework.framework or in Xcode MyApplication.xcworkspace > MyFramework.xcodeproj > Products > MyFramework.framework?

The latter.

Question 3: On the project section Build Phases > Run Script do I have to let /usr/local/bin/carthage copy-frameworks and in section Input Files all frameworks used by my project?

copy-frameworks is only needed for frameworks that are built with Carthage.

@TofPlay
Copy link
Author

TofPlay commented Jun 3, 2016

Hi Matt
Everything seems to work on my current folder. But I have some issue when I try to make a git clone --recursive -b <my branch> <myproject> to test a new installation from scratch.
When I execute the command carthage update --use-submodules --platform iOS I have this output:

$ carthage update --use-submodules --platform iOS
*** Fetching MyFramework
*** Fetching Reachability.swift
*** Fetching realm-cocoa
*** Fetching algoliasearch-client-swift
*** Fetching stripe-ios
*** Fetching AlamofireObjectMapper
*** Fetching ObjectMapper
*** Fetching Alamofire
*** Fetching PureLayout
Parse error: expected submodule commit SHA in output of task (ls-tree -z HEAD Carthage/Checkouts/Alamofire) but encountered:

When I check on Carthage/Checkouts is empty
What I missed?

@TofPlay
Copy link
Author

TofPlay commented Jun 3, 2016

Ok I found it
For Alamofire I was obliged to run those commands:

$ git submodule add -f https://github.com/Alamofire/Alamofire.git Carthage/Checkouts/Alamofire
$ cd Carthage/Checkouts/Alamofire
$ git checkout tags/3.4.0

I had to do the same for other frameworks
My mistake was to believe that with only Cartfile I could restore a functional environment with the command carthage update --use-submodules --platform iOS
We must also commit submodules in Carthage/Checkouts and don't forget to clone the main repository with --recursive option.

Suggestion: Carthage can execute the command git submodule to check if all sub-modules are properly installed. If not execute the commands above.

@TofPlay
Copy link
Author

TofPlay commented Jun 3, 2016

It's not finish yet 😞
When I try to upload my project on App Store I have this warning
uplaod to appstore

Any ideas?

@ikesyo
Copy link
Member

ikesyo commented Jun 3, 2016

That should not be related to Carthage, that would be an issue on iTC side. See also CocoaPods/CocoaPods#5453.

@TofPlay
Copy link
Author

TofPlay commented Jun 3, 2016

@ikesyo Ok in this case just wait and see 🙂
If you have any update can you post a message here? I will do the same.

@pcantrell
Copy link
Contributor

I would typically use --use-submodules, include my framework as a sub-project, and develop that way.

IMO, use-submodules should be an option in Cartfile, not the command line, because this:

Just be aware that if you run a Carthage command, the changes to your dependency could be lost. So commit and push frequently!

…is terrible.

Better still, would you be open to supporting a Cartfile-relative local path instead of a Github repo? This would have several advantages:

  • It would greatly ease local development of a framework.
  • Carthage could still support submodules, but get out of the business of managing them and mucking with a project’s git config.
  • This would better support frameworks including an example project that uses the framework.

@mdiep
Copy link
Member

mdiep commented Jun 8, 2016

IMO, use-submodules should be an option in Cartfile, not the command line

#426 is tracking this idea.

Better still, would you be open to supporting a Cartfile-relative local path instead of a Github repo?

Carthage already supports this.

@pcantrell
Copy link
Contributor

Better still, would you be open to supporting a Cartfile-relative local path instead of a Github repo?

Carthage already supports this.

As far as I can tell, it only works with absolute paths. Carthage appears to resolve relative paths against its internal cache instead of the Cartfile, which renders it useless for the cases I mentioned above:

git "file:../.." "master"
$ carthage update
*** Cloning ..
Failed to check out repository into /Users/paul/Library/Caches/org.carthage.CarthageKit/dependencies/..: No object named "master" exists

Same happens with "../..", "file:/../.." and "file://../..". Am I being dense and missing something?

@mdiep
Copy link
Member

mdiep commented Jun 9, 2016

Oh, you're probably right. I missed that you wanted to use a relative path. Sorry!

A better solution is to just drag the other project into your Xcode project/workspace and build it that way. Just take it out of your Cartfile completely or don't use the copy from your Cartfile while you're developing.

@pcantrell
Copy link
Contributor

A better solution is to just drag the other project into your Xcode project/workspace and build it that way. Just take it out of your Cartfile completely or don't use the copy from your Cartfile while you're developing.

Sure. (Workspace only, right?) But then you’re not testing the framework exactly as Carthage builds it, which has bit me in the past.

@TofPlay
Copy link
Author

TofPlay commented Jun 9, 2016

Hi @pcantrell

…is terrible.

Yes it's terrible! Having to manage Carthage and git submodule for the same project is not simple. For having tested It's easy to make mistakes. It would have been better if Carthage completely took over git submodules or proposed it's own solution.
Maybe we'll have something simpler in future versions of Carthage 😉

Workspace only, right?

Not only on the workspace. You can drag and drop your framework project from /<your project>/Carthage/Checkouts/<your framework>/<your framework>.xcodeproj under your application project as a sub-project. You have to declare your /<your project>/Carthage/Checkouts/<your framework> as a git submodule too for your framework but unfortunately also for all other frameworks. And you have to really be very careful when you manage commits of the main project and those from your framework see as a git submodule.
It's what I have done for my framework. It works. But as I said above this is not simple and it's not a Carthage solution.
What can be confusing (for me) we can use carthage --use-submodules ... but after we have to manage submodules with git.

@TofPlay
Copy link
Author

TofPlay commented Jun 18, 2016

I worked around about how I can create and maintain my own frameworks (compatible with Carthage). At the first time the option --use-submodules was for me a good thing but in practice is not really simple. Define my framework as a git submodule is not the best but it's ok. But for sure I don't really want submodules for all others frameworks manage by Carthage. After several trying I declare my frameworks as submodules and embedded frameworks in my main project. For the others frameworks I use Carthage as usual (without --use-submodules ). Because my frameworks are not manage by Carthage on the main project I create a Cartfile with all dependencies of my frameworks. This way I can maintain my frameworks from the main project. And because each framework has its own repository and it's own Cartfile I can use it as carthage framework on other projects.
I would have preferred all do from Carthage but currently it is not possible. Carthage do not differentiate between the frameworks are used in a project where we just need the binary version and those we developed ourselves and that we must maintain.
Carthage team has already done an amazing job. I am sure they will propose an elegant solution to handle this case. Definitely better than the one I currently use 😋

@TofPlay TofPlay closed this as completed Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants