Creating a pod that relies on another pod - ios

Trying to build a Cocoapod library which is dependant of other published Cocoapod library I own, got the project in XCode to build OK, but running pod lib lint command for checking pod validity fails with
error: include of non-modular header inside framework module on the header files of the library (pod) I'm depending on. All source is Obj-C not Swift.
I did try the following, according to the recommendations found here
Setting the header files of the dependant library as public instead of project
Setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES =
YES for each target
verifying that the relevant headers in build phases are under public.
but problem persists, I cannot publish the pod nor test it.
Update
when I comment out the
s.dependency 'OldPodIDependOn'
line in my podspec file of my new pod then error disappears but the dependent headers are not found. if I do not include the pod I depend on in the Podfile under the ./Example folder, like so:
target 'NewPod', :exclusive => true do
pod "NewPod", :path => "../"
pod "OldPodIDependOn", :path => "../../OldPodIDependOn/"
end
then project will just not build in XCode since the OldPodIDependOn files are not part of the project. Got a bit of a chicken-or-the-egg problem.
Update 2
Also tried removing the :path => "../../OldPodIDependOn/" component to reference the pod that has been published instead of a local one - doesn't help.
Worth mentioning that this pod will include a UI hence a storyboard will be included and referenced, I added s.resources = 'Pod/Classes/UI/NewPod.storyboard' line to the podspec file, and removed the storyboard from the pod target compile sources (otherwise xcode won't build). I don't think that this has something to do with the problem but worth mentioning, maybe I'm doing something wrong in there.
What am I doing wrong?
Any help will be greatly appreciated!

To finally solve this issue I had to discard the workspace that pob lib create created - there was no way around it, I tried all possible combinations / recommendations / code modifications to get rid of the "non-modular header inside framework" errors but nothing seemed to work. pod lib lint ALWAYS failed.
I created my own static library xcode project from scratch, then run pod update on it after adding the dependent pod to the Podfile, then created a .podspec file for this lib and added the dependant pod header files to the "Copy files" build phase of the static lib target + libPods.a file to the "Link Binary with libs" build phase. Poof! no more "non modular header" errors from pod lib lint, even though I am practically doing the exact same thing. Lesson learnt is that pod lib create is not recommended for ALL cocoapod cases.

I had the same issue, and I used
pod lib lint MyPod.podspec --allow-warnings --use-libraries
When adding the --use-libraries option, it worked.

In general error: include of non-modular header inside framework module implies that one of the header files inside the resulting framework ( CocoaPods lints for both frameworks and libraries now ) is not stored inside the framework, or classed as a public header.
This can usually be worked around moving external imports into the implementation files, see this Modified to support using framework #353.

Related

How can you use cocoapod framework into another cocoapod created locally?

Specifically:
Created a new project
Setup CocoaPods
To the Pod file under Pods I added a dependency (for ex.AlamoFire)
The main app which consumes the pods can import Alamofire
The local cocoapod which I created and added by using the following lines in the podfile:
target 'SomeValue' do
my_own_pod
pod 'CocoaPod_2', :path => '/LocalPath/To/PodSource'
end
Ran pod install and I added the AlamoFire Framework to the CocoaPod_2 under Pods -> General-> CocoaPod_2-> Linked Libraries & Binaries
At this point I was expecting that importing Alamofire in my CocoaPod_2 will work fine but its not.
Screenshot of the workspace :
MyProject.XCWorkspace
|_MyProject.App
|____Source Code files importing CocoaPod_1 (Embedded using CocoaPod)
|____Source Code files importing CocoaPod_2 (Embedded using CocoaPods, local Pod)
|_Pods
|____Podfile
|____Frameworks
|____Pods
|___CocoaPod_1
|___CocoaPod_1 Source Files
|____Source Code for Local Pod
|___CocoaPod_2
|____File contains statement (import cocoapod_1) <---Gives error ld: framework not found
You need to do the following two additional things:
You need to add a Podfile in your CocoaPod_2 followed by a pod install.
Also, you need to define a CocoaPod_2.podspec file in your CocoaPod_2
folder.
If you add Alamofire in both the Podfile and podspec file of CocoaPod_2, you don't need to add in the main app's Podfile. Only adding CocoaPod_2 entry in the app's Podfile will suffice.
I hope that helps!

Failed to emit precompiled header for bridging header

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’
pod ‘Alamofire’
pod ‘Kingfisher’
pod ‘MBProgressHUD’
pod ‘pop’
pod ‘EVReflection’
pod ‘StreamingKit’
pod ‘iCarousel’
pod ‘ReflectionView’
When I run the project with Xcode 9.0 beta 2, but unfortunately the error log as follows :
error: failed to emit precompiled header
'/var/folders/kd/4gh0_kxx3jx4thjb_sssmmcw0000gn/T/EvoRadio-Bridging-Header-97bd5f.pch'
for bridging header
'/Users/ringo/Downloads/EvoRadio-master/EvoRadio/Resources/EvoRadio-Bridging-Header.h'
I have googled, but no such issue.The error means it needs a PCH file?
This is my .pch header configuration:
It can't solve it.
How to make it?
I have tried all of the above steps mentioned in the answers but nothing worked for me, the problem was basically with the deployment target version for the project and in the podfile.
In my project deployment target was 10.0 while in my podfile it was 11.0.
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
Make sure you're opening the proper project workspace, otherwise, the Podfile may not have all the resources it needs to compile.
I saw this same error on a project that had been working fine previously.
I discovered that I had accidentally opened the ProjectName.xcodeproj file rather than the ProjectName.xcworkspace file. Opened the xcworkspace file and presto, project was working again!
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
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.
I had this issue just when compiling for a simulator not for a hardware device. There were two compile error like:
error: failed to emit precompiled header 'Bridging-Header-97bd5f.pch' for bridging header 'Bridging-Header.h'
Could not find ActionSheetPicker_3_0/ActionSheetPicker.h in Bridging Header (but it was declared there)
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.
XCode can build seccessful in the some target, but the other target can not.
Finally, I found that Header Search Paths is not the same. (Path: Target > Build Settings > Search Paths > Header Search Paths > add item)
I copied & pasted the path from the successful target. I made it. Bravo.
You can try this solution. I have solved the same problem by this way.
Product > Scheme > Edit Scheme > Select "Build" on Left Menu > Find implicit dependencies
Under the build tab, check 'Find implicit dependencies':
Then make a clean and build again.
In my case I had the same compiler error with additional errors like "Unknown type" in one of my project files, So I just added this to the problematic file, and it solved it instantly.
#import <UIKit/UIKit.h>
My experience with this is that Xcode is unable to find header files for pods/frameworks imported in the project.
My Project experience with this:
Updating Xcode9.2 - 9.3 where many cocoapods had to be updated due to implicit definitions now unavailable or being outdated.
I had changed the Podfile to now include 'use_frameworks!'. Following this and after dealing with other compile issues I found the error you are experiencing. I believe adding 'use_frameworks! was preventing some pods with support prior to iOS 8 from compiling correctly. Steps I took to correct this issue:
I tried deleting the Pods/ directory using cocoa pod deintegrate
I then open project with Xcode and cleaned the build folder and the project. (delete content within derived data folder)
I then pod install again but the issue persisted.
Ultimately I removed the use_frameworks line in Podfile and then repeated steps 1-3 and the project was now able to find the missing header files and the issue never presented it self again.
In my case;
Under Target/Build Settings/
Product_Name section was different than $(TARGET_NAME)
When I changed it $(TARGET_NAME), it was resolved.
In my case, I found that it was because I did not config the Framework Search Paths in Release Tab. Here is the screenshot:
After adding this path, it works.
For my case I had a typo in folder name "Supporing FIles" instead of "Supporting Files".
I also suffered from this after I updated new Xcode. After several hours of investigation, i found that if you have multiple targets, you now have to add more targets in pod file in Xcode 10. So your code should be like this:
platform :ios, '9.0'
target 'EvoRadio' do
pod ‘SnapKit’
pod ‘MJRefresh’
pod ‘Alamofire’
pod ‘Kingfisher’
pod ‘MBProgressHUD’
pod ‘pop’
pod ‘EVReflection’
pod ‘StreamingKit’
pod ‘iCarousel’
pod ‘ReflectionView’
target 'EvoRadio2ndtarget' # add your second target
end
I found that in Xcode 9 you don't need to add, but in Xcode 10 you need to add this. Hope this helps.
Deleting Podfile.lock and re-running pod install fixed this for me.
There are so many reasons and things can do, like:
Restart Xcode, Clean, Build
Remove Pods directory and pod install
Check the missing file is added to your pod file
Check the missing file is added to you bridging header
Change the header settings like here iOS - Build fails with CocoaPods cannot find header files
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 same scenario, make sure for the file A that you have included in YourProjectName-Bridging-Header.h
if it uses some other class(s), then those other classes are also included before that File A
In my case, I was building with the wrong scheme (Top-Left menu).
For Xcode 11 I had an issue with the "Security.framework". I removed this dependency, then re added it. Ultimately fixed the other problems
I got this error after renaming the existing Xcode project configuration in which I had another Xcode project imported.
To fix it, you have to rename the same configuration in the imported project as well.
Since I have been stuck in this issue for 2 working days , I would like to share my issue for you because may be future searchers are facing my problem
I was getting the mentioned error when running with command line , and I found that the command I was writing was for running .xcodeproj ,, but to run a .xcworkspace you have to write the following command
xcodebuild -workspace PROJECTNAME.xcworkspace clean archive
-archivePath build/PROJECTNAME -scheme SCHEMENAME
In my case, all was good. I had just forgotten to add '.h' in import added to the bridging header file
Was
import 'Test'
Required
import 'Test.h'
Had this error in a bit different situation. Added SWIFT file in one project from another one. Checked names of bridging headers, routes - nothing helped. The reason of the error was that I did not import some of my custom classes in the bridging header. Imported - and it worked!

'No such module' when I use CocoaPods

So here's my procedure. I create a new Podfile in the project directory, then I added the following
platform :ios, '9.0'
use_frameworks!
target 'CPod' do
pod 'AFNetworking', '~> 2.5'
pod 'ORStackView', '~> 2.0'
pod 'SwiftyJSON', '~> 2.1'
end
I fire off pod install, and everything goes well, open up the xcworkspace. I then go over to ViewController.swift and if I try to import a pod I get No such module 'SwiftyJSON', if I were to do import SwiftyJSON. Any ideas?
EDIT: SwiftyJSON is a Swift based module, not Obj-C
Try adding the Pods framework to your build scheme and building the framework. After you've built it, build/run your project.
Steps:
Scheme menu > Manage Schemes > check Pods > Close
Select Pods from the scheme menu.
Build Pods.
Select your project from the same menu, then build/run it.
You must reopen project .xcworkspace file(not .xcodeproj) after install your podfile.
Clone the repo with CocoaPods
Open YourWorkspace/YourApplication.xcworkspace
Select the app u want to run Add SwiftyJSON.framework in embedded
binaries for that project Hit Run
Happy Coding :)
You may also try re-installing pods using:
pod deintegrate
and then
pod install
This fixed this issue for me
Press Command+Option+Shift+K and then Run your app, you will see a magic.
Or from the menu -> Product, press Option on your keyboard and you'll see Clean Build Folder.
It's looking funny that how could Xcode do those things with us but same thing happened to me when I used a Swift library using Pod and after too much struggle I ended up with Clean Build Folder.
Not sure if this would still be helpful for others. But, in my case, it ended up being a silly mistake of not referencing dependencies from the .podspec file.
We have an application with multiple internal libraries, and those libraries also have dependencies on each other - which we accounted for the in the Podfiles... but NOT in the podspecs.
So, even though our Podfiles had:
Application / Podfile
# Development Pods
pod 'ConsumingLibrary ', :path => '../ios-consuming-lib'
pod 'DependentLibrary1', :path => '../ios-library-one'
pod 'CommonCoreLibrary', :path => '../ios-common-core-lib'
ConsumingLibrary / Podfile
# Development Pods
pod 'DependentLibrary1', :path => '../ios-library-one'
pod 'CommonCoreLibrary', :path => '../ios-common-core-lib'
Needed to also call it out in the .podspec's:
ConsumingLibrary / ConsumingLibrary.podspec
# TODO
# Add here any resources to be exported.
s.dependency 'DependentLibrary1', '~> 0.1.0-RC'
DependentLibrary1 / DependentLibrary1.podspec
# TODO
# Add here any resources to be exported.
s.dependency 'CommonCoreLibrary', '~> 0.1.0-RC'
I think I wasted about 2 hours trying to figure out why I could build ConsumingLibrary & run tests, but as soon as I built the app, that consumed all three libraries - I kept getting:
No such module 'DependentLibrary1'
In my case it was because I opened xcodeproj instead of the correct xcworkspace.
Had this issue, too. I noticed the folder in Pods/broken_framework_name for framework which produced an error was empty even after pod install or pod update. So, for me those steps helped:
close XCode completely
remove DerivedData
remove Podfile.lock. Before doing it, make sure your pods are set to specific versions and it will not cause unwanted code updates
run pod deintegrate
remove .xcworkspace file
probably optional step: I had general line use_frameworks! written before all targets, but included it also in target in which I had an error
run pod install
After all steps I noticed missing framework files finally appeared back and build was working again.
Try using pod update after pod install command which will solve problem of No such module.
I just tried and it working fine.
Thanks,
Ratneshwar
Those who working with multiple targets , please don't forget to add this line in pods
def shared_pods
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
end
target 'Target_Name' do
shared_pods
end
target 'Target_Name_Two' do
shared_pods
end
Sometimes happens when you have an obj-c pod within a swift project (even when you use the use_frameworks! in the .podfile).
If you're sure the pod is installed and you are still getting No such module, try this:
Go to Pods project in Xcode
Pods
Right click on the affected pod
Show in finder
There should be a package file with .framework suffix. Create a folder Modules in it. In this folder create a file called module.modulemap with code:
framework module MODULE_NAME_HERE {
umbrella header "MODULE_NAME_HERE.h"
export *
module * { export * }
link framework LINKED_FRAMEWORKS_AND_LIBRARIES_THE_POD_NEEDS_HERE
link framework "AdSupport"
link "c++"
link "z"
}
Rebuild and you should be ok.
As #jakub-truhlář wrote, the root issue is the missing module.modulemap file due to some concurrency issue mixing Swift and Objective-C libraries, but instead of creating those files manually, would be better to try multiple times cleaning the Derived Data and build your project. When the project is successfully built then commit module.modulemap files to your repository to avoid to lose those files for example changing the current branch.
I faced the same problem in a swift framework I developed. The framework had a dependency of git project and the framework itself added as a pod to my main project. So, ideally the dependency has been specified in podspec file and Podfile as well.
I didn't faced the problem when accessing through the my main project but when I open the framework standalone it was throwing "No such module" error.
The root cause is, the base configurations is set with the path which points towards my main project instead of the framework itself because I ran podinstall first in my main project and then in the framework project.
Eg: in the project file it was like
0091AB0C861D71C94ADD7240 /* Pods-myframework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myframework.release.xcconfig"; path = "../../Apps/MyMainProject/Pods/Target Support Files/Pods-myframework/Pods-myframework.release.xcconfig"; sourceTree = ""; };
After doing the below mentioned fix,
4444F5B1B35F066E57F96782 /* Pods-myframework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myframework.release.xcconfig"; path = "Pods/Target Support Files/Pods-myframework/Pods-myframework.release.xcconfig"; sourceTree = ""; };
To fix the error,
Project file -> Configurations -> Set all the configurations set to
none.
Remove Pods folder and Podfile.lock.
Run 'pod install' first in the framework project direcory and then do pod install in main project directory.
I get some warning when pod install: '... target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in ...'.
Fix it and enjoy.
Reference: target overrides the FRAMEWORK_SEARCH_PATHS build settings.
Another way this issue can manifest: if you have multiple targets with different platforms (e.g. iOS and watchOS) you need to make sure your podfile specifies the correct platform for each target. Otherwise Cocoapods might be building the right pod but for wrong platform, leading to the "no such module" error.
You can fix it just by specifying the correct platforms e.g.
# global platform
platform :ios, '11.0'
target 'My Framework' do
use_frameworks!
pod 'RxSwift', '~> 5.1'
end
target 'My Framework (watchOS)' do
# override global platform for this target
platform :watchos, '4.0'
use_frameworks!
pod 'RxSwift', '~> 5.1'
end
i fixed it by check "Find Implicit Dependencies" to true.
Go to Edit Scheme -> Build Tab -> set Find Implicit Dependencies = true.
and rebuild.
Adding link "c++" in the framework module.modulemap file worked for me
I had this problem when I opened XCode and then selected the workspace of my project via file->open recent.
I found that I had two .xcworkspace files on my filesystem for the same workspace/project.
Opening XCode by double clicking on the correct .xcworkspace file did the trick.
The correct one is the one that works.
I later deleted the wrong one.
I just updated particular dependencies in terminal
Go to project folder then run below command
pod update your pod name
For me I need to do
pod update ReachabilitySwift
Had this issue while adding CocoaPods into an old project, which already had manually included libs from before. It happened because Xcode was not resolving to the Framework Search Path generated by CocoaPods because of values previously set in target's settings.
Solution that helped me:
copy the old path
hit delete to completely clear the Framework Search Path settings in the target's column - the path, generated by CocoaPods would appear there
add the old search path back under the generated one (only needed if you still have some manually added frameworks to work with)
Clean project, wipe Derived Data, build.
The result would look like this (1st line added by Xcode, 2nd added by CocoaPods, and 3rd is manual):
In case of multiple targets.
For eg. Target1, Target2
use_frameworks!
target 'Target1' do
pod 'Fabric'
pod 'Crashlytics'
target 'Target2' do
end
end
Then run pod install.
I tried all of these suggestions but nothing worked for me. Instead what'd worked for me was deintegrating pods. Afterwards deleting the pods folder from xcode hierarchy and doing pod install. Suddenly it worked. Don't ask me why because anyways most of these suggestions are hit or miss anyways but I'll be happy if it works for someone else too :)
Make sure to import correct framework name that is defined in .podspec of the pod.
I usually remove Pods folder and .xcworkspace file, then I run pod installagain and it helps in almost 100% cases.
My setup
macOS 10.14 Mojave
Xcode 10.3
cocoapods 1.7.5
None of the answers work for me, although some gave partial clues. In my case, the root cause was that I customized my build product paths after running pod install.
If you run cocoapods right after creating an Xcode project, then it usually works if you open the generated Xcode .xcworkspace instead of the .xcodeproj.
Funny things happen if you start tweaking your build product paths after generating the workspace. Because the generated Pods project and its target all refer to your old Xcode project settings.
In my case, my trouble came from:
I prefer all my build products sitting under the project folder $(SRCROOT)/build/$(CONFIGURATION)/$(EFFECTIVE_PLATORM_NAME). So I went ahead and changed my Pre-configuration Build Products Path to it .... AFTER doing pod install.
Now, the generated Pods project, including all its Framework target, still points to the old location, so both the header import and linking of your own project will fail (you'd see Command PhaseScriptExecution failed with a nonzero exit code when No such module is fixed).
The fix:
Delete all Pods stuff including the workspace.
Regenerate Pods project and workspace with pod install. However, cocoapods hardcodes the build product path to ${SRCROOT}/../build and Pre-configuration Build Products to $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) in my case, which usually points to a temporary ~/Library/Developer subfolder . Still not quite right. Then ....
Make sure the Framework Search Path and Header Search Path of my own project cover the above paths.
Tweak Pods project setting and all dependency Framework's Pre-configuration Build Products Path to use my preferred paths.
The moral lesson: Always regenerate Pods and verify the key result paths whenever you touch paths in Xcode project settings.
UPDATE
With Xcode 11, Apple finally removed the confusing "Pre-configuration Build Products Path". To customize the build product paths, use Locations in Xcode preferences with global relative paths pre-baked.
If you see this warning:
[!] The `Joint [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-Joint/Pods-Joint.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Joint [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-Joint/Pods-Joint.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
follow the instructions to avoid Module not found issue.
For me, removing the following from my podFile fixed it:
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
clean project
close xcode
open xcode
enjoy
For using Swift in Objective-C, you should import a header file that Xcode generates automatically in compile time (NameOfModule+Swift.h). In this case, you should try import SwifityJSON in you header file like this:
#import "SwiftyJSON-Swift.h"

Using cocoapods in a framework

I created an iOS framework that uses a library (RestKit) via CocoaPods.
In the application project that uses my framework I also use CocoaPods to include other libraries. I had to include the library from the framework as the project didn't compile otherwise.
Everything works fine, but as expected when I launch the application I get:
Class X is implemented in both /private/var/mobile/Containers/Bundle/Application/[...]/Application.app/Frameworks/Framework.framework/Framework and /private/var/mobile/Containers/Bundle/Application/[...]/Application.app/Application. One of the two will be used. Which one is undefined." in several classes from the libraries.
Is there any way in CocoaPods or in the build process to prevent having duplicate libraries when they're already being used?
Some more context to my question. Here's what I did:
Created a framework project as a Cocoa Touch Framework. Initially I added just a Podfile with a dependency for RestKit as following:
pod 'RestKit', '~>0.23'Then I removed the Podfile and just added a podspec as in the comment by #Paula Chavarría.
Created the app project. Added a Podfile with other dependencies and also the dependency to the framework as #Paula Chavarría also mentioned.
When I build the app project the framework fails building because it can't find the right headers.
I changed the header search path for the framework but it doesn't seem to be enough for the build to be successful.
Do I need to have also a Podfile in the framework? As I said in my original question, I did that at first and I ended up having duplicate libraries and that's what I'm trying to avoid in the first place.
Is there any way to tweak the Podfile or the configurations generated by it and use the headers in the app and link with the libraries in the app?
What am I missing here?... Thanks in advance! :)
If you are using Cocoapods on the application project you can create a private pod for the iOS framework. To do so you have to create a .podspec file in order to add the conflicting dependency. For Restkit the .podspec file would be like this:
Pod::Spec.new do |s|
s.name = "MyFramework"
...
s.dependency 'RestKit', '~> 0.23'
end
You can read more about these files here: http://guides.cocoapods.org/making/specs-and-specs-repo.html
After that you just have to add a dependency of your framework on the application project Podfile. You can do so through a local path or through a version control system.
pod 'MyFramework', :path => './../my-framework'
pod 'MyFramework', :git => 'https://url/to/my-framework.git', :tag => '0.0.1'

Cocoapods Warning - CocoaPods did not set the base configuration of your project because because your project already has a custom config set

After I execute a pod install at the base of my project, I get the following error:
CocoaPods did not set the base configuration of your project because because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target BluePlaquesLondonFramework to Pods/Target Support Files/Pods/Pods.debug.xcconfig or include the Pods/Target Support Files/Pods/Pods.debug.xcconfig in your build configuration.
This probably sounds like a silly question, but how do I set the base configuration for a target?
https://github.com/seanoshea/BluePlaquesLondon/blob/ios8/Podfile is the Podfile which is causing this issue.
http://github.com/seanoshea/BluePlaquesLondon on the iOS 8 branch is the Podfile in question if you're curious to see what the project looks like.
I had the same problem, but in Xcode 6.1.1 - what fixed it for me was to change the configuration file setting to None for the two Pods-related targets, then run pod install again.
The configuration file setting is found by selecting the project (not the target) and then the Info tab.
Don't tinker, Reset.
Step-by-step
Show Project Navigator
Select Project
Select Info
In Configurations, select each one, one at a time (Debug, ApplicationUnitTest, Release, etc.), and for each target within said configuration, set configuration to None.
Make certain that Based on Configuration File reads 0 Configurations Set or No Configurations Set for each configuration. That is the crux.
Quit Xcode
rm -rf Pods/ Podfile.lock ; pod install
Once you have allowed pod install in step 7 to do its magic, you may be able to use a custom config and change your configurations.
Go into XCode and open your project settings and under the Info tab, you will see "Configurations" where you can set a configuration file for both Debug and Release. You apparently have already set these to some custom config and CocoaPods wants/needs you to use the Pods config.
Ran into the same problem. It would build on the simulator but not on my device. None of the answers solved this for me. Here's what I did piecing some answers together:
Changed my pods file to use a specific target:
target :MyProject do
pod 'AWSCognitoSync'
pod 'Facebook-iOS-SDK'
end
Ran pod install
That gives an error:
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `MyProject` to `Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug.xcconfig` or include the `Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug.xcconfig` in your build configuration.
Go Project settings and click on Info tab. There will be an error where it cannot find the Configuration file. Set it to "None" for Debug and Release.
Run pod install yet again
Clean and build. This works.
I fixed my issue after a careful reading of the error message:
[!] CocoaPods did not set the base configuration of your project
because your project already has a custom config set. In order for
CocoaPods integration to work at all, please either set the base
configurations of the target Runner to Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig or include the Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig in your build
configuration (Flutter/Release.xcconfig).
Solution
Open Xcode and change the Runner Info Base Configurations to the
related Pods-Runner.profile.xconfig.
Quit Xcode
Terminal: From the ios project folder run pod deintegrate
Verify pods are removed
Project has been deintegrated. No traces of CocoaPods left in project.
Note: The workspace referencing the Pods project still remains.
Terminal: From the ios project folder run pod install
(from this original - BAD)
(to this GOOD settings)
Notes
I have not been able to resolve the issue using the second
suggestion of including the xconfig file inside of the
Flutter/Release.xcconfig configuration file as mentioned in the
error message.
You should also make sure that you have no pods in the root of Podfile, you should define all the pods that are used in many targets like that:
def shared_pods
pod 'ReactiveCocoa', '~> 2.5'
end
target 'app' do
shared_pods
pod 'RestKit'
end
target 'tests' do
shared_pods
pod 'OCMock'
end
You also might need to delete libPods.a and libPods-app.a from the target dependencies, perform a clean and then run pod install again.
For those coming from the Flutter world, this is a misleading error message suggesting an unnecessary action, and the correct course is to ignore the error and use the flutter cli (not pod), as discussed in https://github.com/flutter/flutter/issues/73845:
gatzsche says a better message would be:
In Flutter pod install should not called manually. To run pod install
execute the following commands flutter clean, flutter pub get and
flutter build ios.
jmagman notes:
As you point out, the error message is suggesting an action that isn't necessary. The flutter command suppresses that message from pod. You ran pod directly, which isn't a recommended workflow. We don't have any control of error messages coming from CocoaPods, and the flutter command line tool already suppresses the confusing message.
I just ran into this issue after adding some custom build configurations. I could see under:
Pods (target) > Target Support Files > Pods
that it had actually created the new xcconfig files that matched the new build configurations but for some reason I could not select these in the project target of my app.
What fixed it for me was to install and use cocoapods-deintegrate:
gem install cocoapods-deintegrate
and then run:
pod deintegrate
followed by:
pod install
In case you are using custom config you can follow the suggestion in the warning and include the Pod config in your config file
#include "Pods/Target Support Files/Pods-YYY/Pods-YYYY.develop-archive.xcconfig"
This will NOT stop the warnings but will allow you to use your private config (there is an open bug on the warning with CocoaPods project)
https://github.com/CocoaPods/CocoaPods/issues/2633
If you added a custom build configuration to your existing project, Cocoapods will complain about it.
Cocoapods will automatically create xcconfig files under the directory Pods/Target Support Files/<build_target> following the naming pattern Pods-<build_target>.<build_config>.xcconfig.
Just make sure to manually add those files to your project in Xcode (under the Pods directory, but not inside the Pods project!). Once those files are included select your project in Xcode, go to the "Info" tab, and expand your custom configuration. Select the appropriate xcconfig file for each target under your custom configuration.
The line in the podfile that is generating a problem is : link_with ['BluePlaquesLondon', 'BluePlaquesLondonFramework'].
Just make this : link_with ['BluePlaquesLondon'] or this (worked in my case, hope it will in yours :-)) :
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
xcodeproj 'BluePlaquesLondon.xcodeproj'
inhibit_all_warnings!
link_with ['BluePlaquesLondon']
def import_pods
pod 'TTTAttributedLabel', '~> 1.10.1'
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.9'
pod 'Google-Maps-iOS-SDK'
pod 'IntentKit'
pod 'HCViews'
pod 'SVProgressHUD', :head
pod 'iRate'
pod 'iOS-KML-Framework', :git => 'https://github.com/FLCLjp/iOS-KML-Framework.git'
end
import_pods
target "BluePlaquesLondonFramework" do
import_pods
pod 'Kiwi'
end
I had the same error while pod install. I tried everything (reinstall pod, update all gems, etc.) and I found solution worked in my case. There was problem because of changing target's name. In this case solution is simple:
Click Product -> Scheme -> Manage Schemes...
Click on your target on the list and delete it with "-" sign on bottom of window.
Click "+" to add target back to list. Choose correct target and name.
After all everything should works.
I moved pods in Podfile outside from the target. File changes from this:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'MyProject' do
pod 'Firebase', '>= 2.5.0'
pod 'Onboard'
pod 'GoogleMaps'
pod 'IQDropDownTextField'
end
To this:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
pod 'Firebase', '>= 2.5.0'
pod 'Onboard'
pod 'GoogleMaps'
pod 'IQDropDownTextField'
target 'MyProject' do
end
Add the relevent xcconfig files to your project. Cocoapods will have created them but you can't set them in Xcode until they are in the project.
You probably want to add them to the Pods group where the other pods xcconfig files are. Right click and add files.
Search for xcconfig files in your project folder or look in Pods/Target Support Files/[TARGET_NAME]/ (I have different cocoapods configured for each target (extension and main project this may be slightly different in your case)
Go to project configurations in the Info of your main project
For each target and configuration set the appropriate pods configuration.
pod install again and you should see no errors.
So for me, the problem was due to the aforementioned xcconfig files names being changed before the Swift 3 update took place.
Something was out of sync, so Cocoapods created a 'Recovered References' folder section with the old named files, and linked to them.
To fix this, I:
Removed the 'Recovered References' folder and the containing old
.xcconfig files from Xcode and file system
Quit Xcode
Run pod install
Everything was handled for me after then, and the warnings were gone.
I was able to build the project touched by this issue on XCode 6 by:
selecting Project from the Project Navigator
choosing Project instead of Target
going to Info tab
choosing Pods.(debug/release) Configuration Files from the combobox for the respective Configurations.
Hope this will help someone.
This happened to me because I already had a Pod configuration. I'm new on iOS development, was searching instructions to install Alamofire + SwiftyJSON and ended up installing the libraries more than once, inadvertently. To me, what worked was: on the folder "Target Support Files" in "Pods" project, I selected the two correct .xcconfig files and dragged them to the "Pods" folder of my app project. This enabled the selection of the correct config files on the base configuration.
But then, if I run "pod install" again, the warning will change to the previous .xcconfig file. I try to delete the files and the old framework from the main project but when i ran the previous command once more, gave me the same warning, and created the file "Pods.framework" under the "Pods" folder of my app project. I ignored it, and it seems to be running ok, despite the two frameworks. I don't know if it's right, and a solution, if exists, it would be welcomed.
I had error:
diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock.
I just checked the path where I was installing the pod and corrected it and installed again,It just worked.
Make sure give the path just before where .xcodeproj or .xcworkspace (if it is already there) exists.
Sorry my previous answer was unclear. This was just one of many errors i've got while trying to set up Cloud Firestore, so this answer is specific for that situation. In order to solve this error and make firebase work, eventually, you have to follow all of the steps from this page: https://firebase.flutter.dev/docs/firestore/overview/ . If you are having problems with generating the 'firebase_options.dart' file, then you need to follow the steps on this page: https://firebase.google.com/docs/cli#mac-linux-auto-script . The last step is optional, but it reduces build time, and I really don't know how or why, but it made some of other errors also disappear... Step 4. Improve iOS & macOS build times, from this page https://firebase.flutter.dev/docs/firestore/overview/. And off course, don't forget to add dependencies in pubspec.yaml: https://pub.dev/packages/firebase_core/install . There is also a great comment here about using Firebase.initializeApp() : https://stackoverflow.com/a/63492262/17626190
Seems a good ole system restart and probably more importantly it seems I had to reinstall cocoa pods even though the CLI seemed to be in perfectly working condition and had been working for many days before today.
Reinstalled CocoaPods 🤷
sudo gem install cocoapods
It doesn't seem this was the fix for anyone else, but I figured I should post it since this was driving me nuts, and hopefully it helps at least one other person.
This is the messages I got after running pod install or pod update:
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.debug-staging.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.debug-staging.xcconfig` in your build configuration (`Flutter/Debug.xcconfig`).
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.release-staging.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.release-staging.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile-staging.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile-staging.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
This is what I did to solve the issue:
Add Schemes to Podfile under project 'Runner'
project 'Runner', {
'Debug' => :debug,
'Debug-staging' => :debug,
'Profile' => :release,
'Profile-staging' => :release,
'Release' => :release,
'Release-staging' => :release,
}
Go to ios/Flutter/Debug.xcconfig and include
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-staging.xcconfig"
Go to ios/Flutter/Release.xcconfig and include
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release-staging.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile-staging.xcconfig"
flutter clean
Delete podfile.lock
Pub get
pod install
Just follow the Android Studio instructions.
This is the error output:
"[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`)."
In android studio IDE go to IOS folder/Flutter and open the file Release.xconfig
Then just past this line:
Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig
Delete podfile.lock and try to rebuild in Xcode. Worked for me.
The simplest solution for this (after having this issue multiple times):
Delete Podfile & Podfile.lock from your project library (save Podfile somewhere so you could easily paste to new Podfile)
run 'pod init'
Edit the 'Podfile' to your will (add pods you are using)
run 'pod install'
This would recreate everything and works always in minutes (not spending time to reverse engineer the "bug").

Resources