how to resolve this cycle in dependencies swift - xcode

Does anyone know how I could resolve this cycle in dependencies? I've been stuck on this problem for 3 days. I tried build cleans, clearing derived data, rebuilding pods, even doing git reverts are not helping.
error: Cycle in dependencies between targets 'Pods-Trust' and 'PromiseKit';
building could produce unreliable results.
Cycle path: Pods-Trust → PromiseKit → Pods-Trust
Cycle details:
→ Target 'Pods-Trust' has target dependency on Target 'PromiseKit'
→ Target 'PromiseKit' has link command with output '/Users/User/Library/Developer/Xcode/DerivedData/Payd-ampguiegvrhgtrfmpddfkkwgmpnf/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/PromiseKit.build/Objects-normal/x86_64/PromiseKit'
○ Target 'PromiseKit' has a command with output '/Users/User/Library/Developer/Xcode/DerivedData/Payd-ampguiegvrhgtrfmpddfkkwgmpnf/Build/Products/Release-iphonesimulator/PromiseKit/PromiseKit.framework/PromiseKit'

Had similar thing few times - try to delete derived data + clean project + pod install ... at least it worked for me

Related

Xcode 13.4.1 - 14.1 : Cycle inside "--"; building could produce unreliable results

After making a GitHub repo and adding my code to my account my code now throws me an error, previous resolutions to the error include changing the sequence of the build phases in Xcode but I seem to have no luck, I also don't have a header phase in my build phases which rules out the older method, error below.
Showing Recent Messages
Prepare build
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
error: Cycle inside Target.swift; building could produce unreliable results.
Cycle details:
→ Target 'Target': CodeSign /Users/macbook/Desktop/target/Build/Products/Debug-iphonesimulator/target.app
Raw dependency cycle trace:
target: ->
node: ->
command: ->
CYCLE POINT ->
node: /Users/name/Desktop/Target/Build/Products/Debug-iphonesimulator/Target.app/_CodeSignature ->
Build failed 4/10/22, 10:12 PM 0.7 seconds

Xcode 10, sourcery & swiftlint build phases order

After updating to Xcode 10 there are some issues with initial project configurations. The steps look like this:
Generating some files using Sourcery
Linting with SwiftLint
Build
And configuration works like this:
And this was working fine in Xcode 9, but apparently, it's not working under Xcode 10 build system. The issue is if I download repository (.generated files are not a part of the repository). And hit build it will show me results like:
...
Using configuration file at '.sourcery.yml'
Scanning sources...
Found 239 types.
Loading templates...
Loaded 9 templates.
Generating code...
Finished.
Processing time 0.491948962211609 seconds
...
So sourcery works ok, then linting:
Linting 'FromResponse.generated.swift' (1/186)
Works fine as well as a process, but in the end, build will fail with:
error: Build input files cannot be found:
'/path/Generated/FromResponse.generated.swift',
...
So it's strange since a files are physically there and according to build settings file should be compiled later than generating them. How should I approach sourcery in build process then?
We are able to "fix" this in a similar way as this Github issue:
https://github.com/mac-cain13/R.swift/issues/438#issuecomment-416982928
We have to add each of the generated files by Sourcery to the output folder and it will get picked up by the Xcode correctly.
This relates to changes in the New Xcode Build System that has been enabled by default in Xcode 10. If a build phase creates files which are needed as an input to a later build phase then it needs to specify them explicitly in the Output Files or Output File List.
In your example the Sourcery build phase is generating Swift source file(s) which are needed as input to the Compile Sources phase.
However, the issue at this point is that after you specify the output files for Sourcery, the build phase doesn't re-run every time as it sees the output file is already there. So far I haven't worked out a useable solution to this part, beyond running tools like Sourcery and SwiftGen manually or keeping the generated files in Git so that they are always present.
I was having a similar problem with a buildphase calling mogenerator to build my data model classes. The approach given by #Yuchen should work.
#Andrew: To force always (re-)running this build phase, I add the line
touch .alwaysRun
as the last line in the shell command to run and mark the build phase "Input Files" to have $(SRCROOT)/.alwaysRun. That seems to do the trick.

Moving files between build chain builds

What is the set up required to move files between builds in TC? I am needing to move both modified source files and build binaries between the build configurations of a build chain.
I have 1 project with 4 builds. The builds are
Update Version Number (This build updates 15 sources files)
Compile (This build compiles a dozen objects)
Test (This build runs a regression test)
Create Package (This build creates a setup.exe file)
Information about the TC setup and chain
I am using perforce as my VCS.
All 4 builds use the same VCS root.
On all 4 builds under version control settings I have "Clean all files before build" set to "On".
"Update Version Number" build is triggered by any check in to the VCS. (This works)
I have been able to successfully chain and trigger the builds. However each build starts with a fresh copy of files from the VCS.
The chaining is set up to use snapshot dependency.
Based off of the TC documentation it looks like I should be using snapshot dependency and not artifact dependency. If I put the build steps of all the builds into the same build everything works. However we are looking to have more flexibly and expand on this build chain in the future.
I tried setting up the configuration so only the first build is attached to the VCS root and the other builds don't have any VCS root. This didn't work.
I have been unable to find the answer googling but I have been able to find someone else who is struggling with this problem. Sadly they didn't receive an answer.
After speaking with TC customer support I learned the correct technique is to use both artifact dependency with "build from the same chain" selected and snapshot dependency.

MBProgressHud Swift Compile Error when Archiving

I already finished my project, it works and runs perfectly on the simulator or in my own device. When I select to Archive the project to upload de build to Itunes Connect, I get all these compile errors
"Use of undeclared type MBProgressHUD"
"Use of unresolved identifier MPProgressHUD"
And so on..
NOTE: I'm using CocoaPods for this library
What solved it for me was adding import MBProgressHUD in the classes where I use this library, not only in the Bridge-Header.h
Navigate to your project build settings and find the “Swift Compiler – Code Generation” section (You may find it faster to type in “Swift Compiler” into the search box to narrow down the results)
Next to “Objective-C Bridging Header” you will need to add the name/path of your header file. If your file resides in your project’s root folder simply put the name of the header file there. Examples: “ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.
Refer this link http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/
Welcome to Cocoapods Hell (a.k.a. : where the magic ends), where one must dive into his project build settings and make sense of what went wrong...
It's very hard to answer to you, as any number of reasons might be causing that.
Do you use the same target for Build / Run & Archive ? It might be because your libPods.a isn't copied into your Archive target
Have you installed Pods using pod install , have you tried playing that command again. (yes, faced with magic going wrong, one can sometimes rely on magic to save him again)
'Build' and 'Archive' product often differ in the build configuration they use (Build most of the time uses 'debug' configuration, while Archive uses 'release' configuration... ). Check your Pods configuration files (debug/release) and make sure they both include your MBProgressHud. Also, in your Project 'Info', check which pods Xcode configuration files are selected for 'debug' and 'release'
Good luck !
(PS : as MBProgressHud is a single file, and one you can often change, another solution is to get rid of Cocoapods and just copy/paste it)

Getting error “ReactiveCocoa/ReactiveCocoa.h” file not found

I'm developing an app using Xcode 6 and cocoa pods.
But it is showing an lexical or preprocessor issue:
“ReactiveCocoa/ReactiveCocoa.h” file not found.
I installed cocoa pods and also updated it. Anyone please suggest how to solve this issue.
I had a lot of trouble installing RAC my first time around, and here's what I usually go through if I'm getting CocoaPods errors :
1 : Check if the Build Active Architecture Only option is set to NO for debug builds. Go to the Pods project in your workspace, make sure Pods is selected and not one of the targets on the inner left side panel, and then search for Build Active Architecture Only and set it to NO. Try rebuilding/cleaning again after.
2 : Make sure you're passing in -all_load to Other linker flags in your target build settings. (Select project > Go to your target > Search forOther linker flags> Add-all_load`
If you want to use Yusef Napora's version of ReactiveCocoa 2 in a swift project :
-BridgingHeader.h set in build settings and containing the import to < ReactiveCocoa/ReactiveCocoa.h >
Linked Frameworks and Libraries: + libReactiveCocoa-iOS.a
Library Search Paths : + < yourPath >/ReactiveCocoaFramework/build/Debug-iphoneos
Header Search Paths : + $(BUILT_PRODUCTS_DIR)/../../include
Compile. :)

Resources