CocoaPods Header Search - objective-c

I'm experiencing what would seem a very basic problem and that is header files not being found. Below is a basic directory structure for a test POD I've created, my requirement is to retain the directory structure and for both root and SubPods to have access to header files. To retain the directory structure I'm using SubPods, if none of the classes make any reference to other classes the POD validates and the structure is correct. But if TSTSubClasses1.h includes TSTRootClass.h the POD lint validation fails 'fatal error: 'TSTRootClass.h' file not found.
Classes/TSTRootClass.h
Classes/TSTRootClass.m
Classes/SubPod-1/TSTSubClass1.h
Classes/SubPod-1/TSTSubClass1.m
Classes/SubPod-2/TSTSubClass2.h
Classes/SubPod-2/TSTSubClass2.m
I've tried various combinations of public_header_files, preserve_paths & s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/**'} but no luck. Is there any where that explains how to resolve search issues, also is there any way of outputting PATH details?
Detailed below is the podspec file, the source has been pushed to the repo and the structure and files do exist.
Pod::Spec.new do |s|
s.name = "PODTest"
s.version = "0.1.0"
s.summary = "PODTest dg dghjghj fghj ."
s.description = <<-DESC
sdfg sdfg adfg sdfgn of PODTest
DESC
s.homepage = "http://myhomepage"
s.license = 'MIT'
s.author = { "Duncan Hill" => "myemail#somedomain.com" }
#s.source = { :git => "git#bitbucket.org:reponame/podtest.git"}
s.source = { :git => "git#bitbucket.org:reponame/podtest.git", :tag => s.version.to_s }
s.platform = :ios, '5.0'
s.ios.deployment_target = '5.0'
s.requires_arc = true
#s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/#{s.name}/**'}
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/**'}
s.source_files = "Classes/*.{h,m}"
s.preserve_paths = "Classes/*"
s.subspec "SubPod-1" do |ss|
ss.public_header_files = "Classes/*.h"
ss.source_files = "Classes/SubPod-1/*.{h,m}"
end
s.subspec "SubPod-2" do |ss|
ss.public_header_files = "Classes/*.h"
ss.source_files = "Classes/SubPod-2/*.{h,m}"
end
end
Thanks for any help.

Your subspecs cannot depend on the parent spec, but can depend on other subspecs. You probably want to create some sort of "Core" subspec, then have SubPod 1 and 2 depend on that.

Related

Dependabot nuget pull request

I have an API where I want nuget packages to update with my own feed, but when I get to this UpdateCheckers setting it shows me update_not_possible.
The project is hosted on azure just like the nugets feed
When the build is executed, it only executes and does not create pull request, the se only in Found # {dep.name} # # {dep.version} ...
require "dependabot/file_fetchers"
require "dependabot/file_parsers"
require "dependabot/update_checkers"
require "dependabot/file_updaters"
require "dependabot/pull_request_creator"
require "dependabot/pull_request_updater"
require "dependabot/omnibus"
package_manager = "nuget"
repo_name = "/myproject/_git/WebApi.Dummy"
directory = "src/WebApi.Dummy"
branch= "Dependabot"
azure_hostname = "https://dev.azure.com/myorganization/myproject" || "dev.azure.com"
credentials = [{
"type" => "git_source",
"host" => azure_hostname,
"username" => "x-access-token",
"password" => "my_personal_token"
},{
"type" => "nuget_feed",
"url" => "https://dev.azure.com/myorganization/myproject/_packaging/myfeedNuget/nuget/v3/index.json",
"token" => ":my_personal_token"
}
]
source = Dependabot::Source.new(
provider: "azure",
hostname: azure_hostname,
api_endpoint: "http://#{azure_hostname}/",
repo: repo_name,
directory: directory,
branch: branch
)
puts "Fetching #{package_manager} dependency files for #{repo_name}"
fetcher = Dependabot::FileFetchers.for_package_manager(package_manager).new(
source: source,
credentials: credentials,
)
files = fetcher.files
commit = fetcher.commit
parser = Dependabot::FileParsers.for_package_manager(package_manager).new(
dependency_files: files,
source: source,
credentials: credentials,
)
dependencies = parser.parse
dependencies.select(&:top_level?).each do |dep|
puts "Found #{dep.name} # #{dep.version}..."
checker = Dependabot::UpdateCheckers.for_package_manager(package_manager).new(
dependency: dep,
dependency_files: files,
credentials: credentials,
)
if checker.up_to_date?
puts " already using latest version"
next
end
requirements_to_unlock =
if !checker.requirements_unlocked_or_can_be?
if checker.can_update?(requirements_to_unlock: :none) then :none
else :update_not_possible
end
elsif checker.can_update?(requirements_to_unlock: :own) then :own
elsif checker.can_update?(requirements_to_unlock: :all) then :all
else :update_not_possible
end
next if requirements_to_unlock == :update_not_possible
updated_deps = checker.updated_dependencies(
requirements_to_unlock: requirements_to_unlock
)
puts " considering upgrade to #{checker.latest_version}"
updater = Dependabot::FileUpdaters.for_package_manager(package_manager).new(
dependencies: updated_deps,
dependency_files: files,
credentials: credentials,
)
updated_files = updater.updated_dependency_files
pr_creator = Dependabot::PullRequestCreator.new(
source: source,
base_commit: commit,
dependencies: updated_deps,
files: updated_files,
credentials: credentials,
label_language: true,
author_details: {
email: "dependabot#bccr.fi.cr",
name: "dependabot"
},
)
pull_request = pr_creator.create
if pull_request&.status == 201
content = JSON[pull_request.body]
puts " PR ##{content["pullRequestId"]} submitted"
ENV['PR_ID']="##{content["pullRequestId"]}"
else
puts " PR already exists or an error has occurred"
end
next unless pull_request
end
puts "Done"

How to use Objective-C framework in Swift without Bridging Header?

I'm developing a Flutter plugin (in Swift) trying to wrap an Obj-C framework. I was able to import the Header files in MyPlugin.h file, but now how do I use the framework without a Bridging Header? I'm just getting not found in scope.
If I were to generate a Bridging Header, I ran into another error using bridging headers with framework targets is unsupported
This is my podspec file, I had to set DEFINES_MODULE to NO in order to build the project without running into Include of non-modular header inside framework module error
Pod::Spec.new do |s|
s.name = 'lisnr'
s.version = '1.0.0'
s.summary = 'Flutter plugin for LISNR'
s.description = <<-DESC
Flutter plugin for LISNR.
DESC
s.homepage = 'redacted'
s.license = { :file => '../LICENSE' }
s.author = { 'redacted' => 'redacted' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
s.preserve_paths = 'radius.framework'
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework radius' }
s.vendored_frameworks = 'radius.framework'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'NO', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
s.public_header_files = 'Classes/**/*.h'
end
The other codes are pretty much generated by the Flutter CLI.
You need a module map. You can either write it manually and put in the framework or do it with a script. See how I did it here for the Spotify SDK which is an ObjC framework.
The script for you would be something like that:
#!/bin/sh
MODULE_DIR="MY_PATH/radius.framework" # You framework's path
mkdir -p "${MODULE_DIR}"
printf "module radius {\n\
header \"Headers/radius.h\"\n\
export *\n\
}" > "${MODULE_DIR}/module.map"

Getting 'undefined method batch' for Google Directory API with service account

So I'm writing a script to batch delete users from a Google Apps for Education domain. The code looks like this:
#! /usr/bin/env ruby
require 'google/api_client'
require 'csv'
service_account_email = 'XXXXXXX#developer.gserviceaccount.com'
key_file = 'key.p12'
key_secret = 'notasecret'
admin_email = 'XXX#xxx'
# Build the API Client object
client = Google::APIClient.new(
:application_name => 'XXX',
:application_version => '0.1'
)
key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)
client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => 'https://www.googleapis.com/auth/admin.directory.user',
:issuer => service_account_email,
:signing_key => key,
:person => admin_email,
)
client.authorization.fetch_access_token!
directory = client.discovered_api('admin', 'directory_v1')
# Reads and parses CSV input into a hash
# Takes file path as an argument
def import_csv(file)
csv = CSV.new(
File.open(file).read,
:headers => true,
:header_converters => :symbol
)
return csv.to_a.map {|row| row.to_hash}
end
users_to_delete = import_csv('accounts.csv')
puts 'Preparing to delete users...'
users_to_delete.each_slice(1000) do |chunk|
directory.batch do |directory|
chunk.each do |user|
client.execute!(
:api_method => directory.users.delete,
:parameters => { :userKey => user[:emailaddress].downcase }
)
end
end
end
puts 'Users successfully deleted!'
When I run the script without the two outer batch blocks, the script runs perfectly (although incredibly slowly).
What I want to know is what I need to change to stop giving me the undefined method error on the 'batch' method for the directory API. In examples in Google's documentation, I've noticed that they call the API differently (zoo = Google::Apis::ZooV1::ZooService.new instead of zoo = client.discovered_api('zoo', 'v1')). I don't see how that would make a difference though.
You can do achieve it this way:
client = Google::APIClient.new(
:application_name => 'XXX',
:application_version => '0.1'
)
directory = client.discovered_api('admin', 'directory_v1')
batch = Google::APIClient::BatchRequest.new do |result|
puts result.data
end
batch.add(:api_method => directory.users.delete,:parameters => { :userKey => user[:emailaddress].downcase })
client.execute(batch)

Own CocoaPods Pod Core Data file can't be accessed

I created my own CocoaPods Pod to use for my apps internally. This Pod should also use Core Data. I added my file xy.xcdatamodeld to my source files but it's not compiled into a xy.momd folder.
Do I need to set any other properties in my Pod to get Core Data to work?
My current pod file:
Pod::Spec.new do |s|
s.name = "Test"
s.version = "1.0"
s.summary = "..."
s.homepage = "..."
s.license = 'MIT (example)'
s.author = { "Felix Krause" => "xy#xy.com" }
s.source = { :git => "http://EXAMPLE/Example.podspec.git", :tag => "0.0.1" }
s.platform = :ios, '6.0'
s.source_files = 'TS/Classes/**/*.{h,m}', 'TS/Views/**/*.{h,m}', 'TS/TSResources/**/*.{json,xcdatamodeld}'
s.resources = "TS/TSResources/**/*"
s.frameworks = 'CoreData', 'QuartzCore', 'Accounts', 'MessageUI', 'CoreLocation', 'CoreGraphics', 'MobileCoreServices', 'SystemConfiguration'
s.requires_arc = true
s.ios.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/../../TS/**' }
s.ios.xcconfig ={ 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/../.." "$(PODS_ROOT)/.." "$(SRCROOT)/.."' }
s.xcconfig = { 'OTHER_LDFLAGS' => '-all_load' }
s.dependency 'JSONKit'
end
Just so I can come back to this, it is actually supported. All you need to do is ensure that your pod spec lists the .xcdatamodeld under resources. Something to the effect of:
Pod::Spec.new do |s|
s.name = "MyPod"
s.version = "0.1"
s.platform = :ios, '8.0'
s.requires_arc = true
s.public_header_files = 'Pod/Classes/**/*.h'
s.source_files = 'Pod/Classes/**/*{h,m}'
s.resources = 'Pod/Classes/CoreData/*.xcdatamodeld'
s.frameworks = 'CoreData'
end
There is currently no explicit support for this. Here is an example of how you could do it. Note, however, that that code was untested, but it should be something along those lines. That specific user moved the model definition into code, in the end, btw.
HTH
Take a look at the following:
https://github.com/CocoaPods/Xcodeproj/issues/81#issuecomment-23142404
https://github.com/Ashton-W/CoreDataPodSample
I'm not very good at Ruby, so I don't understand alloy's example. What I do is just make sure that the xcdatamodeld is included as a source file, then make a reference in my project to that source file in the Pods directory.
The path ends up looking something like '../Pods/[PathToMyPod]/[MyDataModel].xcdatamodeld'.
Its a bit of a hack, but it gets the job done easily.

Carrierwave and s3 with heroku error undefined method `fog_credentials='

I'm trying to setup carrierwave and s3 with heroku. I'm following the carrierwave docs exactly: https://github.com/jnicklas/carrierwave
I've setup a bucket named testbucket in AWS, then I installed fog and created a new initializer with this inside :
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'my_key_inside_here', # required
:aws_secret_access_key => 'my_secret_access_key_here', # required
:region => 'eu-west-1' # optional, defaults to 'us-east-1'
}
config.fog_directory = 'testbucket' # required
end
Then inside my image_uploader.rb I set
storage :fog
Is there something else I am missing??? Thanks for any help.
If you're using carrier-wave 0.5.2, you have to look in the docs within the gem. They are different than what you see on github. Specifically, check out this file in the gem: lib/carrierwave/storage/s3.rb
Also set store to :s3...not :fog.
You'll see this section:
# CarrierWave.configure do |config|
# config.s3_access_key_id = "xxxxxx"
# config.s3_secret_access_key = "xxxxxx"
# config.s3_bucket = "my_bucket_name"
# end
#