CocoaPods / pod-template

An opinionated template for creating a Pod.
Other
398 stars 404 forks source link

Creating a lib without an example creates an Example directory #204

Open sssilver opened 7 years ago

sssilver commented 7 years ago

$ pod lib create always creates a directory called Example and puts the workspace in it, even when asked not to create an example project.

Even if functionally this makes sense (a library needs a workspace to be opened in Xcode and worked on), semantically in this case the name "Example" is a nonsense.

Creating a library without an example

» ~/projects/iOS  $ pod lib create LibWithoutExample
Cloning `https://github.com/CocoaPods/pod-template.git` into `LibWithoutExample`.
Configuring LibWithoutExample template.

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide:
 - http://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and click links to open in a browser. )

What language do you want to use?? [ Swift / ObjC ]
 >
swift
Would you like to include a demo application with your library? [ Yes / No ]
 > No

Which testing frameworks will you use? [ Quick / None ]
 >
quick
Would you like to do view based testing? [ Yes / No ]
 >
yes Putting demo application back in, you cannot do view tests without a host application.

Running pod install on your new library.

Analyzing dependencies
Fetching podspec for `LibWithoutExample` from `../`
Downloading dependencies
Installing FBSnapshotTestCase (2.1.4)
Installing LibWithoutExample (0.1.0)
Installing Nimble (5.1.1)
Installing Nimble-Snapshots (4.4.0)
Installing Quick (1.0.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `LibWithoutExample.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 5 total pods installed.

 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'LibWithoutExample/Example/LibWithoutExample.xcworkspace'

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `http://guides.cocoapods.org/making/making-a-cocoapod`.

What the directory tree looks like

» ~/projects/iOS  $ tree LibWithoutExample -L 2
LibWithoutExample
├── Example
│   ├── LibWithoutExample
│   ├── LibWithoutExample.xcodeproj
│   ├── LibWithoutExample.xcworkspace
│   ├── Podfile
│   ├── Podfile.lock
│   ├── Pods
│   └── Tests
├── LICENSE
├── LibWithoutExample
│   ├── Assets
│   └── Classes
├── LibWithoutExample.podspec
├── README.md
└── _Pods.xcodeproj -> Example/Pods/Pods.xcodeproj

10 directories, 5 files

CocoaPods Environment

   CocoaPods : 1.2.0
        Ruby : ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.12.3 (16D32)
       Xcode : 8.2.1 (8C1002)
         Git : git version 2.11.1
Ruby lib dir : /Users/aharutyunyan/.rbenv/versions/2.3.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 537682fdc3f32ccf2e23e6dfbb802292f15df26f
               rmn-cocoa-podspecs - ssh://git@stash.rmn.com:7999/mbl/cocoa-podspecs.git @ 29142e9f9de5ae0e15f9717b145564af5db8854c

Installation Source

Executable Path: /Users/aharutyunyan/.rbenv/versions/2.3.1/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.1.2
cocoapods-try         : 1.1.0
jugutier commented 7 years ago

Hi @sssilver, This is intended behavior. As you can see in your output logs Putting demo application back in, you cannot do view tests without a host application.

If you don't want an example application you can't have view based testing as those require a host application.

Best, Julian

paulmelnikow commented 7 years ago

Hmm, when view tests are turned off, the behavior is the same. It still creates an Example directory, even when no example project is requested.

pejalo commented 6 years ago

I also don't understand the directory structure. Every CocoaPod repo on GitHub has a .xcodeproj file in the root directory for editing and building source files. Where did this come from?

dnkoutso commented 6 years ago

The .xcodeproj is used for development by the developer. It can also be used if you decide not to use CocoaPods and just clone the repo as a submodule (or copy paste the contents) and then drag the .xcodeproj manually into your project.

The .podspec basically represents the same sources as the .xcodeproj but for CocoaPods. A lot of issues often arise due to this inconsistency and generally it would be great if the .xcodeproj is just generated by the .podspec instead.

pejalo commented 6 years ago

...or by pod lib create!

inderdeep25 commented 6 years ago

has anyone found a solution to this yet ?

jugutier commented 6 years ago

TL;DR :

I only see the framework scheme (so no app target), so other than the name of the folder being example (and it not being too descriptive) I see no issues. If you add view based testing it'll add back the app target because it's required for view testing.

Let us know if there's still an issue. Otherwise we'll close this in a couple of days.

Long version:

@inderdeep25 For this input:

pod lib create MyLib
Cloning `https://github.com/CocoaPods/pod-template.git` into `MyLib`.
Configuring MyLib template.

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide:
 - http://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and click links to open in a browser. )

What language do you want to use?? [ Swift / ObjC ]
 >
swift
Would you like to include a demo application with your library? [ Yes / No ]
 > no

Which testing frameworks will you use? [ Quick / None ]
 >
quick
Would you like to do view based testing? [ Yes / No ]
 > no

Running pod install on your new library.

Analyzing dependencies
Fetching podspec for `MyLib` from `../`
Downloading dependencies
Installing MyLib (0.1.0)
Installing Nimble (7.0.3)
Installing Quick (1.2.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `MyLib.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.

[!] Automatically assigning platform ios with version 9.3 on target MyLib_Tests because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'MyLib/Example/MyLib.xcworkspace'

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `http://guides.cocoapods.org/making/making-a-cocoapod`.

I am getting this directory structure:


tree -L 3
.
└── MyLib
    ├── Example
    │   ├── MyLib.xcodeproj
    │   ├── MyLib.xcworkspace
    │   ├── Podfile
    │   ├── Podfile.lock
    │   ├── Pods
    │   └── Tests
    ├── LICENSE
    ├── MyLib
    │   ├── Assets
    │   └── Classes
    ├── MyLib.podspec
    ├── README.md
    └── _Pods.xcodeproj -> Example/Pods/Pods.xcodeproj

And when opening the project, I only see the framework scheme (so no app target), so other than the name of the folder being example (and it not being too descriptive) I see no issues.

screen shot 2018-01-03 at 10 56 39 pm
revolter commented 6 years ago

@jugutier, But isn't the MyLib.xcodeproj in the Example folder used as a demo application?

teameh commented 6 years ago

I'm struggling with this as well.

so other than the name of the folder being example (and it not being too descriptive) I see no issues.

Well it causes some confusion 😅

2 xcode projects are generated and a workspace that combine the 2 projects.

MyLib
├── Example
│   ├── MyLib.xcodeproj
│   ├── MyLib.xcworkspace
│   ├── Pods
│   │   ├── Pods.xcodeproj
... ... ...

So the workspace should be used for development? Sources of your pod can be found in the Pods.xcodeproj in Development Pods/MyLib? And tests in the other project in the workspace: MyLib.xcodeproj in Tests:

picture 2018-07-18 at 14 23 56

But then again:

picture 2018-07-18 at 14 27 58

jugutier commented 6 years ago

I’ll take another look at this tonight. Are you entering the same input to the interactive menu? @teameh

teameh commented 6 years ago

Thanks for the quick reply! \0/

Yes:

$ pod lib create MyLib
Cloning `https://github.com/CocoaPods/pod-template.git` into `MyLib`.
Configuring MyLib template.

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide:
 - https://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and click links to open in a browser. )

What platform do you want to use?? [ iOS / macOS ]
 > iOS

What language do you want to use?? [ Swift / ObjC ]
 > Swift

Would you like to include a demo application with your library? [ Yes / No ]
 > No

Which testing frameworks will you use? [ Quick / None ]
 > None

Would you like to do view based testing? [ Yes / No ]
 > No

Running pod install on your new library.

Analyzing dependencies
Fetching podspec for `MyLib` from `../`
Downloading dependencies
Installing MyLib (0.1.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `MyLib.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Automatically assigning platform `ios` with version `9.3` on target `MyLib_Tests` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'MyLib/Example/MyLib.xcworkspace'

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `http://guides.cocoapods.org/making/making-a-cocoapod`.
jugutier commented 6 years ago

Hi @teameh

Sorry for the delay.

We'll change the folder name to something other than example (at least for this configuration) I think it definitely is confusing for that setup.

In the meantime yes, use the xcworkspace to develop and run pod install periodically in the test framework to make sure your podspec includes every file & asset the way you want.

Essentially MyLib.xcodeproj is a test framework target to which you pod install your local development pod. the xcworkspace holds both together so you can test and run the code as you develop it.

Let me know if that makes sense 👍

teameh commented 6 years ago

Yeah I think that makes sense. 👍

And maybe this is a bit off-topic... but I think it would also be nice if the pod lib create cli would (also) provide an option to scaffold a project with a fixed xcode project instead of a xcode project that is generated when you pod install the example app. I ran into a problem with creating a pod that required a build script to be ran during development (and not when compiled in users' app's). But if I add it to the generated xcode project it's gone every time I run pod install. It probably makes sense for most users to have this generated approach. but not for everyone.

EdemAttiogbe commented 6 years ago

Hi @jugutier

Any idea when the changes discussed with @teameh above will be implemented? As of Cocoapods version 1.5.3, the behavior above is still the same, and I can concur that it's really confusing.

Also, as an addition, when an example project is specified in the questionnaire presented by pod lib create, can there be two separate directory trees for both the example project and the actual pod? For example, something like below...

MyLib ├── MyLib.xcworkspace ├── Example │ ├── MyLib.xcodeproj ├── MyLib │ │ ├── Pods.xcodeproj │ │ ├── Assets │ │ ├── Classes

I never really understood why the Xcode workspace is within the 'Example' directory when it contains both the pod and example(if one is specified) projects.

orta commented 6 years ago

No time frame I'm afraid, CocoaPods is just something people work on in their spare time - if you'd to see the change, you're welcome to take a look at shipping a PR 👍