问题
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 oflink_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 findTarget_1
,Target_2
OR:
[!] Unable to find a target named
MyPlayground.playground
, did findTarget_1
,Target_2
Also tried adding it within Target_1
target
scope:
ERROR
[!] Invalid
Podfile
file: [!] Unsupported optionsMyPlayground
for targetTarget_1
.
What is the simplest way to add a dependency to Playground source?
回答1:
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
回答2:
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
来源:https://stackoverflow.com/questions/40338698/how-to-add-a-cocoapod-framework-to-xcode-8-playground