15 Replies
      Latest reply on Oct 23, 2019 5:39 PM by alvaroroyo
      Zaba Level 1 Level 1 (0 points)


        I've a issue with integrating swift packages into projects that were created via e.g. xcode 10 (pre 11).

        I see added library in 'Swift Package Dependencies' correctly, it's in 'Frameworks, Libraries and Embedded Content' section of target's settings as well as in 'Link Binary With Libraries' section of 'Build Phases'


        If I create a new project then everything works smothly. A few things that I've already tried:

        - Copy swift package manualy (by drag and drop) into the project

        - Add package via file://LocalURL

        - I've compared info.plist, build settings and schemes beteen old and new project (Maybe I've missed something, my guess is that the issue is in build settings but I can't find it)


        The result is always the same, if I import SPM library in any file I get an error "No such module 'ExampleFramework'"


        Any ideas? Thanks in advance for any help

        • Re: SPM in project pre Xcode 11 - 'No Such Module'
          Claude31 Level 8 Level 8 (7,225 points)

          Sorry if that's a trivial question.


          Did you do an option-clean build Folder from XCode project menu ?

          • Re: SPM in project pre Xcode 11 - 'No Such Module'
            Zaba Level 1 Level 1 (0 points)

            Ok so after various tries I've created new project, added files from the old one and during this I've encountered at identical situation, it turns out that the issue is not in build settings but rather in configuration.

            You cannot build SPM with different configuration than 'Debug' and as in most of my projects I have multiple configurations, that why I wasn't able to use SPM in them.

            Unfortunately I couldn't find a way to change target configuration, nevertheless I'm closing this thread, I hope that my explanation above will hope someone with the same issue

            • Re: SPM in project pre Xcode 11 - 'No Such Module'
              bstahl Level 1 Level 1 (0 points)

              I'm having the same or a similar problem, but in my case re-creating the project and workspace files in Xcode 11 beta-5 still results in those "no such module" errors when compiling/linking my SPM dependencies. In addition to "no such module" errors, some dependencies generate "Command CompileSwift failed with nonzero exit code" errors. Like you, I can run it fine in Debug mode, but cannot export using Archive. This seems like a bug (I hope?), hopefully one that will be fixed soon. This project was fine compiling non-Debug builds in Xcode 10.X. I'm using macOS 10.14.4, but I also tried it in macOS 10.15 beta-5, but it didn't fix anything.


              Submitted Feedback Assistant bug report #FB7031121 "Xcode 11 beta-5 with SPM dependencies produces errors with Archive build."


              EDIT: problem is still present in Xcode 11.1 (release). I'm pretty sure this is some setting from Xcode 10 that got stuck and is messing up the linking, because I created a few new projects with the same dependencies and they're OK, but I can't find exactly what causes it.

                • Re: SPM in project pre Xcode 11 - 'No Such Module'
                  samoilyk Level 1 Level 1 (0 points)

                  I have the same issue with both beta 5 and beta 6 even with Debug. It is a completly new project created in Xcode Beta 5. There are two packages added localy, that depend on external packages (like RxSwift, Apollo and others) and it shows same errors as you described However, sometimes after removing derived data and cleaning a build folder it succedes. But it's so random... For now I disabled parallelized build and always wait for Xcode to finish Indexing before building the project and it works in 2 of 3 build But no idea how to fix it for "Enterprise" configuration, which we use to build at Bitrise. Hope it's a bug and it will be fixed in next releases.

                • Re: SPM in project pre Xcode 11 - 'No Such Module'
                  Burnt Reynolds Level 1 Level 1 (0 points)

                  I just submitted a bug as well (7156929).  I was able to reproduce this with a tiny sample project easily.  I hope they fix it as this will be a big problem for SPM adoption otherwise.

                    • Re: SPM in project pre Xcode 11 - 'No Such Module'
                      bstahl Level 1 Level 1 (0 points)

                      You're right, these kinds of bugs will sour people on adopting SPM for sure, it already is for me. I was really excited to finally have SPM integrated, hoping I could move away from Carthage and Cocoapods, but with the SPM system behaving this way it's a serious impediment and will make me skittish about using it for a long time. I can't afford the time loss trying to figure out what's going on in Apple's inscrutable build system. A "nonzero exit code"? Uh, thanks for that helpful description, Apple, what am I supposed to do with that?

                    • Re: SPM in project pre Xcode 11 - 'No Such Module'
                      grangej Level 1 Level 1 (0 points)

                      Apple ? There has to be a work around here. I am trying to integrate a package into my source code but we do not use standard debug / release only build configurations.

                      • Re: SPM in project pre Xcode 11 - 'No Such Module'
                        spoek Level 1 Level 1 (0 points)

                        We just encountered the same problem when running our release build. Any workaround available? This is frustrating.

                        • Re: SPM in project pre Xcode 11 - 'No Such Module'
                          bstahl Level 1 Level 1 (0 points)

                          For reference, here is my bug report to Apple. To be fair, they did get back to me requesting further information (the build log), which I provided. But that was over a month ago (not only is Xcode 11 out of beta now, but 11.1 is released and still exhibiting the same issue).


                          Please provide a descriptive title for your feedback:

                          Xcode 11 beta-5 with SPM dependencies produces errors with Archive build


                          Which area are you seeing an issue with?

                          Swift Compiler


                          What type of feedback are you reporting?

                          Incorrect/Unexpected Behavior


                          Please describe the issue:


                          I have a Swift 5 project using Swift Package Manager dependencies in Xcode beta-5. This project could Archive build without errors in Xcode 10.X, but in Xcode 11, I get compilation or linking errors and the archive is not built. Specifically, each dependency generates one of 2 errors: "No such module" or "Command CompileSwift failed with a nonzero exit code".


                          These errors are NOT generated using Run (Debug build), they only appear when attempting a non-Debug build, such as Archive or Profile. Again, this same project compiled, linked, and exported fine in Xcode 10.


                          Please list the steps you took to reproduce the issue:

                          1. Cleaned project (Option-Clean Build Folder).

                          2. Delete all in DerivedData folder.

                          3. Restart Xcode.

                          4. Restart computer.

                          5. Try same project on different computers also running Xcode 11 beta-5 (same result seen both with macOS 10.14.4 and macOS 10.15 beta-5).

                          6. Select File > Swift Packages > Reset Package Caches.

                          7. Delete project and workspace files, re-create those files fresh using Xcode 11 beta-5, re-add source files and dependencies.


                          What did you expect to happen?

                          Expected Archive command to produce an archive build.


                          What actually happened?

                          Build fails with error listed above.

                          • Re: SPM in project pre Xcode 11 - 'No Such Module'
                            alvaroroyo Level 1 Level 1 (0 points)

                            Read this post to use SPM with custom environments schemas.