Cocoapods Not Linking Private Framework Pod Correctly - ios

I am trying to link a series of Pods together to encapsulate project functionality and have arrived at an issue.
I have 3 Pods:
IOS-Intrasonics -> contains Intrasonics.framework
IOS-Core -> contains core API and Intrasonics functionality
IOS-Consumer -> contains the consumer app that makes use of the core
Intrasonics Podspec:
Pod::Spec.new do |spec|
spec.name = 'IOS-Intrasonics'
spec.version = '1.0.7'
spec.license = {
:type => 'Copyright',
:text => <<-LICENSE
Copyright 2014 Intrasonics Limited. All rights reserved.
LICENSE
}
spec.homepage = 'http://www.intrasonics.com'
spec.authors = { 'xxxx' => 'xxxxx' }
spec.summary = 'Intrasonics SDK'
spec.source = { :git => 'git#github.com:xxxxx/IOS-Intrasonics.git', :tag => '1.0.7'}
spec.ios.deployment_target = '7.0'
spec.ios.vendored_frameworks = 'src/IntrasonicsDecoder.framework'
spec.ios.frameworks = 'AVFoundation', 'AudioToolbox'
spec.requires_arc = true
end
IOS-Core Podspec:
Pod::Spec.new do |spec|
spec.name = 'IOS-Core'
spec.version = '1.0.0'
spec.license = {
:type => 'Copyright',
:text => <<-LICENSE
Copyright 2014 xxxxxxx. All rights reserved.
LICENSE
}
spec.authors = { 'xxxx' => 'xxxx' }
spec.homepage = 'xxxx'
spec.summary = 'Core'
spec.source = { :git => 'git#github.com:xxxx/IOS-Core.git', :tag => '1.0.0'}
spec.ios.deployment_target = '7.0'
spec.ios.public_header_files = 'Core/Core/**/*.h'
spec.ios.source_files = 'Core/Core/**/*.{h,m}'
spec.ios.dependency 'AFNetworking'
spec.ios.dependency 'IOS-Intrasonics'
spec.requires_arc = true
end
Both of these Pods are located in a private repository. Now, when I run, pod spec lint on IOS-Core, it returns this:
$ pod spec lint
-> IOS-Core (1.0.0)
- ERROR | [xcodebuild] IOS-Core/Core/Core/Models/Events/FNXCIntrasonicsEvent.m:11:9: fatal error: 'IntrasonicsDecoder/IntrasonicsDecoder.h' file not found
- ERROR | [xcodebuild] IOS-Core/Core/Core/Helpers/Core/FNXCIntrasonicsManager.m:13:9: fatal error: 'IntrasonicsDecoder/IntrasonicsDecoder.h' file not found
Analyzed 1 podspec.
[!] The spec did not pass validation.
Even though the Podspec lists IOS-Intrasonics as a dependency, it isn't linking it. IOS-Intrasonics is included in the Podfile and works in the project just fine but it doesn't work as a dependency. Please help!

This looks like it's caused by you not including any public header files in the spec where you're vendoring your framework. You'd want to do that with something like:
s.public_header_files = 'path/to/headers/*.h'

I ended up bundling in the classes I wanted to add with the framework pod instead of the pod that included the pod with the framework.

Related

React Native Module: Remote pod gets installed but not its dependencies?

I have created React Native boilerplate app using:
npx react-native init MyApp --template react-native-template-typescript
After this I added a podSpec file to the root as shown below:
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
Pod::Spec.new do |s|
s.name = package["title"]
s.version = package["version"]
s.summary = package["description"]
s.description = <<-DESC
react-native-test-module
DESC
s.homepage = package["homepage"]
# brief license entry:
# optional - use expanded license entry instead:
s.license = "MIT"
s.authors = { package["authors"] => package["contact"] }
s.platforms = { :ios => "9.0" }
s.source = { :git => "https://github.com/github_account/react-native-test-module.git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,c,cc,cpp,m,mm,swift}"
s.requires_arc = true
# ...
# s.dependency "..."
s.dependency "React"
end
And I am including this pod into another ios App by:
pod 'MyApp', :git => 'https://github.com/shivam-rallyhealth/rn-content-megazord', :tag => '0.0.19'
When I do pod install --repo-update for some reason, it installs all the files, but not the pod dependencies and so When I do a build, I get this error:
#import <React/RCTBridgeDelegate.h> 'React/RCTBridgeDelegate.h' file not found
How do I modify my podSpec such that all the pods also gets installed and not just the module files?
Please note that I am very well able to build the project that lies within ios directory of the React Native boilerplate. The problem comes when I try to outsource it to another existing app and then use it there.

Pod library not installing properly

I have a project XyzAbc with proj structure
--LICENSE
--XyzAbc
----XyzAbc.h
----Info.plist
----file1.swift
----file2.swift
--Products
----XyzAbc.framework
After building this project I pick this XyzAbc.framework and push it in github account that has folder structure
--XyzAbc.framework
--.gitignore
--LICENSE
--XyzAbc.podspec
--README.md
I created XyzAbc.podspec file in my local machine its structure is
Pod::Spec.new do |s|
s.name = ""
s.version = "0.1.1"
s.summary = ""
s.description = ""
s.homepage = ""
s.swift_versions = "4.2"
s.license = {
:type => "MIT",
:file => "LICENSE"
}
s.author = "xyyyy"
s.platform = :ios, "10.0"
s.source = {
:git => "https://github.com/xyz/pqr.git", # github link where I uploaded my compiled library
:tag => "0.1.1"
}
s.source_files = "XyzAbc.framework/Headers/*.h"
s.public_header_files = "XyzAbc.framework/Headers/*.h"
s.vendored_frameworks = "XyzAbc.framework"
s.framework = 'Foundation'
end
I am refering this podspec file in my app like
target 'TestApp' do
use_frameworks!
pod 'XyzAbc', :path => "../../../../Desktop/XyzAbc.podspec"
end
But I am not able to see any header inside pod library. In my project TestApp it looks something like this
--Pods
----Podfile
----Development Pods
------XyzAbc
--------Pods
--------SupportFiles
--------<Frameworks is missing>
I tried using :http then when I provide zip .framework folder in http link, it is not working but when I provide unziped .framework folder then I am able to use this library.
I am following this https://medium.com/onfido-tech/distributing-compiled-swift-frameworks-via-cocoapods-8cb67a584d57
UPDATE - elaborated

CocoaPod spec: Unable to find other source ref for Model.xcdatamodeld

I am trying to create a pod with CoreData model inside. I've followed the tips to use resources and reserve_path. But when I try to lint the spec with pod lib lint there is this weird error that I don't even understand:
- ERROR | [iOS] unknown: Encountered an unknown error (Unable to find other source ref for /Users/rzolin/Projects/ArmorText/iOS-Pod-Test/SampleMessengerCocoapodFramework/SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld/Model.xcdatamodel/contents for target SampleMessengerCocoapodFramework.) during validation.
The spec is based on couple of subspecs, which could complicate the issue a bit. And search on the Internet didn't produce any help so far.
There is a test spec that replicates the error, if somebody is willing to take a look.
The full spec is here:
Pod::Spec.new do |s|
s.name = 'SampleMessengerCocoapodFramework'
s.version = '0.2.0'
s.summary = 'some desc'
s.description = <<-DESC
some desc
DESC
s.homepage = 'http://www.example.com'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'rzolin' => 'rzolin#gmail.com' }
s.source = { :git => 'https://github.com/rzolin/SampleMessengerCocoapodFramework.git', :tag => s.version.to_s }
# Platform setup
s.requires_arc = true
s.ios.deployment_target = '8.0'
s.default_subspec = 'Core'
### Subspecs
s.subspec 'Core' do |cs|
cs.dependency 'SampleMessengerCocoapodFramework/DataManagement'
cs.dependency 'SampleMessengerCocoapodFramework/Networking'
end
s.subspec 'DataManagement' do |ds|
ds.source_files = 'SampleMessengerCocoapodFramework/Code/DataManagement.h', 'SampleMessengerCocoapodFramework/Code/DataManagement/**/*'
ds.resources = [ 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld', 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld/*.xcdatamodel' ]
ds.preserve_paths = 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld'
end
s.subspec 'Networking' do |ns|
ns.source_files = 'SampleMessengerCocoapodFramework/Code/Networking.h', 'SampleMessengerCocoapodFramework/Code/Networking/**/*.{h,m,swift}'
end
# s.resource_bundles = {
# 'SampleMessengerCocoapodFramework' => ['SampleMessengerCocoapodFramework/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
I've tried to ask the question in Cocoapods, but was referred here
Any help would be appreciated!
I had the same problem and error message as you.
I wanted to have the .xcdatamodel in my pod.
Here is my solution:
Add only your code in the source_files:
s.source_files = 'MyPodDiR/**/*.{h,m,swift}'
Add your xcdatamodel path as a resources:
s.resources = 'MyPodDir/CoreData/MyPodModel*.xcdatamodeld'
I had the same issue, by including SampleMessengerCocoapodFramework/Code/DataManagement/**/* you are including all files (so the pod tries to include the .xcdatamodel/xcdatamodeld files and that's where you get the error.
I suggest removing the coredatamodel from the sources file.
i.e s.source_files = 'SampleMessengerCocoapodFramework/Code/DataManagement/**/*.{h,m}'
And keep the rest as is, it should work!

Building a Cocoapods Module error [ARC] xcodebuild: Returned an unsuccessful exit code [duplicate]

This question already exists:
GoogleMapsUtils Framework wrapped in Cocoapods Build error on Xcode
Closed 5 years ago.
I'm quiet new at iOS development, this is my first question at SO. At my company we're trying to convert our app in a Cocoapods module to help as to create diferent apps with similiar functionalities. So far we achive to compile the POD module, but when we're trying to import the classes from the module at the workspace's Example attached we get a "Could not build module 'ProjectCore'
#import <ProjectCore/myProjectCoreClass.h>
No getting more details where the building is failing. Am I missing something? There is any way to know where the building process is failing?
Thanks.
After checking the guide deeply and trying the lint check for the building with:
pod lib lint --verbose --allow-warnings
My project use ARC in only some modules, so the podspec is like this.
Pod::Spec.new do |s|
s.name = 'ProjectCore'
s.version = '0.1.3'
s.summary = 'A short description of ProjectCore.'
s.description = 'This is our core a git with cocoapods - ProjectCore.'
s.homepage = 'https://bitbucket.org/projectcore/ios_projectcore'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Comapny' => 'info#company.com' }
s.source = { :git => 'https://bitbucket.org/projectcore/ios_projectcore.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.frameworks = 'CoreData', 'SystemConfiguration', 'Accelerate', 'CoreGraphics', 'CoreLocation', 'CoreText', 'GLKit', 'ImageIO', 'OpenGLES', 'QuartzCore', 'UIKit', 'AdSupport', "GoogleMapsCore", "GoogleMapsBase", "GoogleMaps", "Crashlytics", "Fabric"
s.library = 'z', 'c++', 'xml2'
s.vendored_frameworks = "StaticLibraries/GoogleMapsServices/GoogleMaps.framework", "StaticLibraries/GoogleMapsServices/GoogleMapsBase.framework", "StaticLibraries/GoogleMapsServices/GoogleMapsCore.framework", 'StaticLibraries/FabricCrashlytics/Crashlytics.framework', 'StaticLibraries/FabricCrashlytics/Fabric.framework'
s.vendored_libraries = 'StaticLibraries/GoogleAnalyticsServices/*.a', 'StaticLibraries/GoogleConversionTracking/*.a'
s.xcconfig = {'OTHER_LDFLAGS' => '-ObjC', 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2'}
arc_files = 'ProjectCore/**/ActionMenuHelper.{h,m}',
'ProjectCore/**/UnitsFormatter.{h,m}',
'ProjectCore/**/BSKeyboardControls/**/*.{h,m}',
'ProjectCore/**/CellMenuLeft.{h,m}',
'ProjectCore/**/CheckInternetConnection.{h,m}',
(...)
s.requires_arc = false
s.source_files = 'ProjectCore/**/*.{h,m,swift}','StaticLibraries/GoogleAnalyticsServices/*.h','StaticLibraries/GoogleConversionTracking/**/*.h','StaticLibraries/ZLib/*.h','StaticLibraries/XMLParser/*.h'
s.exclude_files = arc_files
s.subspec 'ARC' do |sp|
sp.requires_arc = true
sp.source_files = arc_files
end
s.resource_bundle = { 'ProjectCore' => 'ProjectCore/**/*.{png,jpg,xib,strings}' }
s.dependency 'FBSDKLoginKit', '~> 4.11'
s.dependency 'FBSDKShareKit', '~> 4.11'
s.dependency 'NSHash', '~> 1.1'
(...)
end
But my only error is this one:
- ERROR | [ProjectCore/ARC] xcodebuild: Returned an unsuccessful exit code.
Creating your own CocoaPod is fairly straight forward. If you already
have a separate component, you're most of the way there. This guide is
an overview to the entire process, with the other guides in this
section serving as more of a deep-dive for more advanced users.
https://guides.cocoapods.org/making/making-a-cocoapod.html

pod spec lint fails

I made a Swift framework I want to make a CocoaPods for it.
I've followed all the instructions:
created podspec file, added version tag, pushed it to github
When I run pod lib lint it passes but when I run pod spec lint it fails.
Here is my podspec file
Pod::Spec.new do |s|
s.name = "Seru"
s.version = "0.0.3"
s.summary = "Seru is Simple Core Data stack"
s.description = <<-DESC
Seru is Swift framework for working wit Core Data. It setup your core data stack and
gives you nica actions to work with it
DESC
s.homepage = "https://github.com/kostiakoval/Seru"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Kostiantyn Koval" => "konstantin.koval1#gmail.com" }
s.social_media_url = "http://twitter.com/kostiakoval"
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/kostiakoval/Seru.git", :tag => s.version }
s.source_files = "Seru/Source", "Seru/Source/**/*.{swift}"
s.requires_arc = true
s.ios.vendored_frameworks = 'Carthage/Build/iOS/Sweet.framework'
end
It has external framework dependency. I'm guessing this is a problem.
When I do pod speck lint, it says that I can't find that external framework
The problem was that CocoaPods don't include vendored_frameworks folder.
To fix it is to specify that this folder should be included to a CocoaPod by using preserve_paths.
s.preserve_paths = 'Carthage/Build/iOS/Sweet.framework'

Resources