Illegal Instruction 4 error while running the unit tests on Xcode - swift

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.

Related

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!

Module compiled with Swift 3.0.1 cannot be imported in Swift 3.0 on BuddyBuild

I use BuddyBuild for a swift project with Xcode 8.0 and with Carthage 0.18.
Although, in logs I can see that all frameworks are cloning, checking out and building, I receive this one:
module compiled with Swift 3.0.1 cannot be imported in Swift 3.0: /tmp/sandbox/workspace/Carthage/Build/iOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule
This is the entry in Cartfile for Realm:
github "realm/realm-cocoa"
Locally, everything builds, but with other configurations:
Xcode 8.1 and Carthage 0.18
This Module compiled with swift 3.0 cannot be imported in Swift 3.0.1 did not help me much, because of BuddyBuild.
EDIT
I can see that in logs:
Downloading realm-cocoa.framework binary at "v2.1.0"
after that, no building for realm.
Buddybuild typically run the carthage command with --no-build to make sure you don't experience with kind of error.
Note that buddybuild won't run the carthage command if you check in your Carthage/ folder.
You can find more information about how buddybuild deals with Carthage in our documentation.

Module compiled with swift 3.0 cannot be imported in Swift 3.0.1

I upgraded Xcode to 8.1 GM and am now getting the below error for SwiftyJSON. Other imported frameworks seem to work. Is there a way to force this to work in Swift 3 until SwiftyJSON upgrades their framework? I used Carthage to import/update frameworks. I also tried changing Use Legacy Swift language version On and Off to no avail.
Module compiled with Swift 3.0 cannot be imported in Swift 3.0.1:
Modules/SwiftyJSON.swiftmodule/arm64.swiftmodule
SwiftyJson is being downloaded precompiled by carthage. The precompiled download is with Swift Version 3.0. That makes the compiler complain that the version is not correct. Using the following command:
carthage update --platform iOS --no-use-binaries
SwiftyJson (and all other frameworks within Carthage) will be compiled locally using the local version of Swift (3.0.1) and the compiler will not complain anymore.
Remove the app chache from DerivedData, and rebuild. the error may be fixed.
The DerivedData path like this:
~/Library/Developer/Xcode/DerivedData/
Make sure you've placed the new XCode 8.1 GM package in your Applications folder. We ran into this issue when one of us was running Carthage to update our dependencies, but had not replaced the XCode old 8.0 application in the applications folder (8.1 GM was running off the Desktop).
You want to make sure that when you run the following in terminal: xcrun swift -version that it returns Apple Swift version 3.0.1.
Updating default Xcode to new one on terminal worked for me.
Step 1 : Use following command to update Xcode version to latest on Terminal. Ref
sudo xcode-select -switch <path/to/>Xcode.app
Step 2 : Now try carthage update command
carthage update --platform iOS
Just to give the latest updates:
Carthage has released version 0.20 on Feb 27, 2017.
Carthage now only uses the pre-build binary if available pre-build binary is compatible.
That is being said, you no longer have to use: --no-use-binaries to avoid incompatible pre-build framework.
So make sure that you have carthage version greater than 0.20 and simply do:
carthage update --platform iOS
Just like #zirinisp said:
You can Using the following command:carthage update --platform iOS --no-use-binaries
Using the following command:xcrun swift -version to see the Swift version
Do this: Xcode->preferences->locations to clear the derived data and archives data, the most important to change the command line tools to "Xcode 8.1"
Using the following command:xcrun swift -version,you can see the swift version is 3.0.1
Set Use Legacy Swift Language Version = NO
I hope it will help you
Move the beta/GM version if the Xcode to /Applications folder and name it Xcode-beta
Check the output of:
xcrun swift --version
by running this command in terminal, its output should match with the swift version you want the app to compile, because Carthage uses output of this command, to determine the local Swift version.
Update Xcode version to latest on Terminal by running following command:
sudo xcode-select -s /Applications/Xcode-beta.app/
Build the libraries for iOS and prevents Carthage from downloading existing (yet incompatible) precompiled binaries, by running following command:
carthage update --platform iOS --no-use-binaries
Clean & Build
I had exactly the same issue with the library XCTest_Gherkin, what it worked for me was:
Product -> Scheme -> XCTest-Gherkin
Product -> Build
Hope it helps. I am using Cocoapods.
In Xcode Build Settings make sure your Framework Search Paths contain the appropriate Carthage Build folder:
$(inherited)
$(PROJECT_DIR)/Carthage/Build/iOS

Bluemix Swift Mobile Client Access SDK when imported says no such module BMS Core and BMS Analytics show 35 errors due to which my build fails

As per the instructions given on Bluemix site; I installed the Swift SDK
pod use_frameworks!
pod 'BMSSecurity'
and it shows this on my terminal:
Then, when I built the project, I got 36 build errors.
First of which is "no such module as BMSCore" when I can see that framework imported in the pod and 35 errors related to BMSAnalytics, which is again framework imported.
These build errors are due to the incompatibility between two of the BMSSecurity dependencies (BMSCore and BMSAnalyticsAPI) and the version of Xcode you are using (7.2.1). The latest versions of these 2 frameworks only support Xcode 7.3 and higher, as explained in the BMSCore Github README. If you want to continue using Xcode 7.2, you can use BMSCore 1.0.3 instead.
So, there are 2 possible solutions here:
Upgrade Xcode to version 7.3
Add the following line to your Podfile: pod 'BMSCore', '~> 1.0.3'
Option 1 is recommended since only Xcode 7.3+ will be supported in future releases of BMSSecurity.
Are you opening FoodTracker.xcworkspace ?? please open .xcworkspace after pod install..

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.