nstudio / nativescript-cardview

:diamonds: :clubs: NativeScript widget for Material Design CardView
MIT License
282 stars 51 forks source link

Can't find variable MaterialCardView on iOS #12

Closed burkeholland closed 8 years ago

burkeholland commented 8 years ago

When I try and use the plugin, it throws an error Can't find variable MaterialCardView on iOS. If I try and do a tns debug ios --emulator, it throws a wall of Swift linking errors.

System

NativeScript 1.7 iOS 9.2 Xcode 7.2.1

Steps To Reproduce

tns create my-app && cd my-app && tns platform add ios
tns plugin add nativescript-cardview

Add the following markup to your page

<page xmlns="http://schemas.nativescript.org/tns.xsd"                
      xmlns:card="nativescript-cardview">

      <stack-layout><!-- Home page contents -->
        <card:CardView margin="10">
           <grid-layout rows="200, auto, auto" columns="auto, auto, *">
               <image src="~/images/batman.jpg" stretch="aspectFill" colSpan="3" row="0" />
               <label text="Batman wants to be friends?" class="info" textWrap="true" row="1" colSpan="3" />          
               <button text="DECLINE" tap="goAway" class="clear-btn blue" row="2" col="0" />
               <button text="ACCEPT" class="clear-btn blue" row="2" col="1" />
           </grid-layout>
        </card:CardView>
      </stack-layout>

</page>

Run in the emulator

tns deploy ios --emulator

Error is thrown

Mar 18 16:37:11 hollandmac nativescriptnova[6301]: file:///app/tns_modules/ui/builder/builder.js:154:56: JS ERROR Error: Building UI from XML. @file:///app/pages/cards/simple-card.xml:16:9
     ↳Module '/Users/burkeholland/Library/Developer/CoreSimulator/Devices/FAE7B936-79CE-46C4-859F-65506A603837/data/Containers/Bundle/Application/4B9CC923-5319-4FD0-AE7D-37449DA4E814/nativescriptnova.app/app/tns_modules/nativescript-cardview' not found for element 'nativescript-cardview:CardView'.
       ↳Can't find variable: MaterialCardView
Mar 18 16:37:11 hollandmac com.apple.CoreSimulator.SimDevice.FAE7B936-79CE-46C4-859F-65506A603837.launchd_sim[2575] (UIKitApplication:org.nativescript.nativescriptnova[0x330e][6301]): Service exited due to signal: Segmentation fault: 11

Run tns debug ios --emulator. I've attached the text file with the linker errors. linker.txt

Suggested Solution

I'm pretty sure iOS simply can't build that CocoaPod. I noticed that the target version for the Pod is 8.0, but that should just be the minimum version, not the absolute target version. I check the CocoaPod docs for Podfiles and there was no mention of a minimum version, only a target version.

I have no idea.

NathanWalker commented 8 years ago

I'll investigate this weekend.

In meantime, try this:

Open the .xcworkspace file in the platforms/ios folder, then run the 2nd target (it will have a '2' next to it in the available run targets drop down in XCode). Lemme know if it runs that way.

burkeholland commented 8 years ago

I was able to build the 2nd target in Xcode successfully.

NathanWalker commented 8 years ago

I'm working on a much simpler and stable Material Design Card View for iOS. About have it done locally, it will end up here: https://github.com/NathanWalker/MaterialCard

That iOS version will be published as CocoaPod to then be used here. I'll post back when it's all complete and ready.

NathanWalker commented 8 years ago

@burkeholland I've posted an issue here about some things I found while debugging this issue: https://github.com/NativeScript/ios-runtime/issues/536

Additionally, it's worth noting that using tns run ios will work fine. It's isolated to emulating via the Simulator. The workaround mentioned above is the only way at the moment to run this plugin in the iOS Simulator.

burkeholland commented 8 years ago

Looks like Xcode 7.3 fixes the issue with having to downgrade. Nice troubleshooting BTW. Well done. I'll change my version and see what happens.

NathanWalker commented 8 years ago

The new XCode 7.3 does fix the issue on a "fresh add and run". Subsequent runs will result in strange error: https://github.com/NativeScript/ios-runtime/issues/538

Hopefully will be fixed soon. But good news is yes 7.3 does solve the issue. Hooray! Just be sure to run this everytime:

rm -rf demo/platforms
npm run demo.ios

....to demo this plugin successfully until the runtime is fixed.

I'm about to release a new version of this which makes the iOS side even better using the new simpler implementation and new properties which can be set to customize it's look.

NathanWalker commented 8 years ago

1.1.0 released and available now.

bradmartin commented 8 years ago

This good @NathanWalker @burkeholland ?

NathanWalker commented 8 years ago

Still awaiting ios runtime/cli 1.7.2 actually: https://github.com/NativeScript/nativescript-cli/issues/1639

Shouldn't be much longer.

bradmartin commented 8 years ago

2.0.0 fix this? Just cleaning issues, no rush or worries.

jlooper commented 8 years ago

Reporting back! I ran into this issue but it appeared to be because the MaterialCard cocoapod didn't initially install. I opened Xcode and built the target as recommended above, and the pod was installed and the card shows up using livesync. So ... I think you can close this, Nathan! Thanks, everyone!