iOS Project Pods have conflicting folder name - ios

So i'm using these two pods in my project:
pod 'Google/SignIn'
pod 'MSOutlook-SDK-iOS'
To my delight, they both have dependencies that use a Core.h file. I believe i am running into issues that cause a File Not Found for one of the pods because it is looking for a file in the wrong header!
I guess I can make the import explicit, aka changing:
core.h/NSArray+Utils.h
to
orc/core.h/NSArray+Utils.h
But I don't want to do that bc of two reasons:
These pods get updated from time to time, and might introduce new files/overwrite existing changes
There are about 350 files I need to do that to.
Any ideas on how to resolve this? Possibly some renaming or settings change?
Thanks!

This purported error has claimed to been fixed in Cocoapods v1.0 and above.
From github:
"This ought to be fixed in CocoaPods 1.0 if you use bracket imports."

Related

All Pods not recognized after starting the process of adding to app store 'No such module' error

My app worked just fine until I started the process to upload to the app store and somewhere during that process, I started getting the error 'No such module'.
I have tried different pods, same result
I have tried a new blank project with just the import line (after importing the pod), same result
After eliminating the pod it self and the project, it has got to be a setting that got changed that won't allow it to see the pod files. If anybody has any thoughts, I would be greatly appreciative.
*edit: Taking Dershowitz123's advice, I have tried changing the path for the frameworks to
$(SRCROOT)
screenshot1 (sry, I don't have the reputation to post embedded images yet).
I still get a failed build, but I think you are in the right direction. I noticed that it isn't finding the framework file.
screenshot2
I've looked for the file listed and I don't see one in the directory anywhere. When I made my blank test project, it also didn't create a Pods_RiskAssement.framework file (or similar named file).
*edit 2
here's my Podfile:
# 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 ‘RiskAssement’ do
pod ‘SimplePDF’
end
*edit
Resolution. I was unable to figure out how to import the pod, but was able to copy the swift file data and embed it directly into the code for my app. This way I didn't need to reference the pod and was able to build the app.
I'm not sure why this is actually happens, but one way to solve your issue is to go into your build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
I recently received the same 'No such module' message for the different PODS that I had installed. The resolution for me was to select the PODS project in my workspace, select all of my targets, and then manually build them using either the menu command or the Command B shortcut. After it finished building the errors went away.
I hope it helps!

Xcode 7.3 Syntax Highlighting and Code Completion issues with Swift

I am having an extremely frustrating issue with XCode 7.3 (however, this issue has persisted since I installed XCode 7.2) and Swift code, and I am hoping others have had this issue and know how to resolve it. Syntax highlighting and code completion work perfectly fine in Objective-C files, and also works fine when calling other Swift objects within Swift code. However, any Objective-C objects or methods mentioned in Swift code get no syntax highlighting, and XCode will not complete ANY Objective-C declared methods or properties. Everything compiles and runs just fine.
I should also add that I have also tried doing a completely clean install of XCode. I deleted all my derived data, deleted all XCode caches, and deleted my XCode preferences files (in addition to obviously deleting the XCode.app archive before re-installing).
It is making it extremely difficult to develop in Swift. I don't want to do this, but if I can't find a way to resolve this I'll be forced to go back to using Objective-C.
I have the same problem. But finally solved it.
I make two change, not sure which is the key point but you can try them all.
delete the module cache
Within the same folder as your project's Derived Data is a Module
Cache. When Code Completion stopped working, deleting this fixed it.
Close Xcode and delete the
~/Library/Developer/Xcode/DerivedData/ModuleCache directory.
change the Enable Modules value
Go to the Build Settings of your target, then search Enable
Modules
If it's Yes, change it to No, and you may get some build
error, just change it back to Yes.
After two steps above you should Clean(Shift+Command+K) your project.
For now you may fixed the problem.
So it seems the issue was with CocoaPods. I was using Cocoapods as a static library instead of as frameworks. Switching to frameworks (using use_frameworks! in my Podfile) and importing the libraries into Swift has resolved all my issues. I'm guessing all those third party library headers were just too much for XCode to process. Either way, the issue is now resolved. I hope this helps someone in the future.
This might not be necessary anymore but i still want to post this:
At the time of this post, the most recent version of cocoapods (1.0.0.beta.8) requires you to define pods for each Xcode target.
In my case I had a class compile for the project target and for a testing target. I added a pod only to the main target, because of laziness.
Now working in the code of class A I added the pod framework using import NAME and tried to use the classes of the framework. Xcode wouldn't highlight the particular code where I use the new classes, but compiling and running works fine. In the completion dialog the type of the variable was <<error type>>
The way to resolve this issue: in the Podfile add the newly added pod to all targets, the class A is member of.
Now Xcode finds the necessary frameworks for all targets and code highlighting works again.
EDIT 1:
A possible solution is defining a list of shared pods, like in my example:
platform :ios, '8.4'
use_frameworks!
inhibit_all_warnings!
def all_pods
pod 'MPMessagePack'
pod 'SwiftyDispatch'
pod 'BFKit'
pod 'Timepiece'
pod 'Alamofire'
pod 'AlamofireSwiftyJSON'
end
def testing_pods
pod 'Quick'
pod 'Nimble'
end
target 'App' do
all_pods
end
target 'AppLogicTests' do
all_pods
testing_pods
end
target 'AppUITests' do
pod 'RxTest'
all_pods
testing_pods
end
post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
This will add all pods to all targets and adding all testing pods to the targets. Next to these I added 'RxTest' to the AppUITests.
(Chosen pods are examples of my projects, no advertising intended :-) )
We had the same issue in a mixed ObjC/Swift project. Tried all the suggestions about deleting derived data etc, to no avail. Sometimes it helped, but not in a reproducible way and after some time it stopped working.
The post of Galvin in this post put me on the track of the Module related build settings. However it was another setting that solved the code completion/coloring in a reproducible way: setting DEFINES_MODULE (under Packaging) from YES to NO for our main project was the solution.
Notes:
I expected this to break the ObjC/Swift interoperability in our project, but that still works. It seems that setting is only to be used for framework targets. (https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html)
This project setting has not been changed for months, but the code completion issues came up only recently, both for my colleague and me.
If none of the above worked for you and you're using Cocoapods, you can try switching to Carthage.
I tried every suggestion I could find on Google to no avail. But consistently Cocoapods seemed to be coming up as a reason with many hacks in attempt to fix it. I have been reading up on Carthage, and how it doesn't modify your project, force you to use a workspace, or potentially fill your build folder with header files (which confuses Xcode and can cause the syntax highlighting and autocomplete to break).
After making the switch I haven't run into any issues yet, and to be honest I prefer the teensy bit of overhead to have a clean solution. This post really drove it home for me.

Private pod with static library in along with swift pod

I'm working on pods development for an iOS dev team (on private repo). My low-level C/Obj-C core pod contains a static library with some headers and is used as dependency in other pods (pushed with --use-libraries).
Now that the iOS team wants to integrate Swift pods, they had to add the use_framework! option in the Podfile of their projects. Of course, they obtained the following error during pod install :
The 'XXX' target has transitive dependencies that include static
binaries
I spent half a day on the web looking for a way to make my pods compatible with the use_framework! option, in vain. This is very frustrating, as Google Services pods are proofs that it's possible to bypass this problem in a clean way (not with the verify_no_static_framework_transitive_dependencies trick) : the main pod and almost all its dependencies contain static libraries, and everything works perfectly along with Swift pods. Exemple with Google/SignIn which depends on Google/Core (vendored_libraries: Libraries/libGGLCore.a) and GoogleSignIn (vendored_libraries: Libraries/libSignIn.a).
Any idea of what I can do to make my pods compatible with the use_framework! option ?
Thank you all,
Cheers,
Tom
I think I found a hack for my problem. This is quite weird, but I'd say it's clean enough to use it in production ;)
I found it here. The idea is simply to include a source file (even an empty one) in your source_files list inside your podspec.
Basically, the source section of my podspec looks like this :
s.source_files = "myLib/Empty.m", "myLib/Headers/*.h"
s.vendored_libraries = "myLib/myLib.a"
The only modification I made is to add "myLib/Empty.m" in the source files (Empty.m is strictly empty). Without it, I systematically have the transitive dependencies error when I pod install. With it, pod install works fine. It worked for me with both Cocoapods 0.0.39 and 1.0.0.beta.4.
Well, looks like it's a not so dirty solution, but I'm not sure it'll work in every case. And it's no good news about the cleanliness of Cocoapods...
As I mentionned in comments earlier, Google seems to have found a cleaner solution. So if anybody have an idea of the real clean solution, please share !
Cheers,
Tom
PS : I think I'll name the file DirtyCocoapodHack.m instead of Empty.m, sure they'll love it in the dev team ;)

Editing locked files from a CocoaPods framework

I have an Xcode workspace that uses CocoaPods to include several third-party frameworks. I would like to edit a line of source code within one of these dependencies. However, when I do so, Xcode warns me that the file is locked and that any changes I make may not be saved. So my question is: will my changes to the source code be discarded when I run a pod install/update? If not, is there any other scenario, possibly unrelated to CocoaPods, that would discard my changes? And finally, is there any good way that I can edit the source code without running into such problems?
Thanks in advance.
You can not make changes in Original Pod file. If you want to add some more features then you have to fork that particular repo.
Follow steps to do so :
Find library you want to use on Git.
Fork library.
Update Podfile which refer to your forked version.
Suppose I want to fork GPUImage Library. Then point your fork in Podfile as given.
pod 'GPUImage', :git => 'https://github.com/UserName/GPUImage.git'
Make your changes.
Commit/push your changes to your forked repo.
Submit a pull request to the original author of Library.
If pull request is accepted and the pod is updated, revert back your Podfile to use the public pod.
You can create Category (Objective C) or Extension (Swift) to extend or add some features to existing class.
You can do this simple. Just modify the pods src code. Switch to another brach and switch back. Xcode would rebuild pods with your modified code.
If you want go back, you should remove the pod in Podfile, execute pod install.Then add pod back, execute pod install.
This solution is just for debug.
For permament, you should take #technerd 's answer
In fact there is another way in which you can modify the library as per your custom needs and get future updates from the library, all while still maintaining it via cocoapods
I have written article/tutorial explaining the same.
https://medium.com/#mihirpmehta/how-to-modify-cocoapods-library-within-pods-647d2bf7e1cb

Google/Analytics.h file not found when adding to AppDelegate

I am trying to integrate Google Analytics in my ios project using Cocoapods. However, after following this for the steps till adding configuration file to my project, when importing the Google/Analytics.h in AppDelegate I get error for file not found. Tried following things:
Added $(SRCROOT)/Pods/GoogleAnalytics to User Header Search Paths in Build Settings.
Added libGoogleAnalyticsServices.a to link binary with libraries in build phases.
Added -lGoogleAnalyticsServices in Other Linker Flags.
Don't really want to do 2 and 3 as they make it free from Cocoapods.
What exactly am I missing?
Swift 3
With version 3.17.0 (installed using pod 'GoogleAnalytics' in Podfile):
Open yourproject.xcworkspace instead of yourproject.xcodeproj
Use #import <GoogleAnalytics/GAI.h> in the bridging header file
Edit:
Per jeremy piednoel's comment you may also need
#import <GoogleAnalytics/GAIDictionaryBuilder.h>
#import <GoogleAnalytics/GAIFields.h>
Problems
The code examples on the official documentation suggest
installing 1.0.0. Which doesn't even have binaries compiled for
arm64.
There seem to be at least three separate pods related to
GA. GoogleAnalytics-iOS-SDK, GoogleAnalytics, Google/Analytics.
Solution
Add this to your Podfile: pod 'Google/Analytics' and then pod install.
That should work. Now you can simply import Google/Analytics.h as suggested in the docs:
#import <Google/Analytics.h>
Further Discussion
There were two sets of issues that I ran into:
When using the incorrect suggested pod version (1.0.0), was a 64-bit compatibility issue. (ld: symbol(s) not found for architecture arm64)
When using the other pods (GoogleAnalytics-iOS-SDK and GoogleAnalytics) I had complaints of a missing <Google/Analytics.h> header file. ("Google/Analytics.h" not found)
I found this gentleman's post on a mailing list which suggested the Google/Analytics pod with no version number. (pod 'Google/Analytics' as noted above.)
This is a bug in cocoapods.
you need to add $(SRCROOT)/Pods/Google and $(SRCROOT)/Pods/GoogleAnalytics with recursive option to your User Header Search Paths.
Then include the #import "Analytics.h" instead of #import
When you add $(SRCROOT)/Pods/GoogleAnalytics to User Header Search Paths in Build Settings, also select recursive option. It will allow your project to search in GoogleAnalytics and all of its sub-directories.
UPDATED:
I have tried the tutorial and it works fine without any extra step. My pod version is 0.35.0. When you create configuration file, remember to enable GoogleAnalytics service.
UPDATED:
As #RajatTalwar pointed out, you also need to add $(SRCROOT)/Pods/Google with recursive option. Then include the #import "Analytics.h" instead of #import
If anyone else out there is having an error with trying to #import <Google/Analytics.h>, and the other solutions online aren't helping you, you should read on.
I was having this problem and none of the solutions I found would fix it. Then I noticed that one of my targets worked while the other one did not (I had two in the same project), and I tried to track down what was the difference between the two targets.
I noticed that there was a difference in the project on the General tab under Deployment info, where the second target (the one which worked) had separate options for iPhone and iPad, but the first did not. Someone else online said that they received these two new options when they duplicated their target. My second target was also a duplicate of the first, originally.
To make a long story short, I found that if I duplicated my target that the duplicate now suddenly worked. Those separate iPhone and iPad options also magically appeared. So I guess my project target was non-standard and causing a problem, probably because this project was created a long time ago.
I then just deleted the original target and renamed the new one to be the same name, although there was some cleanup work required in the build settings related to the plist file (it made a copy.plist file).
Hope this helps someone.
Check if you have multiple targets, in this case add pod 'Google/Analytics' foreach target in you pod file:
def google_pods
pod 'Google/Analytics'
end
target 'target 1' do
google_pods
end
target 'target 2' do
google_pods
end
target 'target N' do
google_pods
end
Also my $0.02 to this, since it seems to be a never ending story. None of the suggestions above did help. I got this obscure message from pod install
[!] The `blabla [Release]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-blabla/Pods-blabla.release.xcconfig'. This can lead to problems with the CocoaPods installation
Finally I inspected my project.pxbprojand found, that I had this entry:
HEADER_SEARCH_PATHS = "";`
Obviously this is treated as "defined", so I changed it to
HEADER_SEARCH_PATHS = "$(inherited)";
and boom - all the Google suggested includes work
#import <GoogleAnalytics/GAI.h>
#import <GoogleAnalytics/GAIDictionaryBuilder.h>
#import <GoogleAnalytics/GAIFields.h>
Run pod update
Clean Build Files
Run Project
remove valid archs from build settings

Resources