react-native icon indicating copy to clipboard operation
react-native copied to clipboard

asset error after upgrading to RN 0.32.0

Open krapspark opened this issue 10 years ago • 14 comments

After trying to upgrade to 0.32.0, I'm getting the following error when I run my project from command-line (i.e. react-native run-ios):

NSArray cannot be converted to an image

simulator screen shot aug 30 2016 10 39 51 am

The project runs fine when I run it from Xcode. When I create a new project using RN CLI, I can include images without any errors.

Anyone have any clue on what might be causing this? Thanks!

krapspark avatar Aug 30 '16 17:08 krapspark

I have the exact same error both when running from react-native run-ios and when running from XCode... It seems to be related to multi-source images.

Changing sources = [source]; to sources = source; in https://github.com/facebook/react-native/blob/0.32-stable/Libraries/Image/Image.ios.js#L316 fixes it for me.

Still investigating...

cosmith avatar Aug 30 '16 18:08 cosmith

Upgrading to 0.33.0-rc did not fix the issue.

cosmith avatar Aug 30 '16 18:08 cosmith

There was this commit which might have caused this: https://github.com/facebook/react-native/commit/fd48bc3cff29797f5f2f251ad00c1ba3caf5ea4d #1372

@DavidGoldman @mmmulani can you check if there is a bug in the commit?

krapspark avatar Aug 30 '16 20:08 krapspark

I have the same exact issue, luckily the workaround provided by @cosmith works for me.

kelset avatar Aug 31 '16 07:08 kelset

@mmmulani this is the method that throws the error and it looks like you haven't touched it in your multi-source images commit https://github.com/facebook/react-native/blob/master/React/Base/RCTImageSource.m#L53-L82 I don't really understand when it is called but when I set a breakpoint it directs me to https://github.com/facebook/react-native/blob/8a8ac771b11383986f28a706ba550775ed450b61/React/Views/RCTComponentData.m#L239 . Maybe @nicklockwood would know about this?

cosmith avatar Aug 31 '16 10:08 cosmith

This would really point at the binary code RN is running being out-of-date. The native side now expects an array for the source prop and the JS side only emits that type. The fact that it works when you run from xcode means whatever other method you're using does not rebuild the app.

javache avatar Aug 31 '16 18:08 javache

@javache I'm just using the react native CLI when I run it from command line. (i.e. react-native run-ios)

Are there more steps required to clean the build when I run from command line?

krapspark avatar Sep 01 '16 18:09 krapspark

Copying and pasting the ios/ directory from my coworker fixed the issue... go figure.

cosmith avatar Sep 02 '16 13:09 cosmith

@cosmith is it possible for you to do a diff of your files vs your coworker's files? That would be tremendously helpful in locating the source of this issue. Thank you!

krapspark avatar Sep 02 '16 17:09 krapspark

Unfortunately I didn't think of it and deleted my folder... Sorry :/

cosmith avatar Sep 05 '16 13:09 cosmith

I had the same issue in my project:

Project was initialised with RN 0.31, applied this fix #8584 to be able to run on my iOS 10 beta device with Xcode 8 beta.

Issue appeared after upgrading to RN 0.32 (did run the react-native upgrade script, and chose the default "Y" to all prompts).

Building from Xcode again fixed the problem, had to reapply the fix, and set the team profile in order to have Xcode build.

forsen avatar Sep 05 '16 16:09 forsen

Ok, I'm back with news. In my past comment I said that the fix @cosmith provided fixed the issue... well, it actually only fixed it on one of the schemes I had in XCode for the RN project. Today, while going back to XCode for installing something else (Fabric) I noticed that the production scheme was still presenting the issue! Not sure of the reason, I tried the @forsen tactic of applying the fix #8584.

That didn't do anything. So I went for the hard lane: I closed the terminal where node server was running, closed the iOS simulator, Xcode and... completely removed the content of the /node_modules folder. After that, I run npm install in the root folder of the project and re-run to do all the react-native run-ios --scheme "XXXX". This time, everything worked.

IMHO I think that was did the trick was basically forcing all the underlines tools to rebuild everything from scratch.

kelset avatar Sep 07 '16 11:09 kelset

@Sciandra-Leva yeah, I think there's something in my build process that's holding on to an older build of some component.

I got the dev build running through Xcode, though, so I'm no longer blocked. I'm going to close this issue.

A nice guide to really clean the build of every build step would be helpful in the future, though.

krapspark avatar Sep 08 '16 18:09 krapspark

I am getting this same error when trying to upgrade from 0.28 to 0.33. I am on a hybrid app, so I thought it had something to do with Cocoapods still using the older one. But I put a breakpoint in https://github.com/facebook/react-native/blob/v0.33.0/React/Base/RCTImageSource.m#L83, and it had the updated file. The json variable is a NSMutableArray. It seems like it's using the array directly instead of looping through it? I've tried clean building, and nothing seems to work.

mikeygee avatar Sep 20 '16 22:09 mikeygee