How to add a CocoaPod framework to Xcode 8 Playground - xcode

I tried to add some pods to the Playground within an Xcode project. Unfortunately, the only scope supported is targets since the update, and link_with is no longer supported.
ERROR:
[!] Invalid Podfile file: [!] The specification of link_with in the Podfile is now unsupported, please use target blocks instead.
When I use target blocks, I get this error:
[!] Unable to find a target named MyPlayground, did find Target_1, Target_2
OR:
[!] Unable to find a target named MyPlayground.playground, did find Target_1, Target_2
Also tried adding it within Target_1 target scope:
ERROR
[!] Invalid Podfile file: [!] Unsupported options MyPlayground for target Target_1.
What is the simplest way to add a dependency to Playground source?

UPDATE
As of:
Xcode 8.2
You no longer need to add your pod folder into resources, simply use it as you would in the project.
Example:
Pre Xcode 8.1
Thanks to Eric Aya, I have found a solution based on his first suggestion.
In order to add a CocoPods framework to Playground, follow these steps:
Add pods to your pod file and hit pod install
Add a new Playground file
Click on the Sources folder in your playground
Click on the + for Add Files to Sources
Add you pod folder, in our case HanakeSwift
Import your project pods framework import Pods_PodsPlayground
Build and access your framework!
Step 3
Step 4
Step 5
Step 6, 7

In Xcode 8.2:
Click on your project name in the left column
Click "New File" and choose "Playground"
Import the pod that you have installed in your Podfile
Possibly do a build and run to get rid of the error if it temporarily can't find the pod
That's it! You should be good to go

Related

How do I archive Xcode project?

I am currently having issues when attempting to archive my project in Xcode. The following error below appears when archiving:
The link Xcode 12 Error: Multiple commands produce AccessibilityResources.bundle mentions to remove React-Core.common-AccessibilityResources from my target but I do not have this under my target. Can someone please assist?
I am using Xcode version 12.1.
This is what I have in the workspace settings:
Thank you.
I changed the derived data location but still getting the same error:
I am now seeing the below error after updating my Podfile.
Current error:
Updated Podfile:
Have a try with the below solution.
Initially clean the build cache data with the below steps:
You can go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment.
Then click over the little grey arrow under the Derived data section and select your project folder and close the workspace and Xcode then delete the project directory from the derived data directory.
Open the workspace again in Xcode and clean and rebuild the project.
Also, make sure that you have applied pod install after the package installation.
Then, open workspace and set the active scheme as Any ios Device (arm64, armv7)
Click on Project from top Xcode Menu
Then select Archive.
Have a break till the Archive process completes.
Remove the below lines from PodFile:
use_flipper!()
post_install do |installer|
flipper_post_install(installer)
end
and do pod install in ios directory.

No such module ZFDragableModalTransition in Swift

I have a xCode project. I am trying to run FolioReaderKit. I've installed the all project requirements such as CocoaPods and Carthage and I've fixed the errors except ZFDragableModalTransition.
I've downloaded it and added into my project over and over, I've added it as a Link Binary but I'm still getting same error. "No such module ZFDragableModalTransition in Swift"
I am very new in swift and Xcode therefore I might be make a mistake but I didn't manage it yet.
Do you have any suggestion?
You can see the error attached images.
If you want to run the FolioReaderKit Example project and you are new to Swift and Xcode I suggest you to use Cocoapods instead of Carthage. You don't have to run FolioReaderKit.xcodeproj.
Just go to Example folder and follow this steps:
Open the Terminal on Example folder;
Run pod install (you need Cocoapods installed);
Open Example.xcworkspace file on your Xcode and run;
To add this you your project using Cocoapods create a Podfile and add:
use_frameworks!
target 'MyApp' do
pod 'FolioReaderKit', '~> 0.7'
end
Then use pod install to install it to your project, the usage documentation is in the Example project.

Importing Alamofire 3.4 - No such module 'Alamofire'

I hava a project that need Alamofire imported and every aproach i took got me to same porblem
import Alamofire - No such module 'Alamofire'
Installed cocoapods
Edited Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'my project name' do
pod 'Alamofire', '~> 3.4'
end
$ pod install
everything was smooth and had no errors in the proces from installing cocoapods to the end.
Opened project with projectname.xcworkspace
Even tried the manually and still the same problem - No such module 'Alamofire'
Thank you for the help in advance.
After adding a framework through CocoaPods, in most conditions you are supposed to clean and build the project right away.
That should take care of adding/building the new framework to your app and make it active for use
Also, please note that another copy of your project will be created upon addition with pods, called something like 'yourProjectName.xcworkspace' (You can find it in your directory). It will have a light blue color thumbnail. After adding your pods, you must start using that copy of your project instead of the normal project.
// Note : Generally with CocoaPods, when you add a pod to your Podfile, you just need to save the Podfile and type 'podinstall' in your terminal. Make sure to get to your project directory before that. That will import the frameworks automatically. However, you do need to write import statement in your file to use it obviously
You do not need to import Alamofire framework explicitly (if using Cocoa Pods) - Umair (in comments)
Do import Alamofire and then do Build. I think it's helpful.
I had a similar issue and solved it following the below listed steps:
Realized that <projectName>.xcworkspace is what you need to be using after adding a pod to your project
Deleted the pods folder and Podfile.lock and did a pod install
Set Architectures to Standard architectures (armv7, armv7s, arm64)
Set Build Active Architectures Only to Yes
I Faced the Same Issue During the Implementation
Step 1 :
Import Alamofire
Step 2 :
Keep on Pressing Build ( Cmd + B )
Step 3:
If Issue Continues then just close your program for a moment by
completely closing it(cmd + Q) and then Restart it and Follow Step
1 & 2
This will work
Thanks
If you install dependencies using Pods, and if you are working using .xcodeproj file, it will never build prompting no such module error. You should definetely switch to .xcworkspace and you will see everything's fine. If the error persists, you should clean the project or delete derived data.

Podfile PXGoogleDirections and GoogleMaps conflicting names

I'm trying to install a new pod (PXGoogleDirections) to my already existing xcode project which already had a GoogleMaps pod installed.
platform :ios, '8.0'
use_frameworks!
target 'Roadtrip' do
pod 'GoogleMaps'
pod 'PXGoogleDirections'
end
target 'RoadtripTests' do
end
target 'RoadtripUITests' do
end
When I run "pod install" I'm getting the error: "[!] The 'PROJECT' target has frameworks with conflicting names: GoogleMaps."
Any idea how I can fix that?
I've already tried to use the same GoogleMaps version as PXGoogleDirections uses, like so:
pod 'GoogleMaps', '1.10.4'
but I'm getting the same error.
Thanks for your help.
This is because PXGoogleDirections itself is bundled with GoogleMaps. In the documentation of PXGoogleDirections says the way to use googlemaps with it.
Check this
If your app also requires the Google Maps iOS SDK, you might run into
troubles because of conflicts with the bundled Google Maps iOS SDK in
the Cocoapod. If you happen to face these problems, please try to do
the following:
Add -framework "GoogleMaps" to the "Other Linker Flags" of your Xcode
project. Make sure you are linking your app with all the libraries and
frameworks required by the Google Maps iOS SDK. For a full list, see
here:
https://github.com/CocoaPods/Specs/blob/master/Specs/GoogleMaps/1.10.4/GoogleMaps.podspec.json
Also make sure that your app contains the GoogleMaps.bundle in the
"Copy Bundle Resources" phase of the build process. If it doesn't, you
can manually add it to Xcode by browsing to the following directory in
the Finder:
/Pods/PXGoogleDirections/Dependencies/GoogleMaps.framework/Resources/GoogleMaps.bundle.
Drop it in the "Frameworks" group of your project and uncheck the
"Copy" checkbox.
Direct Link https://github.com/poulpix/PXGoogleDirections#in-case-of-problems

Xcode: ld: library not found for -lAFNetworking

Because of this one reason, build always fails...Any ideas about what I could try?
EDIT: the solution is to open the xcworkspace instead of the xcproject!
Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file.
Have the same issue.
What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1 and Adlair Cerecedo-Mendez
Delete the "Pods" project on the left panel of Xcode.
Close Xcode and delete this file in the finder too.
Install pods again.
Open Xcode and clean.
Verify that the build option "Build Active Architecture Only" is set to "NO" for your project but also for your Pods project (selection with left panel).
Click on your project Scheme (top, near the stop button) and "Manage Scheme".
Check, select all your pods libraries and close.
Then, for all libs, select them (scroll the list) and build manually for the selected architecture.
Every time you change your architecture (simulator, device or for archive(Generic iOS Device)) you must do the above step: namely, manually build each libraries by selecting them in your scroll list one by one, and only than build and run your main project.
Seems a bit WTF, but it is the only way I resolve this issue...
I Had this Issue several Times with PODS Libraries.
Here is something you can Try:
Run pod cache clean --all and pod install again.
Check your Header Search Paths and Library Search Paths, Remove all entries and place $(PROJECT_DIR) in recursive mode and $(inherited) as a Second Entry
Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.
Make sure Build Active Architecture Only is set to NO in the Pods project settings.
I'm thinking on two possibilities:
1) Install cocoapods-deintegrate project:
$ gem install cocoapods-deintegrate
Then run $ pod deintegrate, after that run $ pod install again. If it not works, then...
2) You can try open your Pods project and create new scheme for the target that you need, in this case for AFNetworking.
When the static library is created, then add it to your Frameworks references into your main project.
Hope that helps.
I have in project->TARGETS->Build Phases ->Link Binary With Libraries one "extra" framework that remains from recent project. Delate it and all run smoothly
Had a similar issue ... took a while to realize that I had updated my app's "iOS Deployment Target" to iOS 9.0, but the Pods project's "iOS Deployment Target" was still iOS 8.0!!!
I encountered this error when I downloaded some code from github. I tried to build .xcodeproj file but it failed giving the library not found error. I then opened .xcworkspace file and build that file first by clicking Product -> Build for -> Running. The workspace file built fine with no errors. Then in workspace file I changed scheme to the xcode project I was trying to build, and clicked Product -> Run. The app got built and ran with no errors.
I had this issue while using fastlane with a ReactNative project. I had added a dependency that required cocoapods.
My Fastfile looked like this:
...
gym(
scheme: "AppName",
project: "./ios/AppName.xcodeproj"
)
....
And had to change it to the workspace like this:
...
gym(
scheme: "AppName",
workspace: "./ios/AppName.xcworkspace"
)
...
For me all this thing not help. Only delete in Build settings project.
open xcode, from the top left select the pod library that is being shown as not found.Use 'Command B' to build this pod, then again select your target scheme and run.
For me this fixed it.
Use the xcworkspace to build instead of the xcproject?
This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries.

Resources