I created one Swift Package Manager dependency and I need to add a Carthage support in order that depndency later to be used with Carthage in a project. Can someone explain the steps involved in doing this?
Adding Carthage support to a dependency that uses SPM should be the same as adding Carthage support to a dependency that doesn't use SPM. The presence of SPM support should not impact Carthage at all.
The Carthage README has steps for adding Carthage support to your package. To summarize:
Make sure your Xcode schemes are marked as Shared.
Make sure carthage build --no-skip-current successfully builds your dependency.
Make sure to tag your releases with git tags.
OPTIONAL: prebuild binaries of your framework for quicker installation
The thing is a SPM package doesn't need a xcworkspace file. See e.g. one of my framworks for example. In that case using it as carthage dependency is not that straightforward or even possible.
The second thing to consider is that Apple changed the way resources, bundled with a framework are located from the app hosting the framework:
Important
Always use Bundle.module when you access resources. A package shouldn’t make assumptions about the exact location of a resource.
The main pain point here is that this struct is generated when SPM builds the framework but is not created when Carthage builds it. Read detailled information here.
If both points above don't aplpy for your framework then moshe-katz is right and you can just follow the proposed setup instructions. Otherwise please tell me how that works. I already search a solution to this problem for quite some time.
Related
I need to build a wrapper around code that has dependencies that are only available as Carthage dependencies. I have successfully added them to a standard tvOS swift project. I am authoring a react-native ui component in swift with the help of the create-react-native-library package by Callstack.
I added a cartfile in the same way as in my swift project, but this time in the iOS folder of the actual react-native package I am authoring. Here, carthage updates and builds the dependencies correctly, but they do not compile. There is no way to add the generated xc-frameworks to the package's Xcode project file (there are no options to add frameworks in the package project, only in the embedded example project).
Does anyone have any suggestion on how to proceed with this?
I have a project, made up multiple smaller projects. I manage this mess generally through Carthage, but for development, I make use of a xcworkspace, to make it easier and faster to make changes, and Xcode to build the child and master projects via the workspace.
I've recently started updating all the projects to make use of the new XCFrameworks format (instead of the "fat frameworks" which Carthage/Xcode use to generate).
If I'm just working on the root project (xcproject) and linking the XCFrameworks directly, it all works fine. The moment I switch to the xcworkspace and replace any of the XCFrameworks with it's XCProject, the build fails
Multiple commands produce '/Users/.../Library/Developer/Xcode/DerivedData/gnuwolzggqlzhlfiipjzbigitmvu/Build/Products/Debug-iphoneos/....framework':
1) Command: ProcessXCFramework /Users/.../Development/.../.../Carthage/Build/....xcframework /Users/.../Library/Developer/Xcode/DerivedData/gnuwolzggqlzhlfiipjzbigitmvu/Build/Products/Debug-iphoneos/....framework ios
2) Command: ProcessXCFramework /Users/shanew/Development/.../Libraries/.../Carthage/Build/....xcframework /Users/.../Library/Developer/Xcode/DerivedData/gnuwolzggqlzhlfiipjzbigitmvu/Build/Products/Debug-iphoneos/....framework ios
The sub project frameworks DO NOT embedded their dependencies (as if I recall, this caused other issues) and dependency management is managed through Carthage, so the root project AND the child project will share dependencies, which I think is the cause of the issue.
I had some "minor" luck, if I built the sub project first and then remove its "Frameworks, Libraries, and Embedded Content", I could get the root project to work, but when I tried to do this with multiple sub projects I started to run into issues.
I did note that when I remove the xcframeworks and replace it with the project, it displays the project with the "fat framework" icon, instead of the xcframeworks icon ... I doubt this part of the issue, but thought I'd mention it...
So, the question...
How do we include "sub projects"/"frameworks", which have xcframeworks dependencies (shared with other projects) into a xcworkspace and have it build without triggering the "Multiple commands produce ... output" errors.
Not sure this totally maps to OP scenario, but here's what worked for us.
Initial, working setup with .framework:
Workspace
Framework project
Depends on 3rd-party framework ZZZ, through Carthage
Has its own Carthage cartfile and Carthage directory
Linked to ZZZ .framework binary from Carthage\Build
Application project
Depends on Framework, through Xcode target dependency
Depends on 3rd-party framework ZZZ, through Carthage
Has its own Carthage cartfile and Carthage directory
Embeds and linked to ZZZ .framework binary from Carthage\Build
Then we moved 3rd-party dependency ZZZ to XCFramework, still through Carthage, and the same setup was not working anymore. Our framework was building fine, but building our application failed because multiple commands where trying to produce ZZZ.
What worked for us, in the end, was to modify Application project and the way it includes the 3rd-party framework ZZZ. Instead of having its own Carthage-managed dependency, build directory, built binary, etc. for the 3rd-party dependency, the Application project embedded and linked the same binary taken from our Framework Carthage\Build directory.
So a setup like the following:
Workspace
Framework project
Depends on 3rd-party framework ZZZ, through Carthage
Has its own Carthage cartfile and Carthage directory
Linked to ZZZ XCFramework binary from Carthage\Build
Application project
Depends on Framework, through Xcode target dependency
Does not explictly depend on 3rd-party framework ZZZ, through Carthage
Has no own Carthage cartfile and Carthage directory
(or anyway the 3rd-party framework is not listed there)
Embeds and linked to ZZZ XCFramework binary from Framework\Carthage\Build
Hope that makes sense.
The story is different when an Application project depends on our Framework not through Xcode target dependency, but through the raw XCFramework file copied somewhere. In that case, Application project must again explicitly depend on 3rd-party framework ZZZ through Carthage, and embed/link the XCFramework binary from its own Carthage\Build directory.
I have converted some of my class libraries to .NET Standard with Visual Studio 2017.
This was easy, add a .NET Standard class library project in place of the original project and add all the files in there. The .csproj file even looks like a nuspec file now with package information and such. Inside the project options there was a checkbox for "Generate NuGet package on build", which I checked. Easy peasy.
However, .NET Framework consumers of my class library now gets a ton of dependencies, I counted at least 20 other nuget packages that were added, most of which was completely unecessary for my library. In other words, was "easy peasy too easy?"
Is this just a byproduct of me using .NET Standard as the only build output and I should add back a .NET Framework library as well?
Packages such as the following will be added to a project that consumes my library, even though they are completely unnecessary:
System.Security.Cryptography.*
System.Xml.*
System.IO.*
etc. there's plenty of packages being added. My library does "glorified" array analysis and doesn't require much at all.
The Visual Studio project is configured to target .NET Standard 1.0 and the only reference visible is the "NETStandardLibrary" so it's not like I added all of those myself.
I've inspected the package and it doesn't seem to list all of those either.
Can I add only the packages I need and still target .NET Standard 1.0?
My class library is open source here: https://github.com/lassevk/DiffLib
The nuget package is here: http://www.nuget.org/packages/difflib/2017.4.24.2347
This is quite a complex situation at the moment:
Can I add only the packages I need and still target .NET Standard 1.0?
Yes you can do it, but this is no longer recommended. In essence, .NET Standard is a specification that is made up of the packages referencing it. The supported way is to reference NETStandard.Library since it guarantees to bring you all needed compilation references and logic that you need in order to build correctly.
Beginning with the upcoming netstandard2.0, NETStandard.Library will be a flat package without dependencies and the individual packages will be removed from the dependency tree if your project or any other project references them. Also, NETStandard.Library will not be published as a dependency - so if you build a netstandard2.0 library, the resulting NuGet package will have no dependencies. (NETStandard.Library.NETFramework is required to be installed when using it in .net framework projects - NuGet is supposed to do this automatically).
That being said, if you really want to do it, you can set
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
in the csproj file and then add items like <PackageReference Include="System.[Something]" Version="4.3.0" /> for everything you need.
My question is, it seems like difficult to get the framework cartfile name in Carthage whereas in CocoaPods it is too easy by using this like https://cocoapods.org/ we just copy and paste it.
Is there any websites or place to get all the frameworks cartfile name for Carthage dependency tool?
CocoaPods is a centralized dependency manager, which is why you have cocoa pods site listing out all of the available pods ready to be integrated into your awesome project.
Carthage is exactly opposite of that,
By contrast, Carthage has been created as a decentralized dependency
manager. There is no central list of projects, which reduces
maintenance work and avoids any central point of failure. However,
project discovery is more difficult—users must resort to GitHub’s
Trending pages or similar.
Version control Best practices.
When developing a program, I use third party libraries, NUnit and others.
I want to share the sources of this program hosted on http://www.codeplex.com/ or http://code.google.com/hosting/.
What are good practices as regards third libraries?
Should I add the dll of my third libraries in the version control ?
Thank you,
With the introduction of NuGet you have a different way to do this.
See this post by David Ebbo: Using NuGet without committing packages.
Basically you use NuGet to download and add package references to the libraries you want (assuming there's NuGet packages for the libraries you need), but do not add the Packages folder to your repository.
Instead you modify your pre-build step of the projects that require packages so that they automatically download the packages required if they're not present.
Testing has shown that this adds a minor delay to the build process when checking if the libraries are present, so this may or may not be good enough for you.
We always do especially if we are linking against a specific version, we have an NUnit folder for example and then a version folder within it.