Alamofire 4.0, Swift 3 AFError.Swift - 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.

Related

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

Framework not found FBLPromises (Swift Package Manager)

I've seen this problem listed elsewhere, but it always seems to be linked to a Cocoapods installation of Firebase. My problem is the opposite - trying to upgrade from pods to SPM has given me this problem when I try to compile:
ld: framework not found FBLPromises
I'm currently running Xcode 13.3 on a Mac Mini with an M1 chip, but the problem was present in earlier versions of Xcode.
Previously I had Disk (https://github.com/saoudrizwan/Disk) installed via SPM and Firebase/Messaging and Twilio (5.5.1) installed via Cocoapods. I ran pod clean and pod deintegrate, deleted all the Pod files etc and have installed Twilio and Firebase Messaging using SPM. This gives me the following Package Dependencies (and you can see that Promises 2.0.0 has been added successfully):
The top result I get when I look into this is FBLPromises Framework not found, and the second answer suggests adding arm64 as an excluded architecture, but doing that gives me further problems (warning and error below), and I'd rather not exclude an architecture blindly and then go down a rabbithole of trying to fix that when it might not be the solution to my original problem.
Warning and error when I try to exclude arm64 architecture:
None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s) which is not in EXCLUDED_ARCHS (arm64).
error: Build input file cannot be found: '/Users/myName/Library/Developer/Xcode/DerivedData/project-exchrqebmyccatebeoxupvxpdsul/Build/Products/Debug-iphoneos/project.app/project' (in target 'project' from project 'project')
I've not checked to make sure I've not introduced other errors further down the line, but I think the problem was caused by Linker Flags being retained in the build settings.
I went to the Target -> Build Settings -> Linking and deleted everything under 'Other Linker Flags' (OTHER_LDFLAGS is how this is reflected in the project.pbxproj file according to my git diff).
File now compiles and runs successfully, if I find some subtle bugs later that might be caused by this I shall edit this answer accordingly!

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

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.

Swift Version 5, SwiftyJSON

Build system information
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'SwiftyJSON')
how can I deal with it?
SwiftyJSON v4.3.0 supports Swift 5. Check your Podfile to make sure you’re getting the latest release. You may need to update your Pods (with pod update) to make sure you’ve got the latest versions.
Also, you might consider retiring SwiftyJSON and using JSONEncoder/JSONDecoder instead. See Encoding and Decoding Custom Types or the Using JSON with Custom Types sample for more information.
If, on the other hand, you are not using Swift 5 yet, just configure your Podfile indicate that you want to use SwiftyJSON v4.2.0. E.g.
target 'MyApp' do
pod 'SwiftyJSON', '~> 4.2'
end
Either change the build target of your project to Swift 4.x or wait until the project gets support for Swift 5 (you can check that on the GitHub page)
I get this error too when i tried to pod lint or push.
error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2.
I have to stay on xcode 10.1 ans use cocoapods 1.5.3, but on a fresh install (new mac) I received the same error.
Here is my solution:
After comparing my 'gem list' with an other mac, I found that the gem xcodeproj was very high (1.12.0).
So, I installed a lower version required by cocoapods (1.5.3)
"sudo gem install xcodeproj -v 1.5.7"
and remove the never
"sudo gem uninstall xcodeproj -v 1.12.0"
Wrongs fine now, I cant lint and push my pods.

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.