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

Compatibility with XCode 7.3 #538

Closed
NathanWalker opened this issue Mar 22, 2016 · 5 comments
Closed

Compatibility with XCode 7.3 #538

NathanWalker opened this issue Mar 22, 2016 · 5 comments

Comments

@NathanWalker
Copy link
Contributor

7.3 fixes a number of problems with 7.2, namely this very frustrating issue for us plugin developers:
#536

The only problem though is (as @raef mentioned on Slack), on subsequent build/runs:

Expected "/*", "//" or "{" but "<" found. It appears that platforms/ios/Pods/Pods.xcodeproj/project.pbxproj file is getting converted to XML when it is expected to be JSON.

If you remove platforms and add clean via tns platform add ios, everything builds and runs perfectly. Awesome.

So it appears the only issue is just subsequent runs after the platform has been added.
Any insight or patch that could be incorporated to resolve this would be very much appreciated.

@NathanWalker
Copy link
Contributor Author

To help in debugging the above for whomever may tackle the fix here:

  1. git clone https://github.com/bradmartin/nativescript-cardview.git
  2. npm run setup // you will see warnings, it's ok
  3. npm run demo.ios // more warnings, it will run just fine though

You should see Simulator open and the demo running properly.

Now stop ctrl + c, then:

cd demo
tns emulate ios

And you will see the error reported:

Expected "/*", "//" or "{" but "<" found.

@NathanWalker
Copy link
Contributor Author

As reported by @raef (on slack) This appears to be a workaround for those working on NativeScript projects with CocoaPods.
Ensure you have this tool installed:

brew install xcproj

Then add this as an npm script (replace YourApp with your actual project name!!):

  • package.json
"scripts": {
   "ios": "xcproj --project platforms/ios/YourApp.xcodeproj touch; xcproj --project platforms/ios/Pods/Pods.xcodeproj touch; tns livesync ios --emulator --watch"
}

Then run everything through that so:

npm run ios

@raefa
Copy link

raefa commented Mar 22, 2016

As discussed in the Slack iOS channel I got this going. Thanks to @alg as he helped me figure this out (doing a diff between his files and mine). So the issue is caused by “pod install” converting the “.pbxproj” files (within the xcodeproj files) to XML. NativeScript expects them to be in JSON. The problem is explained in a little more detail here: https://github.com/CocoaPods/CocoaPods/wiki/Generate-ASCII-format-xcodeproj

I don’t know why it changes or why it is only happening now with Xcode 7.3. I read here (https://github.com/CocoaPods/CocoaPods/wiki/Generate-ASCII-format-xcodeproj) that if you touch the files it converts them back to JSON. I tried the technique they specified but that did not work. So I installed xcproj (brew install xcproj see: https://github.com/0xced/xcproj/blob/develop/README.md) and then played around touching the project files. I found that I needed to convert both the platforms/ios/ExampleApp.xcodeproj (replace ExampleApp with your app name) and the platforms/ios/Pods/Pods.xcodeproj file. So to do that run:

xcproj --project "platforms/ios/ExampleApp.xcodeproj" touch
xcproj --project "platforms/ios/Pods/Pods.xcodeproj" touch

That is a bit of a pain to type in every time so I created some quick bash scripts to run to build. E.g.

#!/bin/bash
echo LiveSync to Simulator
xcproj --project "platforms/ios/HotHealthApp.xcodeproj" touch
xcproj --project "platforms/ios/Pods/Pods.xcodeproj" touch
tns livesync ios --emulator --watch

I hope that helps.

@jasssonpet
Copy link
Contributor

This seems to be coming from node-xcode not being able to parse xml projects. I'm moving this to the CLI repo.

@jasssonpet
Copy link
Contributor

This issue was moved to NativeScript/nativescript-cli#1639

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

No branches or pull requests

3 participants