2016-02-19 83 views
0

我試圖實現這種反應機組件(react-native-geocoder)到我目前的應用程序,並出現以下錯誤:陣營母語:RNGeocoder.reverseGeocodeLocation - 可能未處理的承諾拒絕

[]([warn][tid:com.facebook.React.JavaScript] Possible Unhandled Promise 

Rejection (id: 0): 
undefined is not an object (evaluating 'RNGeocoder.reverseGeocodeLocation') 
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:61745:11 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:2626:3 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:2781:19 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:2647:10 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:61743:19 
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:15334:34 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:76:17 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:44:30 
[email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:36:19 
global [email protected]://localhost:8081/index.ios.bundle?platform=ios&dev=true:61774:9 
) 

我的代碼

var RNGeocoder = require('react-native-geocoder'); 

// Reverse Geocoding 
var NY = { 
    latitude: 40.7809261, 
    longitude: -73.9637594 
}; 

RNGeocoder.reverseGeocodeLocation(NY, (err, data) => { 
    if (err) { 
    return; 
    } 

    console.log(data); 
}); 

我的設置有任何設置問題嗎?我使用最新的反應原生版本。

回答

1

它看起來像你忘了在你的項目中包含libRNGeocoder.a。你是否像寫在組件中一樣添加它?

  1. In the XCode's "Project navigator", right click on Libraries folder under your project ➜ Add Files to <...>
  2. Go to node_modules ➜ react-native-geocoder and add the RNGeocoder.xcodeproj file
  3. Add libRNGeocoder.a to Build Phases -> Link Binary With Libraries
+0

非常感謝這是問題 – AppVault

相關問題