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

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.

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

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.

Illegal Instruction 4 error while running the unit tests on Xcode

I recently updated to Xcode 12.3 and did the workaround to run the carthage dependencies. The build is fine but when I run the tests, I get the Illegal Instruction 4 error. I assume that the arm architecture issue causes that issue. I use Quick and Nimble coming from carthage and these are used in testing. I have tried setting the excluding archs and validate archs to yes but none of them worked.
I cannot move the libraries from carthage to pods or spm because there are so many configurations in the libraries. Updating to a new Xcode version is such a pain especially if you are using carthage.
UPDATE:
I downloaded the carthage version of 0.37 and implemented the xcframeworks into the project. To run the dependencies for xcframeworks, I run the following command:
carthage bootstrap --use-xcframeworks --no-use-binaries --platform ios
If you can use Carthage 0.37.0 and are able to use XCFrameworks, then this answer might be valuable for you 👍 In this vesion they added support for XCFrameworks and I find it quite nice to use. Especially since this popular workaround can finally be removed again.

Swift 3.1.1 compile error: unknown key 'SwiftImportAsNonGeneric'

Some time after upgrading to Xcode 9, I discovered that I was no longer able to build a Kitura-based project with the Swift 3.1.1 snapshot (which I have installed via swiftenv).
When I ran swift build, some time into the build I would get:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes:8:28: error: unknown key 'SwiftImportAsNonGeneric'
SwiftImportAsNonGeneric: true
^
<unknown>:0: error: could not build Objective-C module 'Foundation'
It seems that there is a dependency between Swift and Xcode, and Xcode 9 is no longer fully compatible with Swift 3.1.1 (or earlier) snapshots. I believe it may be because my project uses Foundation, and Foundation on Mac is provided as part of Xcode, whereas on Linux it is part of the Swift snapshot (via swift-corelibs-foundation).
I did find a solution to this problem: If I keep a copy of Xcode 8.3.3 around (eg. in /Applications/Xcode8.3.3.app) then I can use sudo xcode-select -s /Applications/Xcode<version>.app/Contents/Developer to select the appropriate one prior to building with SPM, and I can then build both Swift 3.1.1 and 4.0 projects on the same system.
However, this feels a bit clunky. Each time I build a project with the 'other' Swift version, I have to make sure I run xcode-select, or the build will fail. Is having multiple versions of Xcode the right solution in this case, or am I missing a trick with Xcode 9?
note that if, like me, you upgraded Xcode via the App Store, previous versions of Xcode are still available from https://developer.apple.com/download/more/

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.