Where is Swift Package Manager cache located (Swift 5.7)? - ios

After retagging a git commit I'm no longer able to fetch the package, because SP Manager uses some cache which I can't find and clean. Getting error:
Revision 30c16cab9c718416fee2191ff2ac0b6f91eeb511 for base
remoteSourceControl https://github.com/myUser/myRepo version 1.0.0
does not match previously recorded value
I cleaned all known to me places: local .build folder, SPM caches in Home and Library/Caches folders, DerivedData, removed Package.resolved.
Using Swift 5.7, trying to generate via swift package generate-xcodeproj.
Does anyone know where this cache is?

This one solves the issue for me.
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/org.swift.swiftpm
From https://blog.todosobreios.com/solucionar-problemas-de-swift-pacakge-manager-spm/

It depends on whether you're building via Xcode, or directly via swift build.
Xcode keeps its packages in ~/Library/Developer/Xcode/DerivedData/<your project>/SourcePackages/checkouts/.
SPM keeps them in .build/checkouts of the project folder.
In general, you should never change the commit a version tag points to, for precisely the reasons you experienced. The version numbers form the identity of a package version (not a commit hash, hash of the files, or anything like that). All the systems that are made to work with package rely on the notion that equal version number means they're identical. You're invalidating this assumption, and you'll cause bugs all over. Release a new minor version with your fix, instead.

Related

Swift Package Manager Dependency Mirroring

I have a project and:
the company I'm working with is self-hosting their git
the CI can communicate only with company's network
That being said, if I want to install any dependency, I have to ask their dev ops to mirror the target repository and only then I can use it.
The problem arises when I want to implement Crashlytics which has a lot of dependencies. When I import the Firebase, it's fetched from the mirrored repo correctly, but it's dependencies are still being fetched from the original URLs (which makes perfect sense).
The question is - How do I tell Swift Package Manager to swap each URL with mirrors? I have all the dependencies mirrored. I only need to tell SPM to use it.
I have found this proposal which was implemented in Swift 5, but when I go to root of my project and run:
$ swift package config set-mirror --package-url <original URL> --mirror-url <mirror URL>
I get this error:
error: root manifest not found
Any ideas how to do this correctly? Thank you
EDIT:
As Florian correctly pointed out, the proposal works from the package's repository, not my projects! So:
I do clone mirrored repo in my project's root
I run set of commands to set mirror url for each dependency:
swift package config set-mirror \
--original-url https://github.com/google/GoogleAppMeasurement.git \
--mirror-url <company's url>/mirrors/githubcom-google-GoogleAppMeasurement
I go back to projects root and run:
xcodebuild -resolvePackageDependencies -project MyProject.xcodeproj -scheme MyAppScheme
But it's still fetching from original urls, not the mirrors!
Having an Xcode project makes this task basically impossible (at the time of writing). Xcode's integration with SPM works fine for most things, but is not (yet?) at par with what SPM can do in pure SPM packages.
The problem is, that swift package config is always only local to the package and does not have any effect on projects / packages that depend on the package. And with Xcode currently having no counterpart to swift package config, it's not possible to do this at the moment.
What you could do, however, is to clone all your dependencies locally and then reference them as local packages from Xcode (simply dragging the package folder into the open Xcode project will do so). Xcode will be smart enough to take the dependencies from the local local checkout (or at least it was smart enough last time I tried this).
Let's hope for a future Xcode version with full SPM support!

Xcode 6: What to ignore when committing to SVN so the application can later be checked out and runnable without any extra work?

I want to commit the minimum amount of files and still be able to checkout and have it working without ANY work. This will be specifically used for a Phonegap iOS application. However, any relation to iOS apps will be great.
Essentially you may ignore only the builds/ folder as the files in there are generated every build. Have been working in a project with other develops having only this folder .gitignore'd.
If you wish, you may ignore several other files to make your repository as clean as possible.
Another way to commit as little as possible is to use external library managements, such as CocoaPods. Just remember to ignore Pods/ folder and run pod install when first running the project on a new computer.

Xcode 7 not working properly with source control

I just updated to Xcode 7, all system is updated, including command line tool, repaired disk permissions. And I still have several issues with that Xcode.
I am using GIT, but when I launch my project Xcode is ALWAYS asking me to upgrade to Subversion 1.7 even when I click on "Don't warn me again for this workspace" he does not remember.
When I quit and relaunch Xcode do not use my credential for GIT when I push he ALL the time ask me to type them.
When I go to preferences it builds up a stack of ghost buggy accounts...
And when I go to github, I realised that Xcode do not send my user.email when committing and pushing as I got a default email of ganzolo#noreply.github.com.
It's really annoying and buggy, does anybody have a clue?
I've removed SVN but still when I am doing a regular commit from command line (Git uses my user.email), when I am doing from Xcode he send like anonymous, really annoying.
You must have a subversion repo in your source tree, possibly in a 3rd-party library, that you are unaware of.
Go to Terminal and do this to upgrade it:
$ cd /path/to/sourcetree
$ find . -name .svn
If you get a hit then:
$ svn upgrade path/of/svnrepo
Better still dump the .svn directory and use git all the way through, if this 3rd-party library is also part of your permanent source tree.
Thanks to this post I found a solution :
https://stackoverflow.com/a/32546171/706189
It appears that Xcode have a bug and do not read global user.name and user.email. Therefor you need to set it locally in your root folder project.

Version control in iOS for an update

I recently released an app to the app store, and it works pretty well, but there were a few errors that I need to fix in an update. Namely, sometimes the score doesn't save correctly, and users cannot listen to their own music in the app. I never used version/source control when building the project, and I never used github.
So, I'm wondering if I should save a copy of the current version before updating it, or if the archive (created when I submitted the project to iTunes connect) is a suitable copy of the project (or is the archive in binary?)?
If the archive does not work as a copy of the code I can revert to (because it is in binary), are there any recommendations on how to save this working version of the app? Also, should I change the plist version before making edits?
Thanks. If this question is unclear just comment and I will try to explain better.
The best answer is simple: use a dedicated software version control system.
Use Git.
Git documentation and getting started help.
It's very easy to get started, even if you already have a ton of code.
$ cd ~/path/to/project
$ git init
$ git add -A
$ git commit -m "This is the version that is currently on the store"
Done.
Alternatives:
Create a copy of your Xcode project folder.
An Xcode archive is not good enough because you may need to revert back your code.

Issues Using GIT with Xcode projects

I know git and use it to manage a lot of my Repos on other projects. However I run into issues when it comes to xcode projects.
I start a project on Machine 'A' - when I push up to a repo and pull to let say machine 'B' I always receive compiling errors. Normally the errors have to do with files not being found. Literally "no such file or directory" followed by a path.
I'm working with the same version of Xcode on both mac's A and B. I also use the threetwenty framework.
When I zip the project up and send via email - the same results occur.
Many times these files that xcode can't find and that fail the build, are media files, like a image or video. Sometimes I see the three20 framework too.
My question is - how in xcode should I set a project up to play nice with git and or code sharing in general. Let me know if you need more information, I know the above is a little vague.
The first thing I always do is set up the .gitignore file before adding any other files from the project. Problems can occur when loading project settings for two different machines that may have the same User account name. You have to make sure some settings aren't added to the repo whilst others are.
I set up my .gitignore by adding the following:
.DS_Store
*/.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
Documentation/Generated
doxygenWarnings.txt
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
If you create the repos from scratch or run git rm --cached <filethatshouldbeignore> to each file that should be ignored and then commit, see if the problem still occurs.
Problems will occur in the .pbxproj file, so make sure all conflicts are corrected too.
Regarding files that cannot be found, remember to import the libraries etc. into the project folders and reference them from there. Apple's own iOS libraries should be fine, but others won't be. For example, in your project folder, copy your images from there and reference them only within the project folder.

Resources