Swift classes marked with @objc not being added to “-Swift.h” header in mixed Objective-C/Swift frameworkHow to call Objective-C code from Swift#pragma mark in Swift?Can't use Swift classes inside Objective-CiOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 BetaImporting CommonCrypto in a Swift frameworkObjective C to Swift header file with multiple targetsimport swift class in objective-c, <myModule>-Swift.h file not foundXcode 8 with mixed Swift and Objective-c project generated “ModuleName-Swift.h” header not foundHow can I deal with @objc inference deprecation with #selector() in Swift 4?Objc class doesn't recognize Swift class

Ender 5: Bowden tube shifts in/out of extruder during retractions

Tikz intersecting nodes and fit boxes

What is Rambam's source that the Sages issued a command to not teach your daughter Torah?

How long should I wait to plug in my refrigerator after unplugging it?

How to design an effective polearm-bow hybrid?

Using Forstner bits instead of hole saws

Is law enforcement responsible for damages made by a search warrant?

Is there a way to say "double + any number" in German?

Difference between "jail" and "prison" in German

What printing process is this?

Generate random number in Unity without class ambiguity

Is this popular optical illusion made of a grey-scale image with coloured lines?

Is the first page of Novel really that important?

How do people drown while wearing a life jacket?

Any information about the photo with Army Uniforms

In a KP-K endgame, if the enemy king is in front of the pawn, is it always a draw?

What license to choose for my PhD thesis?

“The Fourier transform cannot measure two phases at the same frequency.” Why not?

Export economy of Mars

How can I perform a deterministic physics simulation?

Why are sugars in whole fruits not digested the same way sugars in juice are?

Does a bard know when a character uses their Bardic Inspiration?

In MTG, was there ever a five-color deck that worked well?

Is it moral to remove/hide certain parts of a photo, as a photographer?



Swift classes marked with @objc not being added to “-Swift.h” header in mixed Objective-C/Swift framework


How to call Objective-C code from Swift#pragma mark in Swift?Can't use Swift classes inside Objective-CiOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 BetaImporting CommonCrypto in a Swift frameworkObjective C to Swift header file with multiple targetsimport swift class in objective-c, <myModule>-Swift.h file not foundXcode 8 with mixed Swift and Objective-c project generated “ModuleName-Swift.h” header not foundHow can I deal with @objc inference deprecation with #selector() in Swift 4?Objc class doesn't recognize Swift class






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am attempting to convert an old statically linked library to a framework. With mixed swift and objective c in the static library, all headers are generated correctly. However, switching to a framework target and adding swift files, marked with the @objc header, the class is not added to the -Swift.h header. I can import the header, but swift classes are not found. This is in Xcode 10.2 and attempted using both Swift 4.2 and 5.



Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?










share|improve this question





















  • 2





    You do something wrong.

    – Amin Negm-Awad
    Mar 27 at 9:07











  • @AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

    – JDL
    Mar 27 at 13:12






  • 1





    Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

    – Amin Negm-Awad
    Mar 27 at 21:35











  • @AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

    – JDL
    Mar 27 at 22:13












  • Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

    – Amin Negm-Awad
    Mar 28 at 9:12


















1















I am attempting to convert an old statically linked library to a framework. With mixed swift and objective c in the static library, all headers are generated correctly. However, switching to a framework target and adding swift files, marked with the @objc header, the class is not added to the -Swift.h header. I can import the header, but swift classes are not found. This is in Xcode 10.2 and attempted using both Swift 4.2 and 5.



Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?










share|improve this question





















  • 2





    You do something wrong.

    – Amin Negm-Awad
    Mar 27 at 9:07











  • @AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

    – JDL
    Mar 27 at 13:12






  • 1





    Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

    – Amin Negm-Awad
    Mar 27 at 21:35











  • @AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

    – JDL
    Mar 27 at 22:13












  • Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

    – Amin Negm-Awad
    Mar 28 at 9:12














1












1








1








I am attempting to convert an old statically linked library to a framework. With mixed swift and objective c in the static library, all headers are generated correctly. However, switching to a framework target and adding swift files, marked with the @objc header, the class is not added to the -Swift.h header. I can import the header, but swift classes are not found. This is in Xcode 10.2 and attempted using both Swift 4.2 and 5.



Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?










share|improve this question
















I am attempting to convert an old statically linked library to a framework. With mixed swift and objective c in the static library, all headers are generated correctly. However, switching to a framework target and adding swift files, marked with the @objc header, the class is not added to the -Swift.h header. I can import the header, but swift classes are not found. This is in Xcode 10.2 and attempted using both Swift 4.2 and 5.



Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?







ios objective-c swift xcode






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 22:24







JDL

















asked Mar 27 at 1:57









JDLJDL

1,14218 silver badges28 bronze badges




1,14218 silver badges28 bronze badges










  • 2





    You do something wrong.

    – Amin Negm-Awad
    Mar 27 at 9:07











  • @AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

    – JDL
    Mar 27 at 13:12






  • 1





    Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

    – Amin Negm-Awad
    Mar 27 at 21:35











  • @AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

    – JDL
    Mar 27 at 22:13












  • Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

    – Amin Negm-Awad
    Mar 28 at 9:12













  • 2





    You do something wrong.

    – Amin Negm-Awad
    Mar 27 at 9:07











  • @AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

    – JDL
    Mar 27 at 13:12






  • 1





    Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

    – Amin Negm-Awad
    Mar 27 at 21:35











  • @AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

    – JDL
    Mar 27 at 22:13












  • Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

    – Amin Negm-Awad
    Mar 28 at 9:12








2




2





You do something wrong.

– Amin Negm-Awad
Mar 27 at 9:07





You do something wrong.

– Amin Negm-Awad
Mar 27 at 9:07













@AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

– JDL
Mar 27 at 13:12





@AminNegm-Awad, that is a duh comment, the question is "what might I be doing wrong"

– JDL
Mar 27 at 13:12




1




1





Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

– Amin Negm-Awad
Mar 27 at 21:35





Oh, my comment is not precise enough? What about your Q? My answer is the best you can expect from your Q.

– Amin Negm-Awad
Mar 27 at 21:35













@AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

– JDL
Mar 27 at 22:13






@AminNegm-Awad, If there are additional details that I could provide that would make it a better question, please elucidate. I have provided the details that I thought pertinent after searching all available questions on the subject. If you do not know enough about XCode to understand the problem or possible solutions, feel free to let the question pass you by. Actually the question at hand is, "Are there any particular settings in XCode that will affect the generation of the *-Swift.h header in a mixed Objective C/Swift framework target?"

– JDL
Mar 27 at 22:13














Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

– Amin Negm-Awad
Mar 28 at 9:12






Neither did I say that this is not a problem nor did I say that there is no solution to it. I said, that this is the answer you can expect on SO. You can't do it better? Questions seeking debugging help […] must include […] the shortest code necessary to reproduce it in the question itself. Start with creating a new project that contains the problem. If it doesn't contain the error, compare the new project to the existing one. In many cases the Q magically disappears.

– Amin Negm-Awad
Mar 28 at 9:12













2 Answers
2






active

oldest

votes


















1














I had a similar issue. In my case it was a known issue in Xcode 10.2:



https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes




If you’re building a framework containing Swift code and using lipo to create a binary that supports both device and simulator platforms, you must also combine the generated Framework-Swift.h headers for each platform to create a header that supports both device and simulator platforms. (48635615)
...




In my case all I had to do was to update the Carthage to the newest version 0.33.0






share|improve this answer
































    1














    The problem appears to be a combination of Apple's new build system, the expectations they set when compiling and the number of inter-dependencies in the project setup.



    The new build system runs the Swift compilations in parallel. When having multiple library/framework dependencies that are mixed Objective C and Swift, the compiler appears to not generate the -Swift.h files on time. In static libraries, the -Swift.h files appear to be generated at the end of the Swift Compilation process, meaning they are not generated quickly enough to be used by the Objective C files when the Objective C compilation occurs. When generating a framework, it appears that the Compiler generates the header at the beginning of the compilation process and the Swift files are not fully compiled and the -Swift.h file does not generate appropriately with the Objective C class interfaces and protocols.



    What this means ends up meaning is that we can not rely on the "target dependencies" to build the dependent projects correctly.



    So how can we build our .framework of mixed Objective C and -Swift.h without a ton of manual scripting.



    Here are the tricks I discovered that will work.



    1. Use the old build system. When using the new build system there is an error when it attempts to merge the module map for the static library file saying that it can not find the *-Swift.h file whether or not it exists.

    2. Create your framework by making it a wrapper around the static library by:

      • Giving them both the same product name and module name.

      • Add a single .Swift file to the framework build so that it has something to compile and will link the swift libraries.

      • link to the static library in the framework.

      • Add all necessary headers to the public headers of the framework.

      • Add all public headers to the umbrella header.

      • Use a Run script phase to copy the *-Swift.h file from the static library build to the framework product post compile.

      • For any public headers that include the *-Swift.h, you may need to post process the header and replace the *-Swift.h import with the appropriate framework import ie . This would not be recommended due to possible cyclical imports in the umbrella header.


    3. When running a clean, build the framework target first manually, before building the application target.

    Below is an example script for copying the *-Swift.h file post build.



    header_file="$TARGET_TEMP_DIR/../$PRODUCT_MODULE_NAME.build/DerivedSources/$PRODUCT_MODULE_NAME-Swift.h"
    header_dir="$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH"
    mkdir -p "$DIR"
    echo "copying $header_file $header_dir"
    cp -f "$FILE" "$DIR"


    UPDATED



    Marking all modules Swift compilation mode to "Whole Module" appears to have a positive affect on this issue, but I have not fully tested it.






    share|improve this answer





























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368671%2fswift-classes-marked-with-objc-not-being-added-to-swift-h-header-in-mixed-ob%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      I had a similar issue. In my case it was a known issue in Xcode 10.2:



      https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes




      If you’re building a framework containing Swift code and using lipo to create a binary that supports both device and simulator platforms, you must also combine the generated Framework-Swift.h headers for each platform to create a header that supports both device and simulator platforms. (48635615)
      ...




      In my case all I had to do was to update the Carthage to the newest version 0.33.0






      share|improve this answer





























        1














        I had a similar issue. In my case it was a known issue in Xcode 10.2:



        https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes




        If you’re building a framework containing Swift code and using lipo to create a binary that supports both device and simulator platforms, you must also combine the generated Framework-Swift.h headers for each platform to create a header that supports both device and simulator platforms. (48635615)
        ...




        In my case all I had to do was to update the Carthage to the newest version 0.33.0






        share|improve this answer



























          1












          1








          1







          I had a similar issue. In my case it was a known issue in Xcode 10.2:



          https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes




          If you’re building a framework containing Swift code and using lipo to create a binary that supports both device and simulator platforms, you must also combine the generated Framework-Swift.h headers for each platform to create a header that supports both device and simulator platforms. (48635615)
          ...




          In my case all I had to do was to update the Carthage to the newest version 0.33.0






          share|improve this answer













          I had a similar issue. In my case it was a known issue in Xcode 10.2:



          https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes




          If you’re building a framework containing Swift code and using lipo to create a binary that supports both device and simulator platforms, you must also combine the generated Framework-Swift.h headers for each platform to create a header that supports both device and simulator platforms. (48635615)
          ...




          In my case all I had to do was to update the Carthage to the newest version 0.33.0







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 16 at 14:11









          MateuszMateusz

          1,1249 silver badges21 bronze badges




          1,1249 silver badges21 bronze badges


























              1














              The problem appears to be a combination of Apple's new build system, the expectations they set when compiling and the number of inter-dependencies in the project setup.



              The new build system runs the Swift compilations in parallel. When having multiple library/framework dependencies that are mixed Objective C and Swift, the compiler appears to not generate the -Swift.h files on time. In static libraries, the -Swift.h files appear to be generated at the end of the Swift Compilation process, meaning they are not generated quickly enough to be used by the Objective C files when the Objective C compilation occurs. When generating a framework, it appears that the Compiler generates the header at the beginning of the compilation process and the Swift files are not fully compiled and the -Swift.h file does not generate appropriately with the Objective C class interfaces and protocols.



              What this means ends up meaning is that we can not rely on the "target dependencies" to build the dependent projects correctly.



              So how can we build our .framework of mixed Objective C and -Swift.h without a ton of manual scripting.



              Here are the tricks I discovered that will work.



              1. Use the old build system. When using the new build system there is an error when it attempts to merge the module map for the static library file saying that it can not find the *-Swift.h file whether or not it exists.

              2. Create your framework by making it a wrapper around the static library by:

                • Giving them both the same product name and module name.

                • Add a single .Swift file to the framework build so that it has something to compile and will link the swift libraries.

                • link to the static library in the framework.

                • Add all necessary headers to the public headers of the framework.

                • Add all public headers to the umbrella header.

                • Use a Run script phase to copy the *-Swift.h file from the static library build to the framework product post compile.

                • For any public headers that include the *-Swift.h, you may need to post process the header and replace the *-Swift.h import with the appropriate framework import ie . This would not be recommended due to possible cyclical imports in the umbrella header.


              3. When running a clean, build the framework target first manually, before building the application target.

              Below is an example script for copying the *-Swift.h file post build.



              header_file="$TARGET_TEMP_DIR/../$PRODUCT_MODULE_NAME.build/DerivedSources/$PRODUCT_MODULE_NAME-Swift.h"
              header_dir="$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH"
              mkdir -p "$DIR"
              echo "copying $header_file $header_dir"
              cp -f "$FILE" "$DIR"


              UPDATED



              Marking all modules Swift compilation mode to "Whole Module" appears to have a positive affect on this issue, but I have not fully tested it.






              share|improve this answer































                1














                The problem appears to be a combination of Apple's new build system, the expectations they set when compiling and the number of inter-dependencies in the project setup.



                The new build system runs the Swift compilations in parallel. When having multiple library/framework dependencies that are mixed Objective C and Swift, the compiler appears to not generate the -Swift.h files on time. In static libraries, the -Swift.h files appear to be generated at the end of the Swift Compilation process, meaning they are not generated quickly enough to be used by the Objective C files when the Objective C compilation occurs. When generating a framework, it appears that the Compiler generates the header at the beginning of the compilation process and the Swift files are not fully compiled and the -Swift.h file does not generate appropriately with the Objective C class interfaces and protocols.



                What this means ends up meaning is that we can not rely on the "target dependencies" to build the dependent projects correctly.



                So how can we build our .framework of mixed Objective C and -Swift.h without a ton of manual scripting.



                Here are the tricks I discovered that will work.



                1. Use the old build system. When using the new build system there is an error when it attempts to merge the module map for the static library file saying that it can not find the *-Swift.h file whether or not it exists.

                2. Create your framework by making it a wrapper around the static library by:

                  • Giving them both the same product name and module name.

                  • Add a single .Swift file to the framework build so that it has something to compile and will link the swift libraries.

                  • link to the static library in the framework.

                  • Add all necessary headers to the public headers of the framework.

                  • Add all public headers to the umbrella header.

                  • Use a Run script phase to copy the *-Swift.h file from the static library build to the framework product post compile.

                  • For any public headers that include the *-Swift.h, you may need to post process the header and replace the *-Swift.h import with the appropriate framework import ie . This would not be recommended due to possible cyclical imports in the umbrella header.


                3. When running a clean, build the framework target first manually, before building the application target.

                Below is an example script for copying the *-Swift.h file post build.



                header_file="$TARGET_TEMP_DIR/../$PRODUCT_MODULE_NAME.build/DerivedSources/$PRODUCT_MODULE_NAME-Swift.h"
                header_dir="$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH"
                mkdir -p "$DIR"
                echo "copying $header_file $header_dir"
                cp -f "$FILE" "$DIR"


                UPDATED



                Marking all modules Swift compilation mode to "Whole Module" appears to have a positive affect on this issue, but I have not fully tested it.






                share|improve this answer





























                  1












                  1








                  1







                  The problem appears to be a combination of Apple's new build system, the expectations they set when compiling and the number of inter-dependencies in the project setup.



                  The new build system runs the Swift compilations in parallel. When having multiple library/framework dependencies that are mixed Objective C and Swift, the compiler appears to not generate the -Swift.h files on time. In static libraries, the -Swift.h files appear to be generated at the end of the Swift Compilation process, meaning they are not generated quickly enough to be used by the Objective C files when the Objective C compilation occurs. When generating a framework, it appears that the Compiler generates the header at the beginning of the compilation process and the Swift files are not fully compiled and the -Swift.h file does not generate appropriately with the Objective C class interfaces and protocols.



                  What this means ends up meaning is that we can not rely on the "target dependencies" to build the dependent projects correctly.



                  So how can we build our .framework of mixed Objective C and -Swift.h without a ton of manual scripting.



                  Here are the tricks I discovered that will work.



                  1. Use the old build system. When using the new build system there is an error when it attempts to merge the module map for the static library file saying that it can not find the *-Swift.h file whether or not it exists.

                  2. Create your framework by making it a wrapper around the static library by:

                    • Giving them both the same product name and module name.

                    • Add a single .Swift file to the framework build so that it has something to compile and will link the swift libraries.

                    • link to the static library in the framework.

                    • Add all necessary headers to the public headers of the framework.

                    • Add all public headers to the umbrella header.

                    • Use a Run script phase to copy the *-Swift.h file from the static library build to the framework product post compile.

                    • For any public headers that include the *-Swift.h, you may need to post process the header and replace the *-Swift.h import with the appropriate framework import ie . This would not be recommended due to possible cyclical imports in the umbrella header.


                  3. When running a clean, build the framework target first manually, before building the application target.

                  Below is an example script for copying the *-Swift.h file post build.



                  header_file="$TARGET_TEMP_DIR/../$PRODUCT_MODULE_NAME.build/DerivedSources/$PRODUCT_MODULE_NAME-Swift.h"
                  header_dir="$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH"
                  mkdir -p "$DIR"
                  echo "copying $header_file $header_dir"
                  cp -f "$FILE" "$DIR"


                  UPDATED



                  Marking all modules Swift compilation mode to "Whole Module" appears to have a positive affect on this issue, but I have not fully tested it.






                  share|improve this answer















                  The problem appears to be a combination of Apple's new build system, the expectations they set when compiling and the number of inter-dependencies in the project setup.



                  The new build system runs the Swift compilations in parallel. When having multiple library/framework dependencies that are mixed Objective C and Swift, the compiler appears to not generate the -Swift.h files on time. In static libraries, the -Swift.h files appear to be generated at the end of the Swift Compilation process, meaning they are not generated quickly enough to be used by the Objective C files when the Objective C compilation occurs. When generating a framework, it appears that the Compiler generates the header at the beginning of the compilation process and the Swift files are not fully compiled and the -Swift.h file does not generate appropriately with the Objective C class interfaces and protocols.



                  What this means ends up meaning is that we can not rely on the "target dependencies" to build the dependent projects correctly.



                  So how can we build our .framework of mixed Objective C and -Swift.h without a ton of manual scripting.



                  Here are the tricks I discovered that will work.



                  1. Use the old build system. When using the new build system there is an error when it attempts to merge the module map for the static library file saying that it can not find the *-Swift.h file whether or not it exists.

                  2. Create your framework by making it a wrapper around the static library by:

                    • Giving them both the same product name and module name.

                    • Add a single .Swift file to the framework build so that it has something to compile and will link the swift libraries.

                    • link to the static library in the framework.

                    • Add all necessary headers to the public headers of the framework.

                    • Add all public headers to the umbrella header.

                    • Use a Run script phase to copy the *-Swift.h file from the static library build to the framework product post compile.

                    • For any public headers that include the *-Swift.h, you may need to post process the header and replace the *-Swift.h import with the appropriate framework import ie . This would not be recommended due to possible cyclical imports in the umbrella header.


                  3. When running a clean, build the framework target first manually, before building the application target.

                  Below is an example script for copying the *-Swift.h file post build.



                  header_file="$TARGET_TEMP_DIR/../$PRODUCT_MODULE_NAME.build/DerivedSources/$PRODUCT_MODULE_NAME-Swift.h"
                  header_dir="$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH"
                  mkdir -p "$DIR"
                  echo "copying $header_file $header_dir"
                  cp -f "$FILE" "$DIR"


                  UPDATED



                  Marking all modules Swift compilation mode to "Whole Module" appears to have a positive affect on this issue, but I have not fully tested it.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 8 at 14:25

























                  answered Mar 28 at 15:44









                  JDLJDL

                  1,14218 silver badges28 bronze badges




                  1,14218 silver badges28 bronze badges






























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368671%2fswift-classes-marked-with-objc-not-being-added-to-swift-h-header-in-mixed-ob%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript