Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 11/Xcode 9 compatibility #218

Closed
6 tasks done
kelvindart opened this issue Sep 14, 2017 · 36 comments · Fixed by #219
Closed
6 tasks done

iOS 11/Xcode 9 compatibility #218

kelvindart opened this issue Sep 14, 2017 · 36 comments · Fixed by #219
Assignees
Labels

Comments

@kelvindart
Copy link

kelvindart commented Sep 14, 2017

Expected behavior

To be able to deploy to the iOS simulator when Xcode 9 is installed with the iOS 11 SDK, with the ability to select the additional simulators from the list.

Actual behavior.

When I try to run cordova emulate ios without specifying a default device, I receive the following error:

No target specified for emulator. Deploying to undefined simulator

Device type "com.apple.CoreSimulator.SimDeviceType.undefined" could not be found.
[ERROR] An error occurred while running cordova emulate ios (exit code 1).

Despite there being default simulators installed, it appears like it is not selecting the first relevant simulator, instead, just whatever is at the top of the list.

If I run ios-sim showdevicetypes, I am returned the following list, which is omitting the new simulators (iPhone 8, iPhone 8 Plus and the iPhone X), and has the Apple-Watch listed at the start (which, as explained below, is now the default):

Apple-Watch-38mm, watchOS 4.0
Apple-Watch-42mm, watchOS 4.0
Apple-Watch-Series-2-38mm, watchOS 4.0
Apple-Watch-Series-2-42mm, watchOS 4.0
iPhone-5s, 11.0
iPhone-6, 11.0
iPhone-6-Plus, 11.0
iPhone-6s, 11.0
iPhone-6s-Plus, 11.0
iPhone-7, 11.0
iPhone-7-Plus, 11.0
iPhone-SE, 11.0
iPad-Air, 11.0
iPad-Air-2, 11.0
iPad--5th-generation-, 11.0
iPad-Pro--12-9-inch---2nd-generation-, 11.0
iPad-Pro--10-5-inch-, 11.0
Apple-TV-1080p, tvOS 11.0
Apple-TV-4K-4K, tvOS 11.0
Apple-TV-4K-1080p, tvOS 11.0
iPad-Pro--9-7-inch-, 11.0
iPad-Pro, 11.0

If I then run ios-sim start, it states:

--devicetypeid was not specified, using first available device: Apple Watch - 38mm.

I expect, because of this, it's trying to deploy the Cordova app to the Apple Watch, hazard a guess?

If I do specify an iOS emulator to deploy to, I receive the following:

$ ionic cordova emulate ios --target="iPhone-7"
...
No available runtimes could be found for "iPhone 7".
[ERROR] An error occurred while running cordova emulate ios --target iPhone-7 (exit code 1).

Steps to reproduce the problem

As above (assuming Cordova and ios-sim are installed).

  1. Start a blank Cordova project: cordova start SimApp && cd SimApp
  2. Run the app: cordova emulate ios --target="iPhone-7"

System Specs

Please run the commands below in your Terminal.app and include it in the issue. Check when done and include results below.

  • 1. system_profiler SPSoftwareDataType
  • 2. ios-sim --version
  • 3. xcodebuild -version
  • 4. xcode-select --print-path
  • 5. node --version
  • 6. npm --version

1. system_profiler SPSoftwareDataType:

System Software Overview:

  System Version: macOS 10.12.6 (16G29)
  Kernel Version: Darwin 16.7.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: Kelvin’s MacBook Pro
  User Name: Kelvin Dart (kelvindart)
  Secure Virtual Memory: Enabled
  System Integrity Protection: Enabled
  Time since boot: 1 day 6:13

2. ios-sim --version:

6.0.0

3. xcodebuild -version:

Xcode 9.0
Build version 9A235

4. xcode-select --print-path:

/Applications/Xcode.app/Contents/Developer

5. node --version:

v8.2.1

6. npm --version:

5.4.1
@shazron
Copy link

shazron commented Sep 15, 2017

Investigating why it's not showing the new sims.

@shazron shazron self-assigned this Sep 15, 2017
@shazron shazron added the bug label Sep 15, 2017
@shazron shazron added this to the 6.0.1 milestone Sep 15, 2017
@shazron
Copy link

shazron commented Sep 15, 2017

7 device types are skipped on this line: https://github.com/phonegap/ios-sim/blob/4bbe6b3307b594d9bf78775418fea139e71eabb1/src/lib.js#L330

iPhone 8, 11.0
iPhone 8 Plus, 11.0
iPhone X, 11.0
Apple Watch Series 3 - 38mm, watchOS 4.0
Apple Watch Series 3 - 42mm, watchOS 4.0
Apple TV 1080p, tvOS 11.0
iPad Pro, 9.3

@shazron
Copy link

shazron commented Sep 15, 2017

If you run xcrun simctl list devicetypes you will see the new devices are curiously named (obfuscated?):

== Device Types ==
[..irrelevant device types removed...]
iPhone2017-A (com.apple.CoreSimulator.SimDeviceType.iPhone-8)
iPhone2017-B (com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus)
iPhone2017-C (com.apple.CoreSimulator.SimDeviceType.iPhone-X)
iPad Pro (9.7-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)
iPad Pro (12.9-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-)
iPad Pro (10.5-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-)
Apple TV (com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple TV 4K (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K)
Apple TV 4K (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p)
Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
Apple Watch Series 2 - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)
Watch2017 - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm)
Watch2017 - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm)

which don't correspond to the device names when running xcrun simctl list devices (this command lists devices per runtime version). I think this is a bug in xcrun simctl list devicetypes where they did not change the device type names properly. This is apparent in the Apple Watch Series 3 and the new 2017 iPhones, and also the "Apple TV 1080p" for tvOS 11.0.

Also, weirdly the 12.9" iPad Pro is this, just plain iPad-Pro:
iPad Pro (12.9-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)

"iPad Pro, 9.3" is similarly missing in devicetypes since it is now iPad-Pro--9-7-inch-

@shazron
Copy link

shazron commented Sep 15, 2017

I hate to do this, but we may have to do a mapping function to match the mismatched devicetypes.

@shazron
Copy link

shazron commented Sep 15, 2017

See #219 PR, fixes this issue

@kelvindart
Copy link
Author

kelvindart commented Sep 15, 2017

Wow - rapid response :) thanks @shazron. I will check it out. How do I raise the bug against Xcode, if this is Apple's doing?

@kelvindart
Copy link
Author

I have just seen you were up late fixing this - thanks for the dedicated effort.

shazron added a commit that referenced this issue Sep 15, 2017
…219)

* Shows devicetypes for new iPhones, Apple Watches released fall 2017

This closes #218
@jmargolese
Copy link

I have installed ios-sim v6.1.1 and am seeing exactly the same behavior as @kelvindart in the OP above.

I am able to launch the simulator from Xcode 9, just not from the cli.

Is there something else that needs to be done on my end to resolve this?

thx

@shazron
Copy link

shazron commented Sep 19, 2017

Not enough info. Are you using cordova-ios? There needs to be a platform update since ios-sim is baked in there.

@MaxDaten
Copy link

@shazron same probleme here, and yes I'm using cordova-ios. So we have to wait for an platform update…

@kelvindart
Copy link
Author

kelvindart commented Sep 19, 2017

@jmargolese and @MaxDaten, since updating to ios-sim@6.1.1, it works fine for me.

Make sure to follow @shazron's point on the platform update (i.e. update cordova-ios to the latest, cordova-ios@4.5.0)

First, check which version you are running in your local project:

$ cordova platforms

Then remove it, and add the latest version:

$ cordova platform rm ios
$ cordova platform add ios@4.5.0

This will install the latest, which is compatible with Xcode 9/iOS 11 and sims. Also, follow the point on Cordova's blog (https://cordova.apache.org/announcements/2017/09/08/ios-release.html) about cordova-plugin-console.

I believe the console is now integrated into the platform to use window.console.log (is that right @shazron?).

@kelvindart
Copy link
Author

There is a minor issue when running:

$ ios-sim showsdks

But I will open a separate issue for this.

@KevinBeckers
Copy link

Using 4.5.0 solves the issue for me, but forces me to rollback to use 4.4.0 because of:
duplicate symbol _OBJC_CLASS_$_CDVLogger

Issue #12849
Solution: #12849 (comment)

@jmargolese
Copy link

I can't tell if 4.5.0 solves the problem. After following @kelvindart 's suggestions, the build command fails with the same problem @KevinBeckers reports above.

@MaxDaten
Copy link

@kelvindart it works for me with ios@4.5.0. Thanks!

@shazron
Copy link

shazron commented Sep 21, 2017

All, remove the cordova-plugin-console plugin. See the cordova-ios@4.5.0 blog post:
http://cordova.apache.org/announcements/2017/09/08/ios-release.html

@KevinBeckers
Copy link

@shazron This fixed my issue.

@jezmck
Copy link

jezmck commented Sep 21, 2017

Although my issue isn't quite the same as the original issue, it seems likely related, especially re @shazron's fix.

I get No available runtimes could be found for "iPhone2017-C".
after running cordova run ios --target="iPhone-X"

I've removed cordova-plugin-console.
I have

  • Cordova v7.0.1
  • platform ios v4.5.0
  • node --version v7.10.0
  • npm --version 4.2.0

Any suggestions?

@shazron
Copy link

shazron commented Sep 21, 2017

@jezmck ios-sim has been updated in cordova-ios master branch. Unfortunately you will have to wait for cordova-ios@4.5.1 release (we are starting the vote tomorrow, so prob released next week) or just cd platforms/ios/cordova && npm install ios-sim@latest in your project

@jezmck
Copy link

jezmck commented Sep 21, 2017

That's amazing, thank you!

@Ericdowney
Copy link

I'm running an ionic app.

Setup

  • Ionic - 3.10.3
  • Cordova - 7.0.1
  • Node - v6.10.2
  • NPM - 3.10.10
  • Platform iOS - ios@4.5.0

I am also receiving the No available runtimes could be found for "iPhone2017-C". when I run ionic cordova run ios --target iPhone-X

I ran the cd platforms/ios/cordova && npm install ios-sim@latest command and then when attempting to run the app I received this error:

Error: tsconfig: Cannot read file '/platforms/ios/cordova/tsconfig.json': ENOENT: no such file or directory, open '/platforms/ios/cordova/tsconfig.json'.

Any ideas?

@PeterStegnar
Copy link

@Ericdowney Looks like interesting situation ..

I suggest that you do:

  • reinstall platform ios (@latest)
  • reinstall all plugins
  • "build" cordova
  • if still does not work open project in xcode and examine there errors

I had similar problem liek you, and for example I got a swift version error in xcode (that I have unsuported swift 2 code ...) then I set in xcode in project config to swift 3.2 and then it started to work. So in the end check generated project in xcode.

@brandyscarney
Copy link

Error: tsconfig: Cannot read file '/platforms/ios/cordova/tsconfig.json': ENOENT: no such file or directory, open '/platforms/ios/cordova/tsconfig.json'.

@Ericdowney Make sure you change directories back to the root of your project before running the ionic cordova run command. I ran into the same error, and running it from the root of the project works. I brought this up to the team (I work at Ionic) to see if we can resolve the need to run this at the root.

@ariel-ibarra-jd
Copy link

ariel-ibarra-jd commented Sep 27, 2017

If you are getting: No available runtimes could be found
after running: cordova run ios --target="iPhone-#"

Try the approach suggested by @shazron
cd platforms/ios/cordova && npm install ios-sim@latest

@herberzt
Copy link

herberzt commented Oct 5, 2017

I ran: cd platforms/ios/cordova && npm install ios-sim@latest and this works for iPhone-6-Plus but it's still failing when I try to emulate iPad-Pro.
Any suggestions?

@surajpindoria
Copy link

Hey @herberzt,

I just tried this and it launched in the simulator just fine. What is the error message you are seeing?

@herberzt
Copy link

hey @surajpindoria sorry I just now saw this.

when i run : $ phonegap run ios --target "iPad-Pro" --emulator

I get a large thing of output but the main error at the bottom is:
Device type "com.apple.CoreSimulator.SimDeviceType.iPad-Pro" could not be found.

@surajpindoria
Copy link

@herberzt, I just tried this again in a different project and was actually able to see the same error as you. But I was able to get rid of it by removing the iOS platform and then re-adding it. Make sure you are using the latest version, cordova platform add ios@latest.

@herberzt
Copy link

@surajpindoria okay I will give this a try. Thank you.

@herberzt
Copy link

@surajpindoria I took your guidance and did the following:

$ rm -rf platforms/ios
$ phonegap platform add ios@latest
$ bin/clean-build.sh which runs a bunch of commands and essentially gets cocopods in place etc.

went to go run the simulator again and I'm still getting the same error message.

@surajpindoria
Copy link

Hmmm, are you able to deploy to the iPad Pro emulator directly from Xcode? You can open your project in Xcode by running open <project-dir>/platforms/ios/<project-name>.xcworkspace.

@surajpindoria
Copy link

@herberzt Just noticed something on my machine that could explain why you are not able to launch the iPad Pro emulator. Can you run ios-sim showdevicetypes. On a machine using Xcode 9.0 I see an option for just plain iPad Pro. But on another that is using Xcode 9.0.1 I do not see it, but instead see iPad-Pro--10-5-inch- and iPad-Pro--12-9-inch---2nd-generation-.

This could explain why you are not able to launch the emulator.

@holographix
Copy link

holographix commented Nov 22, 2017

Had this issue today, after updating to ionic 3.19.0.
Using the approach suggested by @shazron worked out

cd platforms/ios/cordova && npm install ios-sim@latest; cd ../../../

@ghost
Copy link

ghost commented Aug 24, 2018

when I run ionic cordova build ios --prod. I have a error

cordova build ios
Error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

[ERROR] An error occurred while running cordova build ios (exit code 1).

how to handle this ?

@shazron
Copy link

shazron commented Aug 24, 2018

@pangjianfeng this is not a Cordova issue tracker. Looks like you need to install the full Xcode and for example put it in /Applications. Then sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/

@shabeer3508
Copy link

shabeer3508 commented Nov 16, 2019

@jezmck ios-sim has been updated in cordova-ios master branch. Unfortunately you will have to wait for cordova-ios@4.5.1 release (we are starting the vote tomorrow, so prob released next week) or just cd platforms/ios/cordova && npm install ios-sim@latest in your project

Thank you saved my day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.