I have a private pod called XXCommonUtils which has one dependency installed via Cocoapods, EDSunriseSet.
The podspec for my private pod looks like this
Pod::Spec.new do |s|
s.name = "XXCommonUtils"
s.module_name = 'XXCommonUtils'
s.version = "2.0.2"
s.summary = "XX CommonUtils Component"
s.homepage = 'https://www.xx.com'
s.license = { :type => "Private", :text => "Copyright 2016-2018 by XX. All right reserved." }
s.author = { "XX XX" => "xx.xx#xx.com" }
s.source = { :git => "https://github.xx.com/TSS-XX-CoreApp/iOS-Stage-Frameworks", :tag => "XXCommonUtils-2.0.2-Beta" }
s.swift_version = '4.1.2'
s.platform = :ios, '8.0'
s.requires_arc = true
s.ios.vendored_frameworks = 'XXCommonUtils/XXCommonUtils.framework'
s.frameworks = 'UIKit', 'CoreData'
s.dependency 'EDSunriseSet', '1.0'
end
You can see the EDSunriseSet dependency defined here.
I am importing this private Pod in to an application with the following Podfile
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.xx.com/TSS-XX-CoreApp/iOS-Stage-CocoaPods.git'
target 'netperf01' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
pod 'XXCommonUtils', '2.0.2'
# Pods for netperf01
target 'netperf01Tests' do
inherit! :search_paths
# Pods for testing
end
end
I see that both the common utils private pod and it's dependency EDSunriseSet are installed in the pod install output.
When I run the application, I get an instant crash with this error
dyld: Library not loaded: #rpath/EDSunriseSet.framework/EDSunriseSet
Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/CF8F6C93-2BCF-44F5-B5D1-8B567777271A/data/Containers/Bundle/Application/9E462A24-0417-494F-9081-77D9A33C3B7D/netperf01.app/Frameworks/XXCommonUtils.framework/XXCommonUtils
Reason: image not found
If I uncomment # use_frameworks! in my application Podfile then the app works as normal, however unfortunately this is not a suitable fix for the client attempting the use the XXCommonUtils library. Is there another way to solve this problem?
Related
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.
I have project MySingleViewApp and framework MyFramework. Both are fresh created xcode projects and just added podfile to MySingleViewApp and podspec file to MyFramework.
this is MySingleVIewApp pod file;
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'MyFramework', :path => '../MyFramework'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
And this is MyFramework podspec file
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "bla"
s.description = <<-DESC
some description
DESC
s.homepage = "https://github.com/github_account/my-framework"
# brief license entry:
s.license = "MIT"
# optional - use expanded license entry instead:
# s.license = { :type => "MIT", :file => "LICENSE" }
s.authors = { "Your Name" => "yourname#email.com" }
s.platforms = { :ios => "11.0" }
s.source = { :git => "https://github.com/github_account/my-framework.git", :tag => "#{s.version}" }
s.requires_arc = true
s.swift_version = "5.1.2"
s.vendored_frameworks = 'MyFramework.framework'
s.static_framework = true
s.dependency "UserSDK"
end
When run MySingleVIewApp project i get error
dyld: Library not loaded:
#rpath/GoogleUtilities.framework/GoogleUtilities Referenced from: Frameworks/UserSDK.framework/UserSDK Reason: image not found
If i add UserSDK(which is spec dependency of MyFramework) and remove MyFramework from podfile it works
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'UserSDK'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
Report
What did you do?
I have created podspec file for my custom Framework as:
Pod::Spec.new do |s|
s.platform = :ios
s.ios.deployment_target = '10.0'
s.name = "CustomFramework"
s.summary = "CustomFramework have all the wrapper API."
s.requires_arc = true
s.version = "1.0.0"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "My Name" => "my.name#xyz.com" }
s.homepage = "URL_LINK"
s.source = { :git => "github_url_link", :tag => "#{s.version}"}
s.dependency 'RealmSwift', '3.5.0'
s.dependency 'Firebase/Core', '5.1.0'
s.dependency 'Firebase/Firestore', '5.1.0'
s.dependency 'PubNub','4.7.5'
s.source_files = "CustomFramework/**/*.{swift}"
end
I am adding this Custom framework pod in the sample project as:
target 'customFrameworkSample' do
use_frameworks!
pod 'customFramework' , :path => 'Local_Path_for_customFramework.podspec'
target 'customFrameworkSampleTests' do
use_frameworks!
pod 'customFramework' , :path => 'Local_Path_for_customFramework.podspec'
end
end
What did you expect to happen?
Pod should install properly and When sample project is Build, it should Run and not throw any error.
What happened instead?
In the Sample project, error is thrown while importing firbase, RealmSwift files, etc.. in CustomFramework files.
CocoaPods Environment
cocoapod : 1.5.3
When you specify dependancies in your Podspec you are saying that YOUR CUSTOM FRAMEWORK is dependant on them. So the dependancies will only be available to reference within your framework. If you want the sample application to be able to reference Firebase then you will need to specify this within the sample application's podfile.
Documentation references:
Podspec 'dependancies'
Podfile 'dependancies'
make sure you have added firebase library in Linked framework and libraries
I've created a podspec file for my project, which itself has a podfile.
Podfile looks something like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'FLAnimatedImage', '~> 1.0'
Podspec file is also a standard setup:
Pod::Spec.new do |s|
s.name = "ConversationVC"
s.version = "1.0.1"
s.summary = "ConversationViewController, for messaging"
s.homepage = "[HOMEPAGE URL]"
s.author = { "Andrew Hart" => "[EMAIL ADDRESS]" }
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => "[GIT URL]", :tag => s.version.to_s }
s.platform = :ios, '9.0'
s.requires_arc = true
s.source_files = 'Source/**/*.swift'
s.frameworks = 'UIKit'
s.ios.deployment_target = '9.0'
end
I'm using the pod lib lint command to make sure it passes the Podspec tests, and I'm getting this error:
ERROR | xcodebuild: /Users/Andrew/Code/ConversationVC/Source/View/ConversationImageCell.swift:10:8: error: no such module 'FLAnimatedImage'
That file does have a import FLAnimatedImage line, referencing one of my pods, as do many other files in my project.
I did try using the pod in another project, giving the git url, and it succeeded, but when I built the workspace in Xcode, it gave me the same error to do with the missing framework of FLAnimatedImage.
I'm wondering how I'm supposed to handle this situation?
You should declare your dependencies in your podspec file too, like this:
s.dependecy "FLAnimatedImage", "~> 1.0"
So i figure this should be really easy but after a day of Googling and playing around i still can't seem to get this working. I have a private cocoapod which downloads code from a private git repository. This is all set-up and works fine.
What i'm struggling with is i need to include localized xibs in the cocoapod. I have a LoginView which is shared code across a number of our internal apps. However we have localised versions of the view. From what i can tell due to the way cocoapods flattens out the structure it's just copying the localized xib which is causing the *.lproj directories to be lost. When i then try and use the cocoapod it seems to pick up the first xib regardless of the language setting on the device.
I'm hoping someone might be able to guide me as to how i go about retaining the folder heirachy or if there's another way to include the localised xibs into the cocoapod.
#
# Be sure to run `pod lib lint NAME.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = "ios-XX-common"
s.version = "1.0"
s.summary = "XXXXXX"
s.description = "Pod containing common source code used across multiple apps"
s.homepage = "http://www.example.com"
s.license = 'Copyright'
s.author = { xxx }
s.source = { :git => "xxxx:/data/git/ios-xx-common.git", :tag => 'v1.0'}
s.platform = :ios, '7.0'
s.requires_arc = false
s.header_dir = 'ios-xx-common'
s.header_mappings_dir = 'CommonSourceCode'
s.source_files = "CommonSourceCode/**/*.{h,m}", "CommonSourceCode/CustomUIObjects/**/*.{h,m}",
"CommonSourceCode/Data Objects/**/*.{h,m}", "CommonSourceCode/Helpers/**/*.{h,m}",
"CommonSourceCode/UID/**/*.{h,m}", "CommonSourceCode/UIViews/**/*.{h,m}",
"CommonSourceCode/ViewControllers/**/*.{h,m}"
s.resource_bundles = { 'rr-common-xibs' => ['CommonResources/Xibs/*.lproj'],
'rr-common-other' => ['CommonResources/Icons/*.*', 'CommonResources/IPhone/*.*', 'CommonResources/IPhoneIPad/*.*', 'CommonResources/Sounds/*.*'] }
s.public_header_files = '**/*.h'
s.dependencies = { 'Parse-iOS-SDK' => '~> 1.2.19', 'CocoaLumberjack' => '~> 1.7.0',
'MBProgressHUD' => '~> 0.8', 'AFNetworking' => '~> 1.0' }
end
Thanks
I think you might be after "Development Pods".
So I have two projects, a library project and an app specific project.
In my library project I have a library.podspec file
Pod::Spec.new do |s|
s.name = "Library"
s.version = "0.0.1"
s.summary = "Shared library."
s.description = "This is an iOS library for shared common code across all apps"
s.homepage = "http://blah.com"
s.license = 'COMMERCIAL'
s.author = { "My name" => "my#email.com" }
s.social_media_url = "http://twitter.com/blah"
s.platform = :ios, '8.0'
s.source = { :git => "https://bitbucket.org/blah/library.git", :tag => '0.0.1' }
s.source_files = 'Library/Classes/**/*.{h,m}', 'Library/Models/**/*.{h,m}', 'Library/ViewModels/**/*.{h,m}', 'Library/Views/**/*.{h,m}'
s.resources = "Library/Images/**/*.png", "Library/Images/**/*.jpg", 'Library/Views/**/*.xib', "Library/Fonts/*.otf"
s.requires_arc = true
s.framework = 'MapKit', 'CoreLocation'
s.dependency 'AFNetworking'
s.dependency 'ReactiveCocoa'
s.dependency 'JLRoutes'
end
Then in my specific app project's Podfile...
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
link_with 'Myapp', 'Myapp-Tests'
pod 'Library', :path => '../library/'
Now when I run "pod update" for my specific app project I can see under the Pod project instead of under Pods, I have a new folder called Development Pods.
Just be aware that if you add new files in your Library project, be sure to pod update again.
Peace.