XCode 12.5 won't allow me to add Swift packages. Package resolution failed. <folder> exists and is not an empty directory (-4) - swift

What do I need to do to resolve this?
I can't add Swift packages to my project without XCode 12.5 complaining about a folder that didn't exist there prior to adding the package using Swift packages -> Add package dependancy.
I've tried
Reinstalling XCode
Deleting DerivedData
Clean Build folder
Reset package caches
Resolve package versions
Update to latest package versions
The image below shows ViewInspector failing, but that seems stochastic. The error occurs when fetching SwiftUI-Introspect every other time as well. This hints at a race condition somewhere. It doesn't matter which package I try to add, The folder in deriveddata will be created and XCode will complain and abort.

Related

Xcode: Using packages in Xcode 14

I have several Swift packages in my project.
Works fine with Xcode 13.4.1.
Using Xcode 14 beta 1, all packages fail to build because of an error referencing to one of my packages:
Showing All Messages
Cannot clone from local directory /Users/...
Please git init or use "path:" for Location(scratchDirectory...
I tried:
in Xcode: removing the reference to the package and adding it again
in Xcode: removing the reference, moving the directory to a different place, create a fresh package in Xcode, move the old files into the new package directory
The usual Clean Build Folder and Reset Package Caches
creating the imported package under a new name and import the new one
The packages are part of the project (when creating: ... add to project and directory in the project)
There is a change in the syntax for local packages, the .package(url: … syntax that used to work for packages within the project does not work anymore.
With Xcode 14 local packages that do no have their own repo MUST be referred as:
dependencies: [
.package(path: "../MyLibrary"),
]
Now this works just fine in Xcode 14 beta, but if you're going back to the Xcode release version, you'll get numerous errors. To fix those, reset the package caches by calling
File > Packages > Reset Package Caches
I had the same issue in a project with 14 internal packages, some of them dependent on each other, and it runs fine now in both Xcode 13.4 and Xcode 14 beta.
Hope it helps

Error in resolving package dependency swiftUI project

Dependencies could not be resolved because root depends on 'googleappmeasurement' 9.0.0.
'googleappmeasurement' 9.0.0 cannot be used because 'googleappmeasurement' 9.0.0 depends on 'nanopb' 2.30908.0..<2.30909.0 and root depends on 'nanopb' 2.30909.0..<2.30910.0.
that is my error message, can anyone help?
I am using SDK version 8.9.1 and everything working fine, If you executed the Resolve Package Versions and still not working. you can try the command Reset Package Caches from Project navigator scroll down right click on Package Dependencies then choose the command. that will clear all caches for all installed packages then re-install them again. if that not working i suggest you to use version 8.9.1 till Firebase fix the issue.
I have discovered the problem has been answered here. It occurs when importing Firebase using Swift Package Manager and setting to track "master" instead of a specific release version.
Got same error and solved, check attached image, this most likely packages usage misconfiguration, as follows:
1-perhaps you are working on a branch with different Xcode version than the other developer who installed the package.
2-Perhaps some package is conflicted being used twice, by so some dependencies are duplicated.
Well to solve this you gotta try either to match the Xcode version used while installing the packages, or to remove the package that makes errors(like Firebase here), and try adding that package again your side.

Xcode 13.3 Build Failed because of Cycle in Dependencies between targets libsignal-protocol-swift

After updating to Xcode 13.3 facing Build failed issues with libsignal-protocol-swift library.
This is happening while building second time while after cleaning and building for first time it is working fine. Also, Xcode 13.2.1 has no such errors.
Xcode Error as below :
Cycle inside libsignal-protocol-swift iOS; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle details:
→ Target 'libsignal-protocol-swift iOS' has link command with output '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/SignalProtocol'
○ Target 'libsignal-protocol-swift iOS' has compile command for Swift source files
○ Target 'libsignal-protocol-swift iOS' has copy command from '/Users/ankitkhanna/Documents/Project-Files/Desk-Factors-Project-Files/BlueChats-IOS-master/libsignal-protocol-swift-master/libsignal-protocol-swift/SignalProtocol.h' to '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/Headers/SignalProtocol.h'
After struggling for sometime the solution was actually the same as mentioned in Xcode suggestions.
i.e. to Move the Headers in project Target -> Build Phases on top Compiled sources.
Drag and move Headers above Compile Sources fixed the error.
Please see the image for reference.
I've faced the same issue after updating to Xcode 13.3; however, in my case, I didn't have Headers in Build Phases.
I've followed these steps to solve it:
Precondition: Xcode must be closed.
Delete the DerivedData folder:
rm -rf ~/Library/Developer/Xcode/DerivedData
In the Terminal, type the following command:
defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

Alamofire 4.0, Swift 3 AFError.Swift

Background:
I am relatively new to programming and am updating my current iOS project which uses Alamofire & Swift 3. The project was working fine until I updated to Alamofire ~4.0 which presented me with 530 errors.
I'm opening up the xcworkspaceproject in Xcode8.1
I tried clearing up the problem using the suggestions in this StackOverflow Thread: Alamofire XCode8 Swift 3 results in 786 Compile Errors
including:
gem install cocoapods --pre
and also downgrading the cocoapod version cocoapods-1.2.0.beta.1 from the current beta version down to cocoapods-1.1.1
I also: 1. Deleted the podfile 2. created a new podfile 3. reinstalled all the pods 4.) Clean & Build
Unfortunately none of these worked.
Displayed Errors:
Type 'AFError' does not conform to protocol 'RawRepresentable'
Most of the other of the 530 errors are:
Definition conflicts with previous value
All the errors are contained within the AFError.Swift file (which is locked by default). Thanks for any solution to help in fixing this.
a. Try installing your pods using a stable version after a deintegration:
`pod deintegrate && pod _1.1.1_ install`
b. Try purging DerivedData cache: close Xcode (fully close, like with cmd+q), delete the DerivedData folder, empty the trash. And only re-open Xcode after that last step, to correctly re-build the cache.

Carthage + Quick framework + Swift 2 = "error: module file was created by an older version of the compiler; rebuild 'Quick' and try again"

I'm using Xcode 7 beta 5 (it's the only xcode currently installed) with Swift 2 and when I try to run unit tests with Quick, I get the following error:
error: module file was created by an older version of the compiler; rebuild 'Quick' and try again
I'm using Carthage (0.8.0) to manage my dependencies. My Cartfile.private has:
github "Quick/Quick" ~> 0.5.0
github "Quick/Nimble" "v2.0.0-rc.2"
As far as I know, these are the Swift 2 versions of these libraries. I have the libraries linked and when I try to run the unit tests, I get the noted error.
There's a similar question here but that doesn't seem like my problem
Realm: Module was created by an older version of compiler and could not build objective-c module
I've cleaned out my DerivedData and Carthage/Build folders and still no luck.
How can I run unit tests with Swift 2 and Quick?
It may be related to the following kind of problem if you updated from another beta version : https://github.com/neonichu/xcode-install/issues/48
xcode-install uses ditto to install Xcode, which merges files from the source into existing directories at the destination path.
If a new (beta) version of Xcode doesn't contain files which were present in the previous version, the old files will still be there after installing the update.
Try uninstalling and reinstalling Xcode.