I develop two frameworks (Framework A and Framework B) and deliver them via Cocoapods.Framework A has a dependency on Framework B . Below you can see the pod spec for a Framework A:
s.ios.dependency 'Framework B/Dynamic', "~> 1.0.0"
If I install both frameworks via CocoaPods and specify them both in the Podifle , I receive an error:
[!] The 'PodsTarget' target has frameworks with conflicting names: framework_b_name.xcframework.
I wonder, is there any .podspec argument or build settings for Framework A , which could help me to solve this issue. For example, cocoapods will not install additional Framework A in case, if both Framework A and B have been specified in the Podfile ? I want this issue to be solved on the dependency side and not on the side of the client (person, who installs the pod).
I have tried to use weak linking flag in the build settings as well, as removing /Dynamic from the .podspec
So, here is my solution for the current problem:
In Podfile I have my FrameworkB (without specific version it pulls the latest major, let's say 2.0.0). In my Podspec I had version of a dependency set to ~> 1.0.0], which will pull any version, that is higher, than 1.0.0, but lower than 2.0.0. Plus, I pulled FrameworkB/Dynamic, which led to creation of Dynamic folder, so after pod install/update, I had following project struct:
project
│ /..../
│
└───Pods
│ │ FrameworkB.framework
│ │
│ └───Dynamic
│ FrameworkB.framework
Changing version in the .podspec file to >=1.0.0 fixed the problem.
Related
I'm following instructions here to add a package: https://github.com/joltup/rn-fetch-blob
It says to do npm install OR add to Podfile. What I did was
yarn add rn-fetch-blob
Then
cd ios
pod install
Is that correct? I didn't edit the Podfile but somehow it still knew to get the dependency. Output:
Analyzing dependencies
Downloading dependencies
Installing rn-fetch-blob (0.12.0)
Generating Pods project
Integrating client project
The Podfile doesn't have any reference to rn-fetch-blob. Can someone explain if I did it right or if I needed to edit the Podfile?
When you do pod install, it actually looks into your package.json dependancies to see what dependency requires pod installation. As you have already added it to node_modules but not in Podfile.
Assuming that you are using the latest React Native version like 0.60 and above, this process is simply called Autolinking
Basically, whenever you add a new library to your package.json as you did for rn-fetch-blob and run pod install after adding it, the whole node_modules folder is being scanned thanks to a script file called native_modules.rb to find an appropriate podspec file and install what is necessary to install a pod.
This is the definition of how iOS auto-linking works from the community docs:
Platform iOS
The native_modules.rb script required by Podfile gets the package
metadata from react-native config during install phase and:
Adds dependencies via CocoaPods dev pods (using files from a local
path). Adds build phase scripts to the App project’s build phase. (see
examples below) This means that all libraries need to ship a Podspec
either in the root of their folder or where the Xcode project is.
Podspec references the native code that your library depends on.
Every single time I install a pod using cocoapds. I get this message:
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Why CocoaPods is complaining about:
There is 1 dependency from the Podfile and 1 total pod installed.
I haven't found a way to fix this message.
Any of you know how to fix this issue?
This is actually not an error. Cocoapods is a 'dependency manager'
Here's a text extract that might help:-
CocoaPods maintains a list of every dependency available through
CocoaPods and it keeps a local clone of that list on your machine. You
can find it at ~/.cocoapods/repos/master. Before it installs the
dependencies, it pulls in any changes from GitHub to make sure the
list is up to date.
CocoaPods then inspects the list of dependencies in your project's
Podfile. It ensures the dependencies you specified are compatible with
your project and its targets. It also checks that none of the listed
dependencies conflict with one another. After downloading the
dependencies, it installs them in a Pods directory at the root of your
Xcode project.
The dependencies are basically what you specify on your podfile under use_frameworks. The line tells you that CocoaPods has installed the 1 dependency(i.e: One pod) that you have specified
Therefore, "There is 1 dependency from the pod file and 1 total pods installed" can be thought of as Cocoapods saying "You have specified 1 pod(dependency) in your podfile, we have found the project linked with the dependency, downloaded it to your local pods repository and have successfully installed the one pod out of the downloaded dependency"
Using NativeScript how can I run a project under iOS? I get these messages when I run tns run iOS --bundle
Webpack compilation complete. Watching for file changes.
Webpack build done!
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Installing pods...
Analyzing dependencies
Downloading dependencies
Installing Socket.IO-Client-Swift (11.1.3)
Installing StarscreamSocketIO (8.0.7)
Installing Toaster (2.0.4)
[!] Unable to determine Swift version for the following pods:
- `Socket.IO-Client-Swift` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
- `StarscreamSocketIO` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
- `Toaster` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
Unable to apply changes on device: 21FFE2BB-EB0D-48E3-A7AD-28CA08DD21E5. Error is: Command pod failed with exit code 1 Error output:
[!] Automatically assigning platform `ios` with version `8.0` on target `Hybrid` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Can someone help me out?
Just had these same errors and found out downgrading from cocoapods 1.6.0 to 1.5.3 fixed it for me.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
The problem here seems to be Toaster (2.0.4), which appears to have been developed for Swift 3.
I did this in order to resolve the issue:
go to the main folder for the nativescript project
In your bash shell, do:
% export SWIFT_VERSION=3
Then do your usual:
% tns build ios --bundle
Then open the project in Xcode:
% cd platforms/ios
% Open *.workspace
You'll get a warning about a build error in the pods project and may need to set your development team, but it should work.
The problem is with Cocoapods 1.6.x which have different behavior when it comes up to SWIFT_VERSION. Previously it was possible to set the SWIFT_VERSION in post_install hook of the Podfile, but now the pod install command fails before even getting to post_install.
The best solution is to use Cocoapod which already has SWIFT_VERSION set, i.e. in case you face the error, try to contact the Pod author.
Meanwhile, as a workaround, you can add a pre_install script in your <path to App_Resources/iOS/Podfile file with the following content:
pre_install do |installer|
installer.analysis_result.specifications.each do |s|
if s.name == 'Socket.IO-Client-Swift' || s.name == 'Starscream' || s.name == 'StarscreamSocketIO' || s.name == 'Toaster'
s.swift_version = '4.2'
end
end
end
For each of the Pods you can set different Swift version based on their requirements.
I have it fixed with #K Brown's answer.
Was having these errors when running tns run ios --bundle
for Socket.IO-Client-Swift, StarscreamSocketIO and Toaster when both v1.6.0 and v1.5.3 of Cocoapods installed:
- `<package name>` does not specify a Swift version and none of the targets
(`<project name>`) integrating it have the `SWIFT_VERSION` attribute set.
Please contact the author or set the `SWIFT_VERSION` attribute in at least one
of the targets that integrate this pod.
Below are the commands used:
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
rm -Rf platforms
tns install
tns run ios --bundle
Here is the real fix ! You can't stick with Cocoapods 1.5.3 forever...
Downgrading to 1.5.3 isn't a proper workaround and will not be sustainable in the future. In fact, this error is due to a new behavior introduced in Cocoapods 1.6.0 version, which force developers to set a Swift version to their projects. The goal is in fact to make library developers specify a Swift version in their podspec, so that library users don't have to do this manually (thanks to post_install scripts for example). You can see my discussion about this with a Cocoapods maintainer here. I do agree that this behavior is a bit misleading, as we try to set the Swift version in post_install script but an error is returned before…
In fact, as I have been told by the maintainer, the correct fix to this issue is to set a Swift version at project level (and therefore not at Pod level). To do this, just add a new User Defined Setting in Build Settings, with key SWIFT_VERSION and value 4.0 (for example, as whatever value should work here if you also set the version at Pod level with post_install script).
Long story short, the fix is to add this key/value :
Note that as you're using NativeScript, you may want to set the Swift version by running command export SWIFT_VERSION=4 in your project folder, before building.
I am trying to use the SwiftIconFont Framework in my project. I followed all the directions listed. I added pod 'SwiftIconFont', '~> 2.7' then performed pod install. The terminal spits out:
Analyzing dependencies
Downloading dependencies
...
...
Installing SwiftIconFont (2.7.0)
...
...
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 8 dependencies from the Podfile and 13 total pods installed.
Judging from this terminal message, SwiftIconFont should have been successfully installed on my project. However, when I go to my project to try to link the SwiftIconFont framework, the added directory appears to be empty.
I tried to import SwiftIconFont but Xcode says no such module exists. What else should I do to be able to use this framework?
I also added github "0x73/SwiftIconFont" to my Cartfile, then performed carthage update, even though this step may be unnecessary.
I'm not sure why this 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.
This is a tiny doubt which I want to get clarified.
I have a project which is lets say Project-1 which uses a library of ytr (cocoapod version 0.1.13).
I have another project which is lets say Project-2 which I am planning to use library of ytr (cocoapod version 0.2.0).
Now if I do "pod install" in second project, will this also update the pod which is with "Project-1"?
When you run pod install it is in the context of the Podfile you are referencing. i.e. running pod install in the directory where Project-1 resides will install it's dependencies (and run whatever else you have defined in the podfile) for that Podfile under the $PROJ1_PODFILE_LOCATION\Pods directory
Doing the same for project-2 will install that project's dependencies under its own $PROJ2_PODFILE_LOCATION\Pods directory.
You can see the actual versions it downloaded for each project inside the Podfile.lock file it creates after resolving the dependencies (it's kinda like Gem's Gemfile.lock if you are familiar).
You can read more about this behavior and the Podfile.lock file here