Build errors in Keychain.swift when compiling in XCode, iOS development - swift

Xcode version is 7.3.1
OSX 10.11.6
This link accurately describes the issues I'm having
https://github.com/marketplacer/keychain-swift/issues/37
Errors I'm getting make it clear that my system just isn't recognizing the Keychain.Swift file.
The above link suggests the file is in Swift 3.0, and I double checked that I am running Swift 2.2.
So I tried to install the older version of Keychain.Swift via cocoapods and it seems to update in my system, but I'm still experiencing the same build errors.
I placed "pod 'KeychainSwift', '~> 3.0'" inside the pod file in Xcode and ran "install pod" from terminal inside the project directory.
I tried shutting down Xcode and reopening, I tried running Product-> clean, but nothing seems to work.
The project is a work file that was pulled from github and seems to work on the original authors environment, but I have yet to successfully get my environment to work.
I appreciate any advice and suggestions. I am new to swift, cocoapods, and iOS development.

As i can see the current version of Keychain.Swift you are using is in Swift 3.0
It is giving you error of Date class which is introduced in Swift
3.0
Date Class Documentation Unfortunately Which is supported in ios 10+
Please follow the below steps to remove the previous version and switch to older version:
Remove this line "pod 'KeychainSwift', '~> 3.0'" from your pod and run install pod this will remove the current KeychainSwift pod.
Now add this line pod 'KeychainSwift', git: "https://github.com/marketplacer/keychain-swift.git", branch: "swift_2_3" Reference taken form this link this will install Swift 2.3 version of the file.
Enjoy Coading.

Turns out there are multiple libraries for utilizing the keychain. There is one called KeychainAccess and another one called Keychain-swift. One utilizes "import KeychainAccess" and the other "import KeychainSwift". I simply had the version for swift 3.0 when I'm using 2.2 (which we knew from the start, but still couldn't get it to work). The advice given by Harshal Bhavsar is accurate, but only if you are using "KeychainSwift". Otherwise, you want to roll back to an older version of "KeychainAccess" found here https://github.com/kishikawakatsumi/KeychainAccess/releases.

Related

Xcode 13.2 - Adding package hangs on "Preparing to validate"

I have recently updated to Xcode 13.2 from the Mac App Store. While trying to fix an issue with a Swift package, I uninstalled it and now I cannot reinstall the package.
When I try to add a package from GitHub the process hangs immediately on "Preparing to validate".
I already attempted to restart Xcode, restart my mac, clean derived data, reset Swift package caches and update package versions to no avail.
Is there any way around this issue?
Check https://developer.apple.com/forums/thread/696504 and re-download Xcode 13.2 directly from the releases section of the Apple Developer website: https://developer.apple.com/download/release/
Make sure to update Xcode to 13.2.1
They have just released the update that should fix it. See in the link that #mikeyh posted in the other answer: https://developer.apple.com/forums/thread/696504.
I'm on Xcode 13.4.1 and ran into this same problem when trying to convert my project from CocoaPods to SPM packages because I was using the Legacy Build Location setting. When trying to install any package it would immediately hang on "Preparing to validate..." just like in the screenshot of the question.
I did get an error stating something like the package could not be added because of using the Legacy Build Location setting, however I did not notice this in the Issue Navigator for a while because once I removed all of my CocoaPods and before I could add the SPM packages I was getting hundreds of build errors.
To fix (if your project can use the default Build Location setting) is to set it by going to
File->Project Settings...->Advanced...->Xcode Default

Unsuppored Swift Version Xcode 10.2.1

I open an existing project it contains many errors, this image explains more the issue:
I execute "pod install" but it doesn't solve the problem.
Change Swift Language Version to Swift 4 or higher, found in build settings.
move to the build setting of the project and change the project to swift4 and also move to the pods and every pod you have to change the Swift language version that is Swift 4enter image description here
The message describes all the things itself. You can not convert 3.x swift version into the latest one by using Xcode 10.2.1. You need to open this project in Xcode 10.1 first then convert it into the 4.x swift version.
Later you can open it in 10.2.1 version.
pod install will just install the pods with locked version of each library, of course it will not solve the issue.

Swift class extensions and categories on Swift classes are not allowed to have +load methods

I have updated Xcode Version 10.2 (10E125) and testing on devices (not only simulator)
I get this message when I execute the app:
objc[3297]: Swift class extensions and categories on Swift classes are not allowed to have +load methods
It's just not working on devices with iOS 12.2. I would like to know if there was any update that was affecting the swift classes. So far no answer about this in other forums just saw that apple has some issues with other apps in production as well.
-I'm using extensions of swift classes but I don't think that is the problem
Using Cocoapods and Firebase dependencies.
I searched in my project any functions that could contain "load" functions, none found.
Please some help
Just to add a solution for React Native projects.
This issue occurred because one of our custom react native modules was using the
RCT_EXPORT_MODULE() macro which calls the init function and we were also including swift code. Since react-native version 0.59.3, there's a new macro RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) which avoids the call to init. Replacing RCT_EXPORT_MODULE() with RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) and updating to react native version 0.59.3 fixed the issue.
In my case the only one dependency that has +load method is RxAtomic. Which, by the way, is the only one that didn't update to the current moment to swift 5.0. So I suppose this bug caused by RxSwift. And I also have Swinjects dependencies, but updated all to the newest releases that support swift 5 - it didn't help.
EDIT
I just open Pods project file. Select RxAtomic Target. And change User-Defined property 'SWIFT_VERSION' from 5.0 to 4.2. And it works!!!
At the moment the quick fix:
Download the previous version of Xcode 10.1
Once you've done that, rebuild your project and it works just fine on any device.
I think the problem is related to Swift 5. What we would probably need to do is update all the dependencies to Swift 5. At the moment I don't have the time to do so.
The long fix: Is update your pods and slowly migrate toward swift5.
The pod that was giving more problems was: Swinject with SwinjectStoryboard, and RxOptional.
upgrade to react-native version ^0.59.5
solved it without RCT_EXPORT_MODULE_NO_LOAD,
to update react-native version,
rm -rf node_modules
yarn add react-native#^0.59.5
so this will update other dependancies packages with the new version
I had the same problem and all I did was to update pods. Swinject pod was causing problem and after update to the latest version everything was solved.
You may also try to adjust Swift language version in Pods Targets.
• Downgrading to Xcode 10.0 solved the issue in my case. You can download it at More Downloads for Apple Developers

Xcode not displaying compile errors

I'm working in a specific Xcode project and deliberatly making errors in my code (like using undeclared variables), but Xcode doesnt seem to show any compile errors in my code.
It shows errors only when its build or clean.
Tried clean and build, cleaning derived data and restarted both Xcode and system, none of it works.
Using Xcode 8.2.1 (8C1002) and Swift 3
Besides the DerivedData folder, also try cleaning Xcode caches completely:
rm -rf $HOME/Library/Caches/com.apple.dt.Xcode/
I would recommend also killing the SourceKit process — always a source of issues these days! — but since you are already did a full reboot, so looks like you are good there.
If everything fails, you might consider upgrading to the latest Xcode, version 8.3. Just be aware that:
Xcode 8.3 no longer supports Swift 2.3. Please migrate your projects containing Swift 2.3 code to Swift 3 syntax by opening the project and choosing Edit > Convert > To Current Swift Syntax.
Project Settings, "Show all issues" fixed it for me.
For me, I had to first ensure all of my Xcode Targets had valid Signing & Capabilities like a development Team selected... then I was able to update all of my Targets to Swift 5 using the warning that was presented to me. Immediately after all of the targets were all updated to Swift 5 and the Provisioning was fixed, the red errors were flagged again!
I had the same problem using Xcode 13.3 with Swift version 5.5
Upgrading to Xcode version 14.1 (14B47b) which also upgrades Swift tools to version 5.7.1 fixed the problem.

Cocoapods - Module Compiled with Swift 3.0 cannot be imported in Swift 3.0.1

Just updated to Xcode v8.1 and am trying to install a pod. However, once I import it, Xcode gives me an error saying Module Compiled with Swift 3.0 cannot be imported in Swift 3.0.1 and then a path to the module.
I have tried saying Use Legacy Swift Language Version however this does not solve the issue.
Any other ideas of what I can change to make this compile? I have a hard time believing a minor version change should cause this much trouble.
Thanks in advance for any help.
This happens almost every update. Try pod update in the terminal where the pods are located to get all your pods to the latest versions.
Just clean your project.
Select: Product -> Clean