Copy from Mac OS X does not copy to iPhone Simulator
I was getting frustrated with copy and paste in the simulator and couldn't figure out what was going on.
Results were similar to what you describe: copy and paste would sometimes paste the same value as I had copied before, but not what I just copied to the clipboard.
I finally realized that the simulator has it's own clipboard, separate from the main OS X clipboard.
You use the touch-based copy and paste commands to paste into your application from the simulator clipboard.
You can use the standard OS X copy paste shortcuts (Command-X,C,V) to paste from the system clipboard into the simulator clipboard.
So to copy and paste from Chrome (for example), you select the text in Chrome, Command-C to copy. Then switch to the simulator, Command-V to paste into the simulator clipboard. Then in your application, you simulate a touch in the textfield to bring up the paste option, then simulate a touch to the paste button to paste the simulator clipboard contents into the app.
The menu options do the same thing as the keyboard shortcuts--copy/paste between the system clipboard and the simulator keyboard.
Now that I figured it out, I actually like it much better than if the simulator clipboard was automatically tied to the OS X clipboard.
From Xcode 9.0 or above:
Click on "Edit" from top menus
Enable -> "Automatically Sync Pasteboard"
If already enable then disable it and enable again.
Long press to paste your text i.e copied
Below Xcode 9.0
- Copy text from anywhere
- Paste on the simulator by command (command + v), it will show nothing
- Then press (command + shift + v)
it works for me
- ⌘ + C - Copies the contents of the iOS clipboard to OS X. This works for both text and images.
- ⌘ + ⇧ + C - Copies the selected text (or whatever else responds to the copy: selector in your app) to the iOS clipboard. This one does not appear in the menu.
- ⌘ + ⌃ + C - Copies a screenshot of the iOS app (without the simulator's chrome) to the OS X clipboard (Use ⌘ + S to save it to a file on the Desktop instead).
- ⌘ + V - Copies the contents of the OS X clipboard over to iOS, but doesn't paste it. Again, this works for both text and images.
- ⌘ + ⌃ + V - Pastes the OS X clipboard in the iOS app, but leaves the clipboard unchanged. This does not work with images.