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

[iOS] Third-party libraries not found for "staging" config: Solution!

Open danieldunderfelt opened this issue 10 years ago • 39 comments

Hi!

I installed CodePush in my app today and followed the instructions for multi-environments, where the docs say to create a "staging" project configuration. After doing that, the project would not build at all when the scheme was set to "staging", complaining that no libraries could be found. Re-linking with rnpm didn't help, but I figured out that the issue was that no third-party libraries (including code-push!) include the staging configuration, making the build fail.

The solution was this stackoverflow answer: http://stackoverflow.com/questions/30884778/how-to-compile-a-project-with-app-and-library-in-the-same-workspace-with-differe/30884779#30884779

I had to change it a bit, using the same string for "header search paths" as "framework search paths" (functionally omitting the /include part of that string), but now everything works.

I think this should be mentioned in the documentation right where the user is instructed to create the "staging" configuration.

danieldunderfelt avatar Jul 12 '16 10:07 danieldunderfelt

@danieldunderfelt Thanks for the feedback. I will see how we can improve the documentation.

When you created the staging project configuration, did you also manually create a Staging scheme?

geof90 avatar Jul 12 '16 18:07 geof90

Hi!

No, that was created when I copied the release config and made the staging config.

danieldunderfelt avatar Jul 12 '16 21:07 danieldunderfelt

@danieldunderfelt Unfortunately I was unable to repro the error you were seeing. After duplicating the release config and calling it staging + setting up the CODEPUSH_KEY config, all I did was go to Product > Scheme > Edit Scheme then set the Build Configuration to Staging. After that I ran the app and it was sync-ing against CodePush with the Staging key just fine.

What version of XCode are you on? I don't know if that matters but I'm using v7.1.1. Also are you using CocoaPods for dependency management?

geof90 avatar Jul 13 '16 22:07 geof90

@geof90 No, not using CocoaPods. Does it manage these things for me?

When I figured out why my builds weren't working, that the third-party packages didn't have a staging config, I thought having cocoapods wouldn't matter.

danieldunderfelt avatar Jul 14 '16 06:07 danieldunderfelt

@danieldunderfelt no I only asked because I wasn't using CocoaPods and I was wondering if you were.

geof90 avatar Jul 14 '16 06:07 geof90

@geof90 oh, good good!

Maybe your xcode made staging config for your third-party packages, and my xcode glitched out and didn't?

danieldunderfelt avatar Jul 14 '16 06:07 danieldunderfelt

Nice, this did also fix it for me. I omitted the Step 3 (changing the project.pbxproj) and my Fabric.framework does still work fine.

However when I use different PRODUCT_NAMES for the different build environment, I am getting now a build error. I am have setup the names according to this article

screen shot 2016-07-15 at 1 20 49 pm

When i build my release config everything works, but not when I build the debug or staging config. In these cases I get the following errors:

screen shot 2016-07-15 at 11 22 42 am

I have tried to fix it by

  • set Target => Info => Executable file to $(PRODUCT_NAME)
  • set Target => Bundler Loader to => $(BUILT_PRODUCTS_DIR)/$(PRODUCT_NAME).app/$(PRODUCT_NAME)

I have cleaned my build folder before each build.

This did not happen before, so it could be related to this issue.

(For now my workaround is to use different app icons in order to distinguish my different build environment - as outlines in the article above)

thorbenandresen avatar Jul 15 '16 21:07 thorbenandresen

Here I solved the staging problem by correcting the TEST_HOST which is pointing to a fixed value despite the new PRODUCT_NAME.

I've changed the scheme to use the staging variation for tests builds.

I hope it helps!

FernandoMorais avatar Jul 19 '16 00:07 FernandoMorais

Our solution might be helpful here as well: https://zeemee.engineering/how-to-set-up-multiple-schemes-configurations-in-xcode-for-your-react-native-ios-app-7da4b5237966#.pxa41apg1

huitsing avatar Jul 29 '16 06:07 huitsing

really nice @huitsing! Much more complete solution!

FernandoMorais avatar Aug 16 '16 02:08 FernandoMorais

I have the same issue, too. I use xcode 8 beta 6. library not found for -lCodePush with build configuration "Staging".

I have fix just re-add libCodePush.a at Linked Framework and Libraries. Now everything works fine =).

jm555jm avatar Aug 18 '16 09:08 jm555jm

@jm555jm THX for the hint. I had quite a few external libraries and I was desperately trying to unlink and re-link them without any luck. But manually removing and re-adding them in the Link Binary with Libraries section finally solved the issue and my builds are succeeding again.

davidruisinger avatar Nov 14 '16 23:11 davidruisinger

@jm555jm @flavordaaave thanks for the tip! It took me a couple minutes to figure out exactly how to do that, so for others:

  1. Select your app target
  2. Make sure you are in the General Tab
  3. Scroll down until Link Binary with Libraries
  4. Select libCodePush
  5. Press - minus button at the bottom left
  6. Press + plus button and search for libCodePush 👍

bernatfortet avatar Feb 01 '17 16:02 bernatfortet

Actually after trying that I found that I was still with the Release scheme. After changing it to staging, and after removing and re-adding the library it still doesn't work 😞 Same exact error.

bernatfortet avatar Feb 01 '17 16:02 bernatfortet

+1 Same error, with the header, when on Staging Scheme :(

Amurmurmur avatar Feb 02 '17 09:02 Amurmurmur

@bernatfortet, could you please try to apply instructions from this PR https://github.com/Microsoft/react-native-code-push/pull/690 and let me know if it helps?

sergey-akhalkov avatar Feb 08 '17 09:02 sergey-akhalkov

Closing this due to https://github.com/Microsoft/react-native-code-push/pull/690 has been merged and fixed similar issue https://github.com/Microsoft/react-native-code-push/issues/688, please feel free to reopen in case of any questions or issues.

sergey-akhalkov avatar Feb 13 '17 14:02 sergey-akhalkov

Hi, I also ran into an issue, and came straight here. But for me, I just had to run pod install, and then everything worked after that.

ndbroadbent avatar Apr 19 '17 17:04 ndbroadbent

Argh I still struggled with this for quite a while, but then I realized that you need to build a Release version first, before building Staging. (Because I changed the 'build products path' to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME).)

So if you run a clean, or delete derived data, make sure you switch to your Release scheme and press cmd+B to run a build, before you try to build Staging. Because your Staging build depends on some things that need to be in that Release folder.

ndbroadbent avatar Apr 19 '17 21:04 ndbroadbent

I had a trouble with cocoapods overriding this config settings, used this as a workaround:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'YourTarget'
      target.build_configurations.each do |config|
        if config.name == 'STAGING'
          config.build_settings['CONFIGURATION_TEMP_DIR'] = '$(PROJECT_TEMP_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)'
          config.build_settings['CONFIGURATION_BUILD_DIR'] = '$(PROJECT_TEMP_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)'
        end
      end
    end
  end
end

fannt avatar May 24 '17 15:05 fannt