Updating pods (Charts) to the latest Swift syntax - objective-c

Currently I am using Charts pod in my Objective-C project, so I had to open it today in Xcode 8.1 and of course, I got this message:
This wouldn't be a problem if it was my code, but we are talking here about pods. So, what would be the proper way to handle this warning and switch to Swift 3 syntax for this pod?
What I have tried:
I have run pod update command, and updated it hopefully to the latest version...Still, I am getting the same message when I open Xcode. This is my Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.2'
pod 'Charts', '~> 3.0'
use_frameworks!
target 'drivingCOACH' do
pod 'Charts', '~> 3.0'
end

The Charts pod is documented on https://cocoapods.org/pods/Charts.
Current version (at the time of the question) is using Swift 3.0. So when using it, all your dependencies must be using Swift 3.0 too (you can't mix dependencies of different Swift versions when using Frameworks, which is currently a mandatory requirement).
You could manually change build settings to specify that each pod target is for Swift 3.0 (by setting "Use legacy Swift" value to NO). But because your project is in Objective-C, you may end up to do this operation each time you run pod install.
To avoid that trouble, you can extend the installation script of your Podfile to include those lines, and it will perform exactly the same as above on your next pod deintegrate && pod install:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
Those lines won't be needed anymore the day you decide to integrate some Swift code to your app, because CocoaPods will then match the dependencies Swift version to what you are using.
Also, you may need to delete your Derived Data folder (~/Library/Developer/Xcode/DerivedData by default) while Xcode is closed if you face some cache issues.

Related

Xcode 12, How to suppress "Double-quoted include in framework header" warnings throughout entire project

With Xcode 12 there is a new default warning which will throw a warning anywhere you #import or #include with "quotes.h" instead of <brackets.h>.
Warning: "Double-quoted include in framework header"
How do you turn off this warning for the entire project?
I think a simpler way is to go in the project's Build Settings a just set the option Quoted Include In Framework Header to No :
You can disable these warnings for your entire project by navigating to your project's "build settings", finding the field "other linker flags" and adding the following flag:
-Wno-quoted-include-in-framework-header
Looks like this issue is fixed as part of Cocoapods 1.10.1 (not officially released, as of this writing). However, you can use Cocoapods version 1.10.0.rc.1 temporarily until 1.10.1 is officially available.
gem install cocoapods -v '1.10.0.rc.1'
Another option is to update your Podfile (add below code) to disable the warning flag CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER setting for all pods in your project.
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = 'NO'
end
end
end
end

Why do we need to use target "PROJECT_NAME" do from what version of cocoapods / xcode

Recently in my new MACI've installed cocoa pods 1.2.1 i ran "pod update" in my projects Folder to update to the newest Version.
The result of the update is:
The dependencyFlurrySDKis not used in any concrete target.
I've fixed the problem by adding pod like this
target "PROJECT_NAME" do
pod 'FlurrySDK'
end
But Just for curiasity...
I want to know from which version of XCode / Cocoapods we need to add this line
target "PROJECT_NAME" do
and Why
Can some one please clarify on this
Your pod file will be like this,
it is necessary to add your project name as "target".
Consider this code:
# 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 'PROJECT_NAME' do
pod 'FlurrySDK'
end
I hope it will help you, because i always add this for adding pods.
i think it is not XCode version based.

ld: library not found for -lGoogleToolboxForMac

I am implementing firebase setup via pods.
My Pods file looks like following one.
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'
# $(PROJECT_DIR)/build/Debug-iphoneos/GoogleToolboxForMac lib search path
target 'ProductName' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for mCura
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
Everything is fine with iPad simulator. its running but when I run my application in iDevice. It shows library not found.
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have already wasted 2 days for removing this error & tried everything I could find on net. And GoogleToolboxForMac library automatically installs when firebase pod get installed.
I change my pod file to following code and re-install pod. It installed all necessary files for GoogleToolboxForMac.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'ProductName' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'GoogleToolboxForMac', '~> 2.1'
end
After Installing pod
1) Change Scheme to Generic iOS Device and Build.
2) After build success you can see libGoogleToolboxForMac.a file in black colour instead of red.
3) Now select Device and run build on iDevice. Follow screenshot.
Or you can have build library libGoogleToolboxForMac.a
I was also getting this exception:
It fixed after opening the /platform/ios folder in Xcode instead of /platform/ios/MyApp.xcodeproj file.
I got the same error and it was fixed just by opening the project from the .xcworkspace file instead of the .xcodeproj.
Sigh.
For my Cordova project I just removed plugins, platforms and node_modules, readded IOS, and double clicked instead of using alt-down to open the xsworkspace and suddenly it magically worked.
Posting this here so I remember that it might be unnecessary to look for a real solution.
This StackOverflow question: Framework not found GoogleToolboxForMac had the answer that fixed this for me, but it was not the most highly upvoted answer. I had to go to the build settings for the GoogleToolboxForMac target and change the "Build Active Architecture Only" setting from Yes to No. Then clean and rebuild.

Xcode clang error when adding SDWebImage framework

I am trying to compile an app that use SDWebImage, when I add the framework to xCode I keep getting the following error.
I have attempted to add the framework by clone the git repo
ld: framework not found SDWebImage
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Linking in Xcode requires a bit of work. We can tell what to do or suggest a better way. As I consider "dropping framework" solution a very bad habit, I'd strongly suggest a better way:
Use dependency manager!
This will help you to see whenever your dependencies get new updates. You'll also know which version are you using. This is a good practice.
You can eg use Cocoapods. Go to your Terminal, type:
$ sudo gem install cocoapods
Then go to your project folder (place, where you have xcodeproj) and type:
$ pod init
This creates a file named Podfile. Open it and paste:
platform :ios, '8.0' // or whatever you need
use_frameworks!
pod 'SDWebImage', '~> 3.7'
So when you have it ready, open Terminal and type:
$ pod install
From now you should work on xcworkspace instead od xcodeproj. Your dependency should work correctly.
BTW: There are many other solutions. You can simply use git submodules. You can also use Carthage. However most popular and as for me atm most convenient way is Cocoapods, so I wrote steps for this way.
You've added SDWebImage as a linked framework.
What you should be doing is adding it as an Embedded framework, and make sure that your build phase copies the framework into your app bundle.

Cocoapods podspec dependency import file not found

I'm trying to make a Cocoapod that depends on another but I'm having issues at compile time. Say in this case MyApp is using CocoapodA and CocoapodB, B relies on A.
MyApp Podfile:
platform :ios, '5.0'
pod 'CocoapodA'
pod 'CocoapodB', :path => '../../CocoapodB'
CocoapodB Podspec:
s.dependency 'CocoapodA'
but when I try to compile I get 'CocoapodA/CocoapodA.h' file not found where the import in CocoapodB is trying to include it.
I've tried reading the Podspec documentation but I didn't really get what I'm missing. I also tried s.library = 'CocoapodA'.
Make sure that you correctly specify header files for CocoapodA, for example:
s.public_header_files = 'CocoapodA/**/*.h'
My problem ended up being that the OTHER_LDFLAGS were being overridden. After selecting the Other Linker Flags key (build settings) and pressing backspace it now builds.
Weirdly I can only build on actual device; both simulator and archive are failing. They're probably caused by something else.