Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

'iosfwd' file not found #28

Closed
rubensantiago opened this issue Jun 12, 2018 · 9 comments
Closed

'iosfwd' file not found #28

rubensantiago opened this issue Jun 12, 2018 · 9 comments
Labels

Comments

@rubensantiago
Copy link

After importing <Sonar/SonarClient.h>, 'iosfwd' cannot be found in json.h. This is a mixed Obj-C & Swift project.

@priteshrnandgaonkar
Copy link
Contributor

We do not support swift projects yet. We are working on it. Look at the issue #13

@JiandanDream
Copy link

The same, but mine is a Objc project.

@iineva
Copy link

iineva commented Jun 21, 2018

Xcode Version 9.4.1 (9F2000)
Create a new Objective-C project, same issue.

@noahsark769
Copy link
Contributor

@JiandanDream @iineva I'm seeing this error also. AFAIK, this should work since Cocoapods should be able to compile this objc module to make it usable in a Swift module. Do either of you have a sample project I could look at to try to reproduce? An objc project fails with this error would be best for investigation purposes.

@iineva
Copy link

iineva commented Jun 22, 2018

@noahsark769 You can try this: Test.zip

pod update
pod install
# than build project.

@noahsark769
Copy link
Contributor

Can confirm that the same error happens for me on @iineva 's test project, which has no Swift (I'm running Xcode Version 9.3 (9E145)). @priteshrnandgaonkar can we reopen this since it's not a Swift specific issue?

@noahsark769
Copy link
Contributor

@iineva after trying a few things, I was able to make your project compile by adding the search path "${PODS_ROOT}/SonarKit" with recursive = true to "Search Paths" under "Build Settings".

image

I have to say that I'm not exactly sure what's happening here to fix it, but I tested it twice. Unfortunately, with my project, I still get the same error :(

@noahsark769
Copy link
Contributor

It looks like facebook/yoga#697, facebook/react-native#17556, facebook/yoga#711 were similar issues that React Native had with Swift projects.

The fix there seems to have been to specify public_header_files in Yoga's podspec specifically so that headers with c++ are excluded. My guess is we'll need to some something similar for Sonar/SonarKit.

@noahsark769
Copy link
Contributor

This ended up being a search path issue. See explanation at #13

facebook-github-bot pushed a commit that referenced this issue Jul 20, 2018
Summary:
This PR adds support for using SonarKit clients in Swift apps. Fixes #13, fixes #87

1. Swift can't import Obj-C modules which have C++ headers. For this reason, we use SonarKit as an Obj-C++ wrapper around Sonar, which is written in C++. Due to search path misconfiguration, trying to import SonarKit into a Swift project would import `xplat/Sonar/SonarPlugin.h` instead of `iOS/SonarKit/SonarPlugin.h`, which caused `file not found` errors for C++ stdlib imports like #28 because new projects don't have their search paths set up correctly.
2. The network and layout plugins have C++ definitions (struct methods, classes) in some of their headers. This causes the compiler to get confused for Swift projects, because it only supports importing Objective-C files in umbrella headers, meaning that the `SonarKit` won't build.

1. I updated the `HEADER_SEARCH_PATHS` of SonarKit.podspec's build configuration to include `${PODS_ROOT}/Headers/Private/SonarKit/**` first, which alleviates the search path issue. The Obj-C `Sample` project seems to have worked around this by including a hardcoded `${PODS_ROOT}/SonarKit/**` search path in the pbxproj, which is why Sample works but new projects (like those referenced in #28) don't. I removed this since it's no longer necessary.
2. I added a `SampleSwift` app to demonstrate using Sonar with a Swift project.
3. Because the Podfiles for `Sample` and `SampleSwift` referenced podspecs using `:podspec` instead of a concrete version, Cocoapods wouldn't copy local header files (instead, it downloads them from the source). To enable local development of these sample apps using `:path`, I added a symlink to SonarKit.podspec in the root of the directory.
4. I changed SonarKit.podspec to use a tag-based `source`, since v0.0.1 pulls from the master branch of this repo.

The layout and network plugins still don't work with Swift - in order to fix this, we'll need to work on extracting the C++ out of their headers and writing Obj-C++ wrappers for them. I decided to push this off to a later PR since this one is quite large already.

This means that we need to be able to `import SonarKit` without importing all the network/layout plugin headers. In order to make this work, I made "SonarKit/Core" the spec's `default_subspecs`.

priteshrnandgaonkar, let me know if you have any thoughts on this implementation. You can verify that the SampleSwift app works by checking out this branch, `pod install`ing in the SampleSwift directory, and building it :)

![image](https://user-images.githubusercontent.com/1168853/41928625-ac195bd8-792a-11e8-82b8-65d6233a1fbb.png)
Pull Request resolved: #106

Reviewed By: jknoxville

Differential Revision: D8890010

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 449305bcc5cbeb5787c23f51b1ecb80a5cbdad32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants