Xcode suddenly can not get Swift package revision: "Couldn't get revision" - ios

I opened a project in Xcode that relies on RxSwift which is included as a Swift package through the builtin Swift package manager.
It worked fine a couple of week ago when I created the project.
Now all of a sudden, when trying to build and run my project, I get an error message about that Swift package:
Couldn’t get revision ‘6.5.0^{commit}’
I tried a clean of the build folder, but would still get the same error.
My internet connection is working fine, so it's not a network issue.
I am also surprised that Xcode would try to get the revision again since no update of the package in question, RxSwift was released between the time building last worked fine and today. So I would assume that whatever is cached locally should still be there and functional.
So far I could not find any other reports about this error message.

Apparently, something was wrong with the package cache.
An update of Xcode or a cleaning tool I run on my Mac which deletes some caches might have confused Xcode's package cache.
In Xcode, click File > Packages -> Reset Package Caches from the menu and then build again.
If that does not do it, first try to restart Xcode and then also try cleaning the build folder as well and try again.

For me deleting the .build directory in the project directory worked but that's more likely what Xcode actually does anyway with Reset Package Caches.

Related

Xcode 11.4 compile error 'Missing package product <package name>'

When I integrate a local package in my Xcode project everything is fine initially but when i switch branches and want to run the app Xcode gives me the compile error Missing package product <package name>. When I quit Xcode and re-open it everything is fine again. Any idea what this can be? An Xcode bug?
We also integrate external packages via Swift Package Manager which works perfectly fine. No issues there.
The issue is also well described in a post by Jesse Squires.
Solution 1: File > Swift Packages > Reset Package Caches
Solution 2: File > Swift Packages > Update to Latest Package Versions
For me, I needed File > Swift Packages > Reset Package Caches
In Xcode go to File > Swift Packages > Update to Latest Package Versions
Worked for me
In Xcode go to Product > Clean Build Folder
This worked for me. The problem originally started when I was trying to solve another issue that came up after I deleted my Derived Data folder.
Restarting Xcode didn't work, but cleaning the build folder did. I don't know if the other answers here would work for me because I didn't try them seeing as cleaning the build folder worked.
I bumped into this issue today on Xcode 13.0 when working on the WooCommerce iOS app after manually deleting the DerivedData folder.
The build was failing like in the questions description: Missing package product '<package name>'
I tried both resetting the packages cache and updating to the latest versions, but neither work. Thinking about it, that's not surprising since the packages Xcode couldn't find were local packages.
What did the trick for me was following this suggestion from an Apple forums thread and remove the local packages references, then adding them back again.
In WooCommerce's case, the local packages are part of a workspace file. Removing then adding them back again in the same order didn't result in a diff in the file. That is, nothing really changed in the workspace setup, but that was apparently the kind of kick Xcode needed to get over that error. 🤷‍♂️
I'm not sure of the root cause, but I get this quite regularly. Not the most elegant solution, but neither Reset Package Caches nor Update to Latest Package Versions worked for me. For me, I had to quit Xcode, and delete DerivedData.
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Then rebuild.
None of the answers worked for me on Xcode 12.5 beta. I had to manually remove all spm packages and re add them.
SPM - Reset Package Caches vs Update to Latest Package Versions
File -> Swift Packages -> Reset Package Caches
File -> Swift Packages -> Update to Latest Package Versions
Update to Latest Package Versions
fetch the latest possible version(based on restrictions)
Reset Package Caches
reset cache(derived folder) -> Update to Latest Package Versions
folder
<path_to_derived_data>/<randomizer>/SourcePackages/checkouts/<project_name>
//e.g
/Users/alex/Library/Developer/Xcode/DerivedData/SPM-dpsmlyjrashqjefkfheppizcrgic/SourcePackages/checkouts/SPMExperiments
[Local SPM]
I tried:
Clean project
Clean derived data
Resolve Package Versions (File > Package)
Update to Latest Package Versions (File > Package)
Restart Xcode
Restart Mac
And restarting the Mac is what worked 🥲
Others say doing "Resolve Package Versions" multiple times also work.
I got this error when having the same local Swift package open in two different instances of Xcode in two different projects. Got it working again by quitting Xcode and only having one project open at a time.
A workaround for me at the moment has been both running Product > Clean Build Folder (cmd-k) and then restarting Xcode. This is an issue in both Xcode 12.4 and 12.5, and 12.5's per user package caching did not resolve the issue.
File > Swift Packages > Reset Package Caches also appears to work but it is slower for me.
Context:
One of my vendors distributes their pre-compiled binary library via SPM. Whenever I switch between git development branches, I get:
"artifact of binary target 'xyz' failed extraction: The operation couldn’t be completed. (TSCBasic.StringError error 1.)"
It also causes these "missing package product" errors for totally unrelated packages presumably because if one package fails the whole SPM process fails ("resolving package graph failed") even if these package are entirely independent.
Edit: With Xcode 12.5 simply quitting Xcode and re-opening seems to be enough.
Start with the other answers like
Reset Package Caches
Product > Clean Build Folder
If this doesn't help...
In my messages I found a hint that I had a dependency to two different version of the same package.
After fixing this, Reset Package Caches suddenly worked for most of my packages.
I could fix the remaining problems by adding
platforms: [
.iOS(.v13),
],
to the corresponding package. Before that, I had no platforms statement.
Xcode Source Control should be enabled to run this.
Preference -> Source Control and enable the source control.
If none of the above answers work, Please refer the solution shared by GravityBytes in this link on Apple Forums.
Eventually he happened to share the below resolution
I eventually got this resolved. What seemed to get it working was re-adding my local packages using the "Add Packages…" menu option on the project that has the framework targets using the local package. This created a new "Packages" group in the project, and eventually started compiling correctly.
Please remove the existing references and try adding them using the above approach.
Just a silly question: did you set up your git account on Xcode preferences?
For Moya I had to edit project file to Xcode heart's content
/* XCRemoteSwiftPackageReference "Moya" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Moya/Moya";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 13.0.2;
};
anything other than 13.0.2 results in unresolutio for the numerous semicircular dependencies that Moya package brings to the table.
This breathes a new life into https://foldoc.org/field+circus
I had this issue after the current branch rename in the project and resolve it by clearing xcuserdata in workspace.
Nothing worked for me except Product -> Clean Build Folder and Restart
For me, Xcode was opened using Rosetta which wans't enabled before. Disabling Rosetta helped me 💪🏼
In Xcode 12.0.1 (12A7300) this bug has been fixed. It was auto-resolved by the Xcode update for me.
EDIT Xcode 12.5 [beta]
Apple added a SPM cache. See my question here. If you run into this problem with this Xcode version it might help to delete this cache.

Firebase Unity xCode linking errors

I am having issues trying to make a build from Unity (version 5.5.2f1) with Firebase Auth / Database imported. I am using the newest Firebase SDK of 3.0.0.
The errors I get are as follows:
I believe it has something to do with cocoaPods. The XCode project compiles with a podfile. And the errors I believe are related to missing libraries? But all the required libraries are set to iOS, and are included with the XCode project.
Unsure of what to try next. Thanks in advance to anyone able to help.
When you build and run from within unity, it tries to run the pod installation for the dependencies needed, and patches the xcode project file (not workspace).
If there is an error with this process, you should see it in the console.
Normally pods are meant to be used with the workspace file, but since unity automatically opens the xcode project the plugin tries to make it work.
Try opening the .xcodeproj instead of the workspace.
So I finally figured out my issue. I had a previous build that worked all the way through to my device. So I eventually tried opening that one again, and I ran into the same errors with an older build.
So that got me thinking.. Why would a previous build that used to work fail this time around?
I came to the conclusion that the only things that changed were possibly me updated Unity to 5.5.2f1. So I updated again to the latest release at this time which is 5.5.2p3, and ran through the same steps:
1) Build to iOS
2) Install pods in the target folder
3) Run xc workspace
And it successfully built. So it must of been something on Unity's side. If anyone ever runs into a similar situation, hopefully this will help.
P.S. I also did update to the latest release (at this time) of Unity Firebase SDK of 3.0.1. Not sure if that had anything to do with making a successful build, but wanted to put that information out there.

Too many semantic issues. Xcode 8.2.1

I was working on a project before in Xcode 7, it perfectly compiled and ran. When I copied the entire project onto a fresh installed macOS and tried to compile in Xcode 8.2.1 I get these errors. I tried all these links listed below, none of them helped. Is there a fix to this?
Tried Solutions:
Thread 1
Thread 2
Errors:
I was working on a project before in Xcode 7, it perfectly compiled and ran. When I copied the entire project onto a fresh installed macOS and tried to compile in Xcode 8.2.1 I get these errors.
It appears that your project has external dependencies that you haven't accounted for. It's hard to say what those are without a look at the project, but the header files that Xcode is complaining about (e.g. L2SDKIPCamViewer.h, DGActivityIndicatorView.h, etc.) should provide some clues. Check the original machine to see whether it has a package manager like CocoaPods installed, and if so, which packages are installed. The project's dependencies should be documented in a README file somewhere near the top of the project's file hierarchy, but if the project was developed by you or someone in your organization, or if the developer was just too busy to bother, that might not be the case and you'll have to find and fix the dependencies one at a time.

Build operation failed without specifying any errors for React Native Xcode project

I have a React Native project that works fine most of the time(Android and iOS). But sometimes out of nowhere I receive this error when I am trying to build the Xcode project (Xcode or react-native run-ios):
Build operation failed without specifying any errors.
Individual build tasks may have failed for unknown reasons.
One possible cause is if there are too many (possibly zombie)
processes; in this case, rebooting may fix the problem.
Some individual build task failures (up to 12) may be listed below.
How do I solve this? Push to a branch on git, fresh clone, npm install, and all is working fine for a period. And after that the problem will repeat. Making fresh clones of project each time is a pain and takes long time. Is there another way or something that I don't know?
Maybe a some files that are in .gitignore is causing the problems, and after a fresh clone that solves the problem. This is the .gitignore file for my iOS project:
# Created by .ignore support plugin (hsz.mobi)
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
I had this same issue and it was fixed by deleting the contents of node_modules and doing a npm install in the parent folder.
I was faced with this problem too. And I noticed that my folder name was too long. I changed the project folder's name with the short one and this error gone. Try to change the project folder name.
It was really a time killer issue. I rebased the complete code base to a collegue's mac where it worked fine. After sparing more than a couple of morning hours I could find a solution.
Solution - Simply shorten your Project folder name (in mac).
This is undoubtedly irritating that its suggested to have longer and meaningful variable names but the folder name has to be this concise.
I had a issue with XCode 9.1 and iOS 11...
I solved this issue moving up my folder to another path, I know it doesn't make sense and is dumb but it really work for me. My project was at /Users/Me/Documents/MyProjectDir and I changed to /Users/Me/Desktop/MyProjectDir
What helped me was removing the ios/build folder in my React Native project, followed by rebuilding the project.
I highly recommend to run the build on console, to see if it outputs any other relevant information.
react-native run-ios --scheme "app-debug" # Or any aproppriate target
Read more about building+archiving from CLI here or try with other OSS tooling like fastlane.
For me it found bugs twice, that both were unrelated with the building process itself:
1) One was fixed rolling back to node v8 (LTS) apparently. It was very obscure, but I suspect had to do with having little memory available (running flow + packager + xcode + spotify + chrome on 8GB RAM MBP)
2) The other one was related to having a space on the xcode output. "App Canary.app" could not be installed. I figured it out doing ls ios/build/Build/products.... This error only happened after upgrading xcode, and wasn't happening with the release target, that did not have any whitespaces.
The only take away here is to run build directly on the console to debug further. You might find out things that are completely unrelated, and probably can't be solved by just removing the build folder.
Hope it helps.
Trashing ios/Build resolved this issue for me
In my case simulator is not shutdown correctly.
So I opened simulator manually again then I got an error that simulator is not shutdown correctly.So I relaunched the simulator successfully and built xcode project again. Error is resolved

Why do I need to clean the xcode project everytime I build the project?

I have an iOS app written in Swift. Whenever I run the project, it gives Shell Script Invocation Errors:
When I clean the project, the subsequent build performs ok. But again, if I build the project next time, it again gives the same error.
Cleaning and rebuilding the project takes a lot of time. Is there some way around it?
It's difficult to know exactly what is causing this issue as it could be a number of things, So the question is quite broad.
Few things to try...
Check your build phases in the project and look for anything that might not be expected
Try checking out your project (if using version control) in another location such as your Documents folder to make sure there isn't a permissions issue.
Try cleaning the build folder using alt, cmd, shift + k.
If your still having issues after that try providing additonal information.
What version of xcode are you using?
Are you using any xcode plugins?
Are you using any package management solutions? carthage? pods?
Have you tried to build your project on another computer?
Are you using the latest version of the command line tools?

Resources