Closed Jarred-Sumner closed 7 years ago
Hey @Jarred-Sumner. It might be an XCode 8 / Swift 2.3 3.0 issue.
I'll have a look tonight and ensure it's compatible.
Meanwhile, take a look at #7 and #13 to see if either of those are helpful. If they are, make sure to post your findings here.
Thanks.
I got it mostly working.
I ended up:
It felt pretty hacky though - would be great if it worked out of the box (and ideally supported RNPM)
On Mon, Sep 19, 2016 at 8:25 AM Joshua Pinter notifications@github.com wrote:
Hey @Jarred-Sumner https://github.com/Jarred-Sumner. It might be an XCode 8 / Swift 2.3 3.0 issue.
I'll have a look tonight and ensure it's compatible.
Meanwhile, take a look at #7 https://github.com/joshuapinter/react-native-unified-contacts/issues/7 and #13 https://github.com/joshuapinter/react-native-unified-contacts/pull/13 to see if either of those are helpful. If they are, make sure to post your findings here.
Thanks.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-248025592, or mute the thread https://github.com/notifications/unsubscribe-auth/AArTS4EpVYPgii0zSIHJnK4lQ0KVPFqaks5qrqlTgaJpZM4KAJIv .
You bet. I'll get this updated tonight so it "Just Works".
RNPM works great for Obj-C libraries but doesn't know what to do with Swift libraries. I'm sure I can get it working with some manual RNPM instructions, though.
Stay tuned.
Hey guys, I can confirm this issue. Just updated to iOS 10/Xcode 8.
Hey Gents, spent the last couple days going through and updating to XCode 8 and Swift 3.
Even with their Swift Converter, Apple sure didn't make it easy.
I've pushed the latest to master
and published version 1.0.0 to npm so I would recommend updating your package.json
to use
"react-native-unified-contacts": "^1.0.0",
And then do a npm update react-native-unified-contacts
.
Try out a build of your apps with this new version and let me know if you have any trouble. I'm going to close this issue for now.
I'm at a loss here, @joshuapinter . Still seeing this error after updating to 1.0.0. Here are some of the things I've tried and re-tried:
I'm on xcode 8.0, using swift 3.0
I'd really like to make this work but I feel like I'm stuck!
@jignamru Strange. Okay, let's get this working.
I tested with our existing apps, but I will try it with a fresh app now and see if I run into problems.
Stay tuned!
Josh
@jignamru Using a brand new sample app I ran into the same trouble. I think it's due to the newer version of React Native. I'll fix it and release a new update shortly.
@jignamru Okay, I was able to get it working without needing to update the library. Here's what I did:
Create a new app called ExampleApp:
$ react-native init ExampleApp
Go into that the new ExampleApp directory:
$ cd ExampleApp/
Install React Native Unified Contacts and save it to package.json
:
$ npm install --save react-native-unified-contacts
Open up the ExampleApp in XCode:
$ open ios/ExampleApp.xcodeproj/
Takes a minute to index your new project.
+
button in the bottom left and click "Add files..."
ExampleApp/node_modules/react-native-unified-contacts/
:
RNUnifiedContacts
directory and click Add
:
RNUnifiedContacts
is at the first level in my Project Structure:
ExampleApp
in the project structure:
Build Settings
tab:
Use Legacy Swift Language Version
to No
.
NSContactsUsageDescription
key to Info.plist
:
Note: After entering "NSContactsUsageDescription" and tabbing from the key field, it will be replaced with XCode's friendlier version.Open up index.ios.js
:
$ open index.ios.js
Add the following code that Includes the react-native-unified-contacts
library and gets all the Contacts:
var Contacts = require('react-native-unified-contacts');
Contacts.getContacts( (error, contacts) => {
if (error) {
console.error(error);
}
else {
console.log(contacts);
}
});
That should do it!
So try and replicate these steps and see if you can get it working. I'll be around tonight so post a reply and let me know how it goes.
Really appreciate your commitment to making this work, @joshuapinter. However, still a problem, and I noticed that I don't see what you see in step 12. This is what I see instead:
You know why that would be?
$ swift -v
Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
Target: x86_64-apple-macosx10.9
$ react-native -v
react-native-cli: 1.0.0
react-native: 0.35.0
@jignamru Can you confirm that you've got the main target selected?
@joshuapinter - yes, I have the main target selected.
And you're in XCode 8?
Yes, Version 8.0 (8A218a)
I'm baffled by this. I remember having the problem in finding that setting in my older project. I'm going to try to reinstall xcode at this point since that's one thing I haven't done.
Have you tried creating a new project and following every step from https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-253066009?
@joshuapinter yes I did start from a new project.
@jignamru That's super strange. Yeah, maybe a reinstall will help. If you just skip that step and keep going what happens?
A reinstall didn't help my case. If I keep going, I get the same undefined error:
Tried searching for answers on Google but not seeing anything relevant. Unsure what I can try next. This is so strange!
There must be something we're missing with XCode. When you find out, please post what you find back here.
@jignamru Any update?
Still hunting for answers, @joshuapinter. I'm curious, do you have Swift 2.3 installed? I wonder if I'm not seeing the "swift legacy" option because I only have Swift 3 installed by updating to the latest xcode. I tried looking into getting 2.3 installed but couldn't find good documentations out there...
@jignamru Not sure actually. I never intentionally installed it but maybe it was there with XCode 7.
So are you currently running this example on xcode 7 or 8?
On Wed, Oct 12, 2016, 9:18 PM Joshua Pinter notifications@github.com wrote:
@jignamru https://github.com/jignamru Not sure actually. I never intentionally installed it but maybe it was there with XCode 7.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-253410627, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDQWteqh6_GXjMzW_kAZI03wGXBspvIks5qzbEigaJpZM4KAJIv .
-Jigna
Xcode 8.
@Jarred-Sumner Hey Jarred, any chance you can do a quick test and see if all the steps work for you in https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-253066009 and let us know?
@joshuapinter: So another team member of mine gave this a shot and got the same results as me, with no option to select "use legacy swift" (both of us only have Swift 3.0 installed) and even after doing the rest of the steps, we are seeing the undefined error.
I tried finding a way to install an earlier version of swift, but without any success (Apple is not making it easy!) I suspect that if you remove any earlier installs of swift, you might see what we are seeing.
If you ever see and fix this, do let me know. You have a cool module but for now, I have to use another one that gets me results. Thanks again for all your help!
Man, that's frustrating. Thanks for trying it out and letting me know. I'll reopen this issue and get it properly fixed up.
Hi @joshuapinter ! Just tried your module and ran into the same issue as @jignamru using xcode 8.1beta on an ios10.1 phone :(
@bourgois This is ridiculous. I'm getting this fixed today. Did you happen to walk through all the steps in https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-253066009?
Yes I did :( but I am not starting from scratch. I am trying to use this in an existing RN project.
I also tried severals trick I found on SO about swift code inclusion within obj-c project with no luck...
Well, I’ve got it working in my project, so there IS a way. I'll just try and reverse engineer it. I won't be able to test against 8.1 beta but I'll see what's going on.
I wish I just wrote this in Obj-C from the get-go but I wanted to make use of the Swift niceties. I might still rewrite in Obj-C just so it plays nicely with React Native and rnpm, though.
I have the same error on Xcode 8.1 (8B62).
@alexHlebnikov Working on a solution here. Are you able to try the steps in https://github.com/joshuapinter/react-native-unified-contacts/issues/12#issuecomment-253066009 and let me know how it goes?
@joshuapinter I tried these steps, there is no Use Legacy Swift Language Version
in my project Build Settings.
Hello All!
My apologies for the late reply to this but I was finally able to do some sleuthing this weekend and found a resolution to this issue. It helps that I was testing this out on a freshly formatted MacBook so I was actually running into the same problem all of you guys were having. And reproducibility is half the battle.
So, it all came down to a minor change in how the files are added to your Project in XCode. You can't add the directory RNUnifiedContacts
, you have to add the three files inside of that directory instead.
See the updated Installation Instructions for what I mean.
It would be a terrific help to me if you guys could quickly test this out to see if it's working. I have a lot of updates I have planned for Unified Contacts so it would be great to solve this and not have to rewrite it in Obj-C.
Many thanks once again.
Hate to drag this bag up but I'm getting the same issues again after the latest update (Xcode 8.3) :(
@chrise86 No worries. Did you follow the install instructions to the letter?
I did, but it grumbled about the following:
Check dependencies
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
** BUILD FAILED **
The following build commands failed:
Check dependencies
Which I tried, but there are looooads of changes that it failed to do automatically.
@chrise86 Damn. I wish Apple had better support for Swift but it's especially painful for third party libraries like this. Maybe the best bet is to convert this entirely to Obj-C. Not sure.
I'm headed out for the weekend but I'll be able to look at this after I'm back. Can you keep me posted on anything you try?
Sure thing!
I am having the same issue with xcode 9. I am getting Contacts.getContacts is undefined and I cannot find any of the Swift settings. Any ideas on how to fix this?
@artkulakow Sorry for the trouble. Did you follow the instructions for including the library? I'll try with XCode9 this weekend and see if I can diagnose the issue.
I feel like I must be doing something wrong here.
To import
react-native-unified-contacts
, at the top of the file, I have:(which is copy/pasted straight out of the readme)
In the code, I run:
Running
Contacts.getContacts
throws the error at the bottom. It's as thoughContacts
is undefined and so the module isn't exported?I've followed the other instructions in the
README
- adding the folder into the project in XCode, ensuring it's a top-level folder,npm install
, etc. It's possible I did that wrong, but I checked twice.Stacktrace:
This is running in the simulator on iOS 10 in XCode 8.