I downloaded a project from GitHub, then pod the following files, some of which are written by OBJ-C and I used a bridge header.
pod ‘SnapKit’
pod ‘MJRefresh
For me, this problem occurred when I added new build configuration and scheme to the existing project.
The solution was to run pod install
on newly created scheme. After that, project was built successfully.
Note this can also happen if your bridging header imports Objective-C code that itself imports your app's Swift module via myproject-Swift.h
. The solution is to use forward declarations for your Swift types and import the project Swift module in the .m
file.
@class MySwiftClass
or...
typedef NS_ENUM(NSInteger, MySwiftEnumType)
MySwiftEnumType
is the lowest level name even for classes. So Swift enum MyClass.MySwiftEnumType
becomes just MySwiftEnumType
In my case;
Under Target/Build Settings/
Product_Name section was different than $(TARGET_NAME)
When I changed it $(TARGET_NAME), it was resolved.
There are so many reasons and things can do, like:
The only one works for me is the accepted answer in Xcode 9 - failed to emit precompiled header.
platform :ios, '11.0'
in podfile should match the target in the project
I had this issue just when compiling for a simulator not for a hardware device. There were two compile error like:
After hours of research and try and errors it turned out, that there was no valid architecture set in the project to compile for simulators.
At Project -> Build Settings -> User-Defined -> VALID_ARCHS
add the architecture x86_64
to enable compilation for simulators.
I also got exact same issue (Xcode9 beta 6) after I added cocoa pods for Encrypted Core Data.
This is my PodFile
:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
target 'Root' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Root
target 'RootTests' do
inherit! :search_paths
# Pods for testing
end
target 'RootUITests' do
inherit! :search_paths
# Pods for testing
end
end
Solution:
1 I added $(inherited) non-recursive
to Search Path -> Header Search Paths
2 Then added ${PODS_ROOT} recursive
to Search Path -> User Header Search Paths
Both the above in my projects' target build settings.
Please have a look at these SO answers:
1 Inherit Header Search Paths
2 Inherit User Search Paths