Search code examples
iosobjective-cswiftheader-filesbridging

After importing Objective C Framework into my Swift project, my project does not recognise my header file in my Bridging file


I've got to import a Framework into my Swift project that is written in Objective C. So I've created a Bridging file and after I've added the Header files to it and compiled, my project says it cannot find them. The image below shows my Framework and you can clearly see AWController.h but it throws an error in my Bridging file when building.

enter image description here

The Bridging file shows in my Settings so what am I doing wrong or what have I missed? I've set my Defines Module to Yes in Build Settings and my Module Name has no spaces.

enter image description here


Solution

  • I would review the setup for AWS at their website. They even have a section that details using with Swift iOS9.

    Among other things, if you are using the Frameworks manual integration, verify that step 4 is complete.

    Under the Build Phases tab in your Target, click the + button on the top left and then select New Run Script Phase. Then setup the build phase as follows. Make sure this phase is below the Embed Frameworks phase.:

    Shell /bin/sh

    bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework/strip-frameworks.sh"

    Show environment variables in build log: Checked Run script only when installing: Not checked

    Input Files: Empty Output Files: Empty

    You might want to install and use Carthage to make this easier. Head over to the Homebrew website then after installing homebrew you'd run brew install carthage from the command line. After that go back to the link above and follow the Carthage instructions.

    Secondly, I would take another walkthrough of the Apple Documentation on Working with the bridging header files to see if any of the edge cases apply and just as a sanity check.

    Third, if that doesn't work, I'd just try creating an empty Swift project and walk through the steps again using one of the techniques above. There might be something wrong with one or more settings in your project files or the file itself might be corrupt.

    BTW - The product bundle identifier should probably be following the convention of com.yourdomain.YourProductName.