My app does not find sirikit intentdefinition classes in xcode 11.4 - ios

My app has had support for a couple of siri shortcuts since it came out, haven't touched it in a long time. My project compiles and builds in 11.3.2 but doesn't in 11.4.
The errors i get is that the classes that are supposed to be generated from my intentdefinition file, and that i am referencing in my intenthandlers are no longer found.
For example, in my intentdefinition file i have a custom intent called "MyStatus".
I then have a MyStatusIntentHandler:
#import "MyStatusIntent.h"
#interface MyStatusIntentHandler<MyStatusIntentHandling> : NSObject
In 11.4, i get an "MyStatusIntent.h" file not found. In 11.3.1 and earlier it builds fine.
I am not super great at project config and structure, so i'm a bit at a loss as to where to start digging. If anyone has any pointers, and what in 11.4 that might be new and giving me problems, I'm all ears.

I've had a similar problem in mixed swift+objc project.
There is a file 'Intents.intentdefinition' in my project for a separate Siri Extentsion target.
Also, this file is included in the compilation of the application target (for using generated classes in adding intents with UI).
Siri Extenstion target builds successfully.
But Application build fails with error: "'AnyIntent.h' not found", though those files were generated (I've checked).
I solved this issue only by changing the build setting of the Siri Extension target
Intent Class Generation Language (INTENTS_CODEGEN_LANGUAGE)
from Automatic to Swift
All imports of the previously generated intents header files I changed to
#import <SiriIntents-Swift.h>

I have this problem too.
After updated XCode get build failed with "error: use of unresolved identifier" for classes from *.intentdefinition file.
with terminal build I had this message:
2020-03-26 17:11:21.874 xcodebuild[28391:166707] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEIntentBuilder/IDEIntentBuilder-16029/IntentsBuildSystem/XCCompilerSpecificationIntents.m:46
Details: Code generator extension identifier unexpectedly nil for <DVTDeclaredPrimitiveFileDataType:0x7f888398b950:49:'com.apple.sirikit.intentdefinition':'Intent Definition':-*-*-------**-----*--*----*----------------------*-------------->
Object: <XCCompilerSpecificationIntents: 0x7f88838a4540>
Method: -createCommandsforInputs:withMacroExpansionScope:
Thread: <NSThread: 0x7f8892390940>{number = 13, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
now I downgrade Xcode and add feedback to the https://feedbackassistant.apple.com/feedback/7640678

I have dug around, and also talked to Apple Support. Turns out, it has to do with the "legacy build system".
Once i switched to the new build system in xcode project settings, i could build the project again. I would argue that if they still support the legacy system (which they do), it should work, but oh well.
Read how to switch here:
https://help.apple.com/xcode/mac/current/#/dev396bc94c7

Stumbled upon this problem on XCode 12.4 while trying to add a ConfigurationIntent for an iOS 14 widget, and in my case the problem wasn't that the code generator was erroring out. Turned out it actually worked just fine, but the names of the classes it created were prefixed with an "Objective-C Class Prefix", (because of some Obj-C legacy project setting, or whatever) and the boilerplate code generated by XCode which referred to it was oblivious to that step and kept looking for a ConfigurationIntent class that was nowhere to be found. Changing INTENTS_CODEGEN_LANGUAGE didn't help with this either.
Anyway, in the end I had to delve into:
DerivedData/<ProjectName>/Build/Intermediates.noindex/<ProjectName>.build/Debug-iphoneos/<TargetName>/DerivedSources/IntentDefinitionGenerated/Intents
which is where I found my intent class file, and its actual name in the form of <ObjCPrefix>ConfigurationIntent. I replaced the references to ConfigurationIntent with this, and the errors finally disappeared.

Related

'Executable path is a directory' Xcode popup error

I have an iOS Xcode project with 3 targets - AppTarget, Lib1 and Lib2.
Hierarchy:
AppTarget is dependent on Lib1 and Lib2. It has no code (SceneDelegate, AppDelegate etc. is moved to Lib1).
Lib1 is a static library containing the AppDelegate and SceneDelegate (Lets not get into why they were moved here from the AppTarget).
Lib2 is a static library, dependent on Lib1. It extends the SceneDelegate class using swift extensions.
In order to get the above structure, I had to add, remove file references and set dependencies.
When I run the AppTarget, I get the following popup after build succeeds,
Pasting the above error as a text,
Details
Executable Path is a Directory
Domain: DVTMachOErrorDomain
Code: 5
Recovery Suggestion: /Users/<user_name>/Library/Developer/Xcode/DerivedData/<project_name>-bnytgzvocmpwyuajjxxjivpkymui/Build/Products/Debug-iphonesimulator/<project_name>.app is not a valid path to an executable file.
User Info: {
DVTErrorCreationDateKey = "2022-11-03 08:04:49 +0000";
}
I'm not sure why this happened. I didn't mess with the default executable path in Xcode->Preferences->Location tab.
There's an Apple forum post which describes a similar error (not the same).
The solution was to check for references of old files, which are not present now. I have verified the Target->Build Phases->Compile Sources of all 3 targets and things are as expected....Didn't see any 'faint files'.
What am I missing here? Any help will be greatly appreciated.
I'm using Xcode 14.0.1 and swift 5+.
One of the reasons for this can be if there are no sources in the app target. If there is no code, the executable does not get generated as expected. See if adding a dummy/sample source code works i.e. Just a swift file with an empty class should also do the trick.
What worked for me:
Delete app from simulator
Delete DerivedData folder -> ~/Xcode/DerivedData
Quit Xcode
Restart computer
Launch Xcode, clean project (command + k), clean build folder (shift+command+k)
From there I was able to run my app target successfully ✅
Exclude the arm64 arch when building for the Simulator. The reason is the Simulator is using X86 based architecture. When building for a real device, like an iPhone, you must remove the Architecture exclusion. The iPhone is using arm based arch.
See the snapshot here

command libtool failed with a nonzero exit code [duplicate]

When I try to build my app with Xcode, an error interrupts the build process:
Command CompileStoryboard failed with a nonzero exit code
Sometimes, it shows this error instead:
Command CompileSwift failed with a nonzero exit code
I have New Build System turned on.
What can I do to fix this?
Closing Xcode for me didn't have an effect. Instead, I cleaned the project using CommandShiftK.
I also found another reason: I had a storyboard reference to another storyboard which I had removed. The quick fix was deleting this.
I also facing same issue in xcode 10 and tried all the solutions provided but nothing working.
Then I deleted all the files and folders of the following folder :
~/Library/Developer/Xcode/DerivedData
and it worked like a charm.
When you stop building a project when the compiler is in the middle of something "important", this error could appear. In that case, building the project again and letting it finish normally makes this error disappear.
This is a known issue with Swift 4.2 and Xcode 10. I found an article here that fixed it for me: https://github.com/Yummypets/YPImagePicker/issues/236
In short, go to your projects build settings, and add a user defined setting named SWIFT_ENABLE_BATCH_MODE and set its value to NO.
Previously, I tried each of the methods suggested here (rebuild, exit Xcode, clean and rebuild, purge Derived Data files). None of them worked.
Once I added the user define build setting per the article, Swift then told me the true error. In my case, it was a missing }, but it could be any number of problems.
I encountered this error when I was upgrading my project from Swift 4 to 5.
I first updated all my pods to their latest versions. When I built, some pods showed this error.
The following steps resolved this issue for me:
Removed all pods from Podfile
Executed pod install to remove all installed pods
Executed pod deintegrate to remove support for CocoaPods
Deleted Podfile.lock and .xcworkspace from my project so no
CocoaPods anymore
Now my project is a pure Xcode project
Opened my project from the regular .xcodeproj file
Changed Swift Version of my project to Swift 5
Cleaned the project (cmd+shift+K)
Quitted Xcode
Restored all pods to my Podfile
Executed pod install to reintegrate CocoaPods and add my pods
Opened the project from the .xcworkspace file
Cleaned and rebuilt
Some old pods that were still using Swift 4.0
(SlideMenuControllerSwift in my case) were set to Swift 5.0, caused
many build errors in their code. I corrected it back to Swift 4.0
by opening the Pods project and selecting its target.
Cleaned again, rebuilt.
Now I have only errors in my own project code related with difference in Swift version I made. My job now is to fix them.
This error happened to me when I forgot to change entity Properties before creating NSManagedObject subclass. Solved by:
delete Entity+CoreDataClass.swift and Entity+CoreDataProperties.swift.
under "class" of the entity model inspector, change "module" to Current Product Module and "codegen" to Manual/None.
recreate the NSManagedObject.
I had the error Command LinkStoryboards failed with a nonzero exit code, and found that I was using a reference to a non-existent storyboard. I had recently changed the name of a storyboard file, so changing the reference from the 'old' name to the 'new' name solved it for me.
You may not have exactly the same error as me, but an easy way to find a more detailed explanation of the error is to:
Show the issue navigator (while the build time error is showing)
Click the error:
Then, you should see more about your error:
I hope this helps. Please, I am aware that I am answering from experience of a different error than this question was asked about, but I believe this advice should help you conquer similar problems!
For me cleaning the project (Command + Shift + K) and restarting xCode worked for me
If you have multiple targets, where two or more targets have files with the same name, check the target membership of those files in Files inspector. The error occurs when multiple instances of the equally named file have set the target membership for the same target.
Since this issue looks to have dozens of possible solutions and the root cause could be very vague, I'll throw my situation into the ring. Half of my pods were failing with some sort of CompileSwiftSource failure, but only on archive. I was still able to build for device and simulator just fine. I tried a lot (if not all) of the solutions suggested here with no luck. One of the pods had a slightly different error before the CompileSwiftSource error so I went to updating and trying to fix that single pod. It was the Cache library for iOS which hadn't been updated in a while. There was a fork that resolved the issue with updating to Xcode 10.2 that I was able to update to and after that, all of the other issues took care of themselves. So look for a single outlier in your pods if you're getting a bunch of them erroring out and start there.
Switching to the legacy build system fixed the issue for me
In my case, I was clean build folder then restart my mac then it's work.
I had the JSONwebtoken pod installed and that was causing issues. I needed to delete the CommonCrypto folder that is in the JSONWebtoken pod folder. Here is a ->link<- explaining the issue. This started happening in Xcode 10.
In my case it was about having a file named Location. after some digging I find out that it was about having two file with the same name (weird). Cause I don't, however, it's been solved by removing the file and adding another file with a different name.
filenames are used to distinguish private declarations with the same name
This can also occur when you have two swift files with the same name. For example, two ContentView.swift files
In my case, I used too complicated initializations inside a class extension. It suddenly broke my build.
class MyClass { }
extension MyClass {
static var var1 = "", var2 = "", var3 = "", var4 = "", ...., var20 = ""
}
Resolved:
class MyClass { }
extension MyClass {
static var var1 = "",
static var var2 = "",
static var var3 = ""
static var var4 = "", ....,
static var var20 = ""
}
In my case it was empty assets catalog, when I delete it everything was fine again.
Command CompileSwift failed with a nonzero exit code
This error happens when you are migrating your code from Xcode 9 to Xcode 10+. It due to any class name is conflicting with existing apple classes. For Example: State, Event etc.
So first change the class/structure name if any existing in your code like "State" to "StateDetail"
If Info.plist is added in target, remove tick mark from it so it will not copy app bundle (Latest Xcode10 security reason).
Select Info.plist file and uncheck under "Target Membership" in right side Identity inspector
And build code again!!!
In my case, the problem was that I assigned a .swift class to the viewController in the storyboard, while the project was Objective C.
I tried a lot of the options discussed here.
Delete and reinstall pods
Clean Build Folder
Delete Derived Data
Add SWIFT_ENABLE_BATCH_MODE and set its value to NO
Restarting Xcode and Recompiling
Restarting iMac and Recompiling
set Compilation Mode to Incremental
Changed build settings: SWIFT_COMPILATION_MODE = singlefile and SWIFT_OPTIMIZATION_LEVEL = "-O"
Nothing worked. I'm using Xcode Version 11.0 beta (11M336w).
Finally I downloaded a fresh copy and replaced the one I had previously installed. It was the same exact version. That did the trick.
I got this error while trying to run my unit tests in a submodule. What I have done is:
Change the simulator => Clean the project => Build the project => Run unit tests.
After this, my unit tests ran without any issue.
I have the issue like that and my solution is change a little thing in Build Settings:
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OPTIMIZATION_LEVEL = "-O";
it work to me
Alright, I was having the same problem with Xcode 10. I usually use a storyboard for every view, that way if someone is helping it's easier to fold code in. I needed to make one of the view on one storyboard the initial view Controller.
In my case it was renaming a file to an existing file in other folder(Group) by mistake, just rename it to what it was then the error disappeared
The targets should be specified with related data such as appicon
For me the problem was that on my Podfile I didn't put use_frameworks!. I just uncomment that line, run pod install on the terminal again. And it got fixed.
It was commented since the app was entirely made on Objective-C. Since the app now uses Swift I had to make that change on the Podfile
I had the same error Restarting Xcode and Recompiling Fixed the issue for me.
I got the same error when linking separate storyboards. The error, "Command CompileSwiftSources failed with a nonzero exit code." is shown because I simply forgot to set the view controller inside the second storyboard that I am linking as 'an initial view controller'.
In my use case I had used the function "Refactor to Storyboard" in Xcode 13. It created the new refactored story board fine but failed to add it to bundle resources.
So my fix was to:
Select the target project in Xcode Navigator
Choose the build phases tab
Expand Copy Bundled Resources to see if new storyboard was added. If not, just add it to the list and rebuild.
My app was having Notification Service Extension, and was using Xcode 11. The Extension doesn't have anything to do with pods.
After 1-2 years, I have taken that project into my new m1 chip mac with Xcode 13. But the compilation was failing and showing me the error in pods.
I tried to remove and add all pods, tried clean etc all possible available answers available on internet. Almost spent 4-5 hours to make it run, but nothing worked.
Final Solution that worked:
I removed, notification service extension from the project, its target etc too. And then tried to run the app. Amazingly it worked. After that, i added that extension again(by creating new extension and putting the same code again), and everything is working perfectly fine.
I am still surprised that, was that issue with extension or with pods. But finally it worked for me.
Hopefully, this answer might resolve someone's issue and you can save enough time.

Build error Xcode 10 - Multiple commands produce

I just upgraded to Xcode 10, and I suddenly face this error when I try to build, any ideas how to fix it? I tried cleaning derived data, but without any luck.
If you use CocoaPods, click Xcode menu file -> Workspace Settings , And click Build system choice Legacy Build System
If you not use CocoaPods, same of top , select Project Settings
If your app is generating the error related to the multiple .app files just like mentioned above in question then removing the .plist files from "Copy bundle Resources" WILL NOT WORK.
If the error is related to .app file then follow the following steps.
Select the Target.
Go to Build Phases tab.
Remove the items listed in Output Files
Compile the code if it compiles successfully then not follow the next steps.
If code does not compile successfully and Xcode may give you an error related to "Library not found". Then add the missing library in General Tab in Linked Frameworks and Libraries that Xcode mentioned in the error.
Keep adding these libraries (that Xcode ask through compile errors) in Linked Frameworks and Libraries until the code compiles successfully.
Hope this helps.
You can try to change the build system to Legacy,
File > Workspace Settings > Build System > Legacy Build System.
I also faced this issue in xcode 10 but it was because of adding the same framework in main project + other extensions (watchkit or siri extension etc).
I added ObjectMapper in podfile for my main project + for my extensions. When I compiled it gave me an error that multiple command produce and also shows me which framework is causing this issue. Now its working fine for me as I've removed it from my extensions I wasn't using it in my extensions.
Don't know about your issue may be you can check your podfile.
If this is CoreData related. The issue is that you are trying to generate the NSManagedObject subclass but you need to set the 'CodeGen' option to Manual/None. This option is defaulted to Class definition and this would regenerate the code thus creating this issue.
i encountered this issue as well while working with CoreData.
in my .xcdatamodeld file, it came down to the fact that, during the creation of my various Entities, i had copy and pasted one multiple times (thinking i was saving time because various properties were similar enough that i thought this was a good idea).
the resulting Build error Xcode 10 - 'Multiple commands produce' occurred because i forgot to check and make sure the new Entities were set to their own unique corresponding class to match the new Entity in the Data Model Inspector pane.
unfortunately, it took me two days to figure out the original Entity's Class Name was still in place.
so lesson: careful when you copy/paste/duplicate Entities in CoreData.
(... i guess :0} )
some time saver. oops! hope this helps someone.
I had this same issue with Core Data entity class. I had forgotten to select Codegen Manual / None because I do not allow mine to be autogenerated. So I had a class in place and also it was trying to generate one.

How to fix Application Loader Error: Invalid Bundle. The bundle ... contains disallowed file 'Frameworks'

I have a Swift project with three Swift custom frameworks. The App builds and runs successfully but when I try to upload to iTunes Connect using Application Loader I get the following error for all three frameworks:
ERROR ITMS-90206: "Invalid Bundle. The bundle at 'XXX.app/Frameworks/YYY.framework' contains disallowed file 'Frameworks'."
As discussed in this SO answer I have set the 'Embedded Content Contains Swift Code' to NO in the frameworks and YES in the App, but this error persists.
The three Frameworks are all my own (I am seriously considering reworking the project to avoid Frameworks altogether but that is a chore I would like to avoid right now).
I am not using cocoapods.
Any ideas on how to resolve this error?
The key to solving this for me was, in addition to ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO, also setting EMBEDDED_CONTENT_CONTAINS_SWIFT=NO in build settings for all targets except the main app target. Had to clear out derived data, but after that all was well.
In (SE-0133) of the Xcode 8.3 Release note, there's a description about EMBEDDED_CONTENT_CONTAINS_SWIFT setting:
The new build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES replaces the EMBEDDED_CONTENT_CONTAINS_SWIFT setting, which has been deprecated. This new setting indicates that Xcode should always embed Swift standard libraries in a target for which it has been set, whether or not the target contains Swift code. A typical scenario for using this setting is when a target directly uses or embeds another product that contains Swift code. (26158130)
which means ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES has replaced EMBEDDED_CONTENT_CONTAINS_SWIFT, thus you need to change the former one(ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) to NO in the extension target.
So this is not a good answer, but it is what I did to resolve it:
I created a new project and copied in all my files - in a flat structure without Frameworks, editing just to remove the relevant import statements. It now uploads fine. So it is the Framework structure that is the root of the problem. Not sure if the idea of Swift embedded custom libraries is just broken or I was doing something wrong so still looking for better answers...

Intermittent Swift Framework Compiler Error

I am trying out Swift in the XCode beta. In particular using an #IBDesignable and #IBInspectable. I am building a framework containing an (#IBDesignable) UIView subclass and a Simple iOS App in order to test it out (Both contained in and linked via a workspace). After a few successful builds I get the following error in the framework build output:
:0: error: /Users/richardpj/Projects/Swift2/Swift2FW/build/Swift2FW.build/Debug-iphonesimulator/Swift2FW.build/unextended-module.modulemap:2: umbrella header 'Swift2FW.h' not found
:0: error: could not build Objective-C module 'Swift2FW'
Before you ask I've done a clean and deleted my derived data but nothing seems to resolve it except deleting and recreating the workspace and project files.
Any ideas on the source of the error, how to replicate (for a bug report) OR am I being dumb.
EDIT: I've gotten 50 views since this was posted. Sounds like it's a bug I should report. Any ideas on how to do that?
When making my own swift framework I got the error "could not build Objective-C module".
I fixed it by going to "Link Binary With Libraries" and adding "UIKit".
In case if you are writing embedded framework in Swift check your Project Settings -> Framework Target Name -> Build Phases -> Headers. Currently (Xcode 6.2) any header file listed in Public section here can cause this error:
<unknown>:0: error: could not build Objective-C module 'YourFrameworkName'
I was seeing this error when the .h umbrella file had the same name as one of my swift files. Once I changed the name of the swift file the framework built.
Ex. Project Name: TestProject
|_
TestProject.h <=
|_
Models
|_
TestProject.swift <=
Having the two files with the arrows ( <= ) named the same caused the "could not build Objective-C module" error for me.
In my case I had a previous build setting that overrode Public Headers Folder Path (PUBLIC_HEADERS_FOLDER_PATH) . Clearing that to the (new?) default value of $(CONTENTS_FOLDER_PATH)/Headers fixed the error.
In my case, all I had to do was open the "Edit Scheme" window (Product > Schemes > Edit Scheme) for the embedded Swift Framework target and uncheck "Shared". I guess because non-embedded Swift frameworks aren't yet supported, sharing a framework scheme implies there must be an Objective-C component of the module.
You can also uncheck this in the "Manage Schemes" window (Product > Schemes > Manage Schemes...).
After coming across this problem many times and sometime resorting to recreating the whole project I have found that this very strange build problem is normally caused by you having Breakpoints set.
Open the Breakpoint Navigator Window (CMD-7) and delete all the breakpoints.
This normally fixes this problem for me however bizarre it may sound.
It's very easy to accidentally add a breakpoint when you're clicking in the margin to investigate compilation errors.
I don't know if this will help anybody else but I had imported the ProjectName-Swift.h file into the ProjectName.h (umbrella header) file during some testing, and when I removed that import the error went away and I was able to build again.
In my case this turned out to be because I had failed to list the framework as a dependency in the build phases of my other target(s). As soon as I did that, all was well.
I presume that it is because this ensures that the framework is build before the target(s) that use it.
The reason this issue is intermittent is evidently that, without the dependency, the order of building is indeterminate — so sometimes it happens to be the right order and the build works, and other times it happens to be the wrong order and the build fails.

Resources