# Xcode 15 Beta + Cycle inside \<Target\>; building could produce unreliable results

**URL:** <https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906>\
**Category:** Using Swift\
**Tags:** xcode, packagemanager\
**Created:** [June 30, 2023, 3:57am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906 "2023-06-30T03:57:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![swhitty](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/swhitty/32/10082_2.png) [@swhitty](https://forums.swift.org/u/swhitty)\
**Post date:** [June 30, 2023, 3:57am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/1 "2023-06-30T03:57:55Z")

</div>

Feedback raised: `FB12477645` — Reporting here for visibility of others.

I maintain a project that was failing to build in Xcode 15 beta 1/2. It failed with error:

`Cycle inside <Target>; building could produce unreliable results.`

I narrowed it down and reproduced in a new project with these 2 steps:

1. Add blank build script phase with input files: `$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)`

2. Add a binary SPM package like [twilio-video-ios](https://github.com/twilio/twilio-video-ios) or [medallia](https://github.com/medallia/digital-ios-sdk)

Either of the steps on their own is OK, but when both are applied the build error occurs.

---

<div class="post-metadata">

**Author:** ![aurora14](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aurora14/32/5593_2.png) [@aurora14](https://forums.swift.org/u/aurora14)\
**Post date:** [July 7, 2023, 1:14am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/2 "2023-07-07T01:14:40Z")

</div>

For what it's worth, it's still happening in Beta 3. We have two production apps that aren't building because of this :(

---

<div class="post-metadata">

**Author:** ![azarovalex](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/azarovalex/32/9141_2.png) [@azarovalex](https://forums.swift.org/u/azarovalex)\
**Post date:** [July 12, 2023, 8:50am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/3 "2023-07-12T08:50:16Z")

</div>

The issue is still present in beta 4.  
I was using a build phase to inject values in Info.plist during the build and in Xcode 15 betas this results in a "cycle".

The workaround I came up with is using Info.plist preprocessor prefix file.  
Instead of modifying Info.plist directly in the build phase, it now adds values to the prefix header

```swift
echo "#define KEY VALUE" > "${BUILT_PRODUCTS_DIR}/My-Info.plist-Prefix.pch"

```

And set `$(BUILT_PRODUCTS_DIR)/My-Info.plist-Prefix.pch` as an output file of the build phase.

Then, enable `Preprocess Info.plist File` build setting and set prefix file to the same path as in the build phase.  
If everything is done correctly, Xcode will replace stubs in Info.plist with values from the prefix file.

This isn't a perfect solution, but at least it unblocks builds on Xcode 15.

---

<div class="post-metadata">

**Author:** ![jonathanim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jonathanim/32/30771_2.png) [@jonathanim](https://forums.swift.org/u/jonathanim)\
**Post date:** [July 14, 2023, 10:07am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/4 "2023-07-14T10:07:09Z")

</div>

@azarovalex Thanks for replying. I encountered the same issue. Could you give a more specified clarification for each step? Thanks very much. 😃

---

<div class="post-metadata">

**Author:** ![azarovalex](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/azarovalex/32/9141_2.png) [@azarovalex](https://forums.swift.org/u/azarovalex)\
**Post date:** [July 14, 2023, 1:09pm UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/5 "2023-07-14T13:09:46Z")

</div>

Sure thing, @jonathanim.  
Let's say you had a build phase that injected some dynamic value `INJECTED_VALUE` to Info.plist with a key `PLIST_KEY`. This is my use case that stopped working in Xcode 15 betas, and here is what I did as a workaround:

First, add this key to Info.plist with a mocked value that later will be replaced, let's say

```swift
<key>PLIST_KEY</key>
<string>MOCKED_VALUE</string>

```

Then change the build phase that previously modified the Info.plist to generate a .pch file:

```swift
echo "#define MOCKED_VALUE INJECTED_VALUE" > "${BUILT_PRODUCTS_DIR}/My-Info.plist-Prefix.pch"

```

Add `$(BUILT_PRODUCTS_DIR)/My-Info.plist-Prefix.pch` as an output file of the build phase.

Lastly, enable the "Preprocess Info.plist File" build setting in your target and set "Info.plist Preprocessor Prefix File" to the same prefix file `$(BUILT_PRODUCTS_DIR)/Dash-Info.plist-Prefix.pch`.

After following these steps Xcode will now substitute the value in your Info.plist with runtime generated values that the build phase is writing in the prefix header. Hope that solves your problem.

---

<div class="post-metadata">

**Author:** ![HiddenJester](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hiddenjester/32/30777_2.png) [@HiddenJester](https://forums.swift.org/u/HiddenJester)\
**Post date:** [July 14, 2023, 9:36pm UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/6 "2023-07-14T21:36:38Z")

</div>

Oh my goodness. This is a lifesaver post, I didn't know we _could_ use precompiled headers in Info.plist and this worked a treat! Thank you!

---

<div class="post-metadata">

**Author:** ![aurora14](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aurora14/32/5593_2.png) [@aurora14](https://forums.swift.org/u/aurora14)\
**Post date:** [July 25, 2023, 11:38pm UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/7 "2023-07-25T23:38:34Z")

</div>

This is still present in the Beta 5, - however for those with Crashlytics in their project, this might help:

> <https://github.com/firebase/firebase-ios-sdk/issues/11471#issuecomment-1621884706>
>
> \### Description
> 
> When I use Xcode 15 beta1 and beta2 to build my product, Xcode …show up an error message:
> \`\`\`
> 
> Showing All Messages
> Cycle inside SaleAppDev; building could produce unreliable results.
> Cycle details:
> → Target 'SaleAppDev': ExtractAppIntentsMetadata
> ○ That command depends on command in Target 'SaleAppDev': script phase “Run Firebase Crashlytics Framework”
> ○ Target 'SaleAppDev' has a command with output '/Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app.dSYM'
> ○ Target 'SaleAppDev' has process command with output '/Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Info.plist'
> ○ Target 'SaleAppDev' has copy command from '/Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/SourcePackages/artifacts/aws-sdk-ios-spm/AWSCore/AWSCore.xcframework/ios-arm64\_i386\_x86\_64-simulator/AWSCore.framework' to '/Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Frameworks/AWSCore.framework'
> 
> 
> Raw dependency cycle trace:
> 
> target: -\>
> 
> node: \<all\> -\>
> 
> command: \<all\> -\>
> 
> node: /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Intermediates.noindex/SaleApp.build/Debug-iphonesimulator/SaleAppDev.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata -\>
> 
> command: P0:target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-:Debug:ExtractAppIntentsMetadata -\>
> 
> node: \<target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--package-copy-files-phase\> -\>
> 
> command: P0:::Gate target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--package-copy-files-phase -\>
> 
> CYCLE POINT -\>
> 
> node: \<target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--fused-phase3-copy-files\> -\>
> 
> command: P0:::Gate target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--fused-phase3-copy-files -\>
> 
> node: \<target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--fused-phase2-run-firebase-crashlytics-framework\> -\>
> 
> command: P0:::Gate target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--fused-phase2-run-firebase-crashlytics-framework -\>
> 
> node: \<execute-shell-script-9158ce05fb5c3595d8f47cfea6cad70818949a790f5e1b8e3c3cfd1c5335f867-target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-\> -\>
> 
> command: P2:target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-:Debug:PhaseScriptExecution Run Firebase Crashlytics Framework /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Intermediates.noindex/SaleApp.build/Debug-iphonesimulator/SaleAppDev.build/Script-3AE1F9A71AA6D7E600F7C8E5.sh -\>
> 
> node: /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app.dSYM/Contents/Resources/DWARF/SaleAppDev -\>
> 
> command: P0:target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-:Debug:GenerateDSYMFile /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app.dSYM /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/SaleAppDev -\>
> 
> node: /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Info.plist -\>
> 
> command: P0:target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-:Debug:ProcessInfoPlistFile /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Info.plist /\*project path\*/SaleAppDev-Info.plist -\>
> 
> node: /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Frameworks/AWSCore.framework -\>
> 
> command: P0:target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad-:Debug:Copy /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/Build/Products/Debug-iphonesimulator/SaleAppDev.app/Frameworks/AWSCore.framework /Users/galvin/Library/Developer/Xcode/DerivedData/SaleApp-bflooukvzshbnyftcyfhikcrvfzk/SourcePackages/artifacts/aws-sdk-ios-spm/AWSCore/AWSCore.xcframework/ios-arm64\_i386\_x86\_64-simulator/AWSCore.framework -\>
> 
> node: \<target-SaleAppDev-9158ce05fb5c3595d8f47cfea6cad708268edd9a57a401552e80349710d5b9ad--fused-phase3-copy-files\>
> 
> 
> \`\`\`
> 
> This error only show up in some specific situations. My app contains some SPM libraries:
> a. firebase (https://github.com/firebase/firebase-ios-sdk, 10.10.0, with Crashlytics upload script)
> b. aws ios sdk (https://github.com/aws-amplify/aws-sdk-ios-spm, 2.33.0)
> c. cardio (https://github.com/verygoodsecurity/CardIOSDK-iOS.git, 5.5.7)
> d. some other library, not important 
> 
> For Xcode 14:
> a+b+c+d: build success ✅
> 
> For Xcode 15 beta1 and beta2:
> a+b+c+d: build failed, cycle inside error ❌
> a+c+d: build failed, cycle inside error ❌
> a+b+d: build failed, cycle inside error ❌
> a+d: build success ✅
> b+c+d: build success ✅
> a+b+c+d, but remove the \`${DWARF\_DSYM\_FOLDER\_PATH}/${DWARF\_DSYM\_FILE\_NAME}/Contents/Resources/DWARF/${TARGET\_NAME}\` for Crashlytics upload script in \`Input Files\`: build success ✅
> 
> Looks like there is a conflict with the input files of Crashlytics upload script and some xcframework library.
> 
> \### Reproducing the issue
> 
> \_No response\_
> 
> \### Firebase SDK Version
> 
> 10.10.0
> 
> \### Xcode Version
> 
> 15.0 beta.2
> 
> \### Installation Method
> 
> Swift Package Manager
> 
> \### Firebase Product(s)
> 
> Crashlytics
> 
> \### Targeted Platforms
> 
> iOS
> 
> \### Relevant Log Output
> 
> \_No response\_
> 
> \### If using Swift Package Manager, the project's Package.resolved
> 
> 
> 
> \<details\>
> \<summary\>Expand \<code\>Package.resolved\</code\> snippet\</summary\>
> \<br\>
> 
> \`\`\`json
> 
> {
> "identity" : "firebase-ios-sdk",
> "kind" : "remoteSourceControl",
> "location" : "https://github.com/firebase/firebase-ios-sdk",
> "state" : {
> "revision" : "5034479ca0c4f32f299677fb0ba1fe4d3e3e20b4",
> "version" : "10.10.0"
> }
> }
> 
> \`\`\`
> 
> \</details\>
> 
> 
> \### If using CocoaPods, the project's Podfile.lock
> 
> 
> 
> \<details\>
> \<summary\>Expand \<code\>Podfile.lock\</code\> snippet\</summary\>
> \<br\>
> 
> \`\`\`yml
> 
> Replace this line with the contents of your Podfile.lock!
> 
> \`\`\`
> 
> \</details\>

> <https://github.com/5calls/ios/pull/330/files>
>
> When building with Xcode 17 there is a error caused by a build cycle being detec…ted.
> 
> Turns out this is an issue with the Crashlytics script and fixed with the suggestion here: https://github.com/firebase/firebase-ios-sdk/issues/11471

This worked to make builds compile successfully for me, - **might be worth checking to make sure it doesn't have any ill side effects for the Crashlytics functionality though**

---

<div class="post-metadata">

**Author:** ![jonathanim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jonathanim/32/30771_2.png) [@jonathanim](https://forums.swift.org/u/jonathanim)\
**Post date:** [July 26, 2023, 2:55am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/8 "2023-07-26T02:55:42Z")

</div>

Not sure if it helps in your situation. I fixed this problem by following the answers in this post [Cycle inside my app on XCode 15 be… | Apple Developer Forums](https://developer.apple.com/forums/thread/731287?login=true)

Check comments of [Akira\_Hayakawa\_Atsurae](https://developer.apple.com/forums/profile/Akira_Hayakawa_Atsurae).

```swift
In my case, the following solved the problem. I paid attention again to the order of the Build Phase. When I was checking the Build Phase, I found that the "Embed Foundation Extensions" (Widget Extension) related to WatchApp were last in the order. (RunScript was also executed in the middle). I noticed this and solved the problem by rearranging the order of Embed Foundation Extensions to be right after Copy Bundle Resources. 

```

---

<div class="post-metadata">

**Author:** ![jaleel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jaleel/32/45076_2.png) [@jaleel](https://forums.swift.org/u/jaleel)\
**Post date:** [July 26, 2023, 8:07am UTC](https://forums.swift.org/t/xcode-15-beta-cycle-inside-target-building-could-produce-unreliable-results/65906/9 "2023-07-26T08:07:07Z")

</div>

Oh, thx, this helped in my case!
