Need to re-install libraries before every build (Carthage) - swift

My team and I are working on a Swift project (Swift 5 - XCode 11), and decided to use Carthage as our dependency manager to handle libraries such as SwiftyJSON, SDWebImage and MapBox. We have done the setup as specified on Carthage's GitHub: created a Cartfile, downloaded the libraries, dragged the files onto the "Frameworks, Libraries & Embedded content" part of XCode, added a Build stage as Carthage requests it...
My problem is: after almost every successful build, when I try to run the application, the build fails because one of the packages is not recognised: the message says: "Swift compiler error. No such module 'SwiftyJSON'" (or any of the other libraries).
To sort out this problem temporarily, I re-download again all packages by running:
$ carthage update --platform ios
The problem is that I need to re-do this update every time I build my application, otherwise it fails. None of my other three teammates are facing this issue.
Would be really helpful if someone knew the source of this problem, I have tried almost everything!
Thank you!

Related

Swift Package Manager gets stuck indefinitely upon adding new package [duplicate]

After updating Xcode to version 13.2 i can't build my project anymore. I have a strange error "Internal error: missingPackageDescriptionModule" related to my Workspace file.
It's definitely related to SPM because Xcode is not loading SPM packages also. I tried to "Reset package caches", "Resolve package caches" and also "Updating to latest package caches" but after all of these operating nothing happens. Deleting derived data, cleaning didn't help too...
I tried also to resolve packages from Terminal using xcodebuild -resolvePackageDependencies but I get error message:
--- xcodebuild: WARNING: The directory /Users/ptocicki/Developer/KFC/kfc-ios also contains the legacy project 'project.pbxproj' - ignoring it and using 'KFC.xcodeproj'.
xcodebuild: error: Could not resolve package dependencies:
Internal error: missingPackageDescriptionModule"
Apple is aware of the issue.
We're currently investigating this issue — thank you to those who have
filed bug reports so far. To workaround this issue, please re-download
Xcode 13.2 directly from the Downloads page.
https://developer.apple.com/forums/thread/696504?answerId=698142022#698142022
🎊 Fixed on v13.2.1 and you can download from here
Explaination
This bug is reported and the v13.2.1 AppStore version but As  Apple suggest here, you should download the Xcode manually from the developer center
Manual download of any Apple developer software
✅ The always working and preferred workaround!
Download directly from Apple:
Latest Release version or
Latest Beta version or
Any version you need and all other downloadable contents
Then extract and move it where you like. This has so many benefits compared to AppStore updates. (like the ability to resume download, not replacing the old one, not wasting hidden directories and etc.)
Note that you should use safari to download it.
⚠️ Important note for developers like me!
The page you’re looking for can’t be found.
If you The page you’re looking for can’t be found message, you may need to use a VPN if you are in a country that the US sanctioned like mine. Because Apple is blocking some IP address ranges.
If you’re using Swift packages either standalone or as dependencies in an Xcode project or workspace, the Mac App Store version of Xcode fails during package resolution with the error “Internal error: missingPackageDescriptionModule.” (86435800)
Workaround: Download Xcode 13.2 directly from the Apple Developer website.
I just got the issues late at night after Xcode updated on its own while I was working on my project, which was not a cool surprise. It appears to be affecting all dependencies. You are not alone in this it's affecting everyone. I did what they recommended and downloaded Xcode directly from the Apples developer site and it fixed all my issues super happy right now!!!!!!!
XCode was updated to 13.2.1 at 12/19 which fix the issue.
https://developer.apple.com/documentation/xcode-release-notes/xcode-13_2-release-notes
If you’re using Swift packages either standalone or as dependencies in an Xcode project or workspace, the Mac App Store version of Xcode fails during package resolution with the error “Internal error: missingPackageDescriptionModule.” (86435800)
Workaround: Download Xcode 13.2 directly from the Apple Developer website.
Seems local package still working. So there is a temporary solution: We can download the dependencies then add them to the project as local paclages.
Please update to Xcode 13.2.1.
If not, download Xcode 13.2 from the Apple Developer website.
Updating from Xcode 13.2 to 13.2.1 from App Store fixed the issue for me.

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

Building project for M1 Mac fails because of architectures it believes are missing

We have a project that uses many AWS libraries. On first attempting to build it, using carthage, it downloaded binaries and it did not build at all. So we ran carthage --no-use-binaries and it built the libs.
Then this error occurs:
LoginService.swift:9:8: Module 'AWSMobileClient' was created for incompatible target arm64-apple-ios9.0: ..Carthage/Build/iOS/AWSMobileClient.framework/Modules/AWSMobileClient.swiftmodule/arm64.swiftmodule
Based on this stack overflow thread, we add arm64 to excluded architectures for the simulator.
Which makes all the aws code compile (yay) but then, this error occurs trying to use a framework that is coming in via the Swift Package Manager:
[].swift:10:8: Could not find module 'Parma' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator
So it wants the x86 version of this lib, and cannot find it.
The app does run on the phone now. But not the simulator of course. Not sure if there is a way to figure out which architectures are built by SPM? or control it. I did reset the SPM cache after excluding the arm64 arch.
I think the best solution for getting this working on M1 is to use XC-Frameworks.
carthage update --use-xcframeworks
This will only build the valid archs you need. If you have any dependencies that don't support XCFrameworks yet you'll have to run lipo to remove x86 simulator targets in your build phase.
Hey I've come across the issue. Just open your old project by Rosetta and build it. Then uncheck open by Rosetta and build it. It helped me to open old project on m1

Cocos2d-x project's 2nd rebuild onwards gives an error 'Xcode cannor run using selected device'

Fresh cocos2d-x project build using Xcode runs normally on iOS simulator/device, but after making changes to cpp source files, rebuild fails with error-
Xcode cannor run using selected device. Choose a destination with a supported architecture in order to run on this device.
The only way to make it work is delete build binaries (i.e. delete XCode>Derived Data folder), and take fresh build after restarting Xcode.
Can someone please help me resolve this issue?
Additional Details:
This error is related to mismatching device architecture and armv6 armv7 flags. But first build works fine, and stops working after second build onwards, that means this is not a possible issue.
If the project is not using cocos2d-x (i.e. plain Objective-C project), then there is no such error after second build.
Compiler selected: Apple LLVM Compiler 4.2
Thanks in advance!
Following my comment you should make sure you use the latest templates for creating cocos2d projects. Some templates will only work for a specific Xcode version so make sure you use the right templates for your xcode version (There are some for xcode 3.x and others for xcode 4.x)
Change Valid architecture to armv7 and armv7s. Remove armv6. See image for more information.

Xcode warning: application executable contains unsupported architecture(s):arm, arm (-19031)

I've been receiving this warning since I loaded my project in last Xcode 4 preview. There was no warning before that but now I can't get rid of it even in Xcode 3.2. I've been googling but nobody seems to have the same error.
My project and target settings are correct (IMHO): Architectures: Standard (armv6 armv7), Base SDK: Latest iOS (currently set to iOS 4.2), Build Active Architecture Only: FALSE, Valid Architectures: armv6 armv7.
I compared every project setting with other projects and and found no differences. I even have recreated the project starting from scratch and copying classes, resources and frameworks with the same result.
I must say that the warning is not shown when I set Debug configuration.
I hope someone can help me because I don't know what to do. Thanks in advice.
I kept getting this error and it was driving me crazy. Then I realized I was building the project for Simulator instead of Device. Once I made the change, I was able to upload the app without a problem.
Several things spring to mind. Firstly that there is some file lurking around in the build directory. But I presume you have deleted the build directory. Secondly, that there is something lurking in your library directories. I think xcode puts some tempt files down in them now. Thirdly that something has gone funny is the core xcode setup.
So here's what I would try (the emphasis here is "try" - I don't know if any of this will work :-)
Make sure you have deleted the build directory.
Do a full un-installation of code. Clear out any developer directories and then re-install.
SOLVED!. Not a good solution though.
After a thousand tests I uninstalled Xcode 3.2.5 and installed 3.2.4. Everything went ok since then. Now I'm afraid of upgrade to last version again. :/