Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Unable to compile on iOS #1

Closed
PerThomasHaga opened this issue Mar 11, 2019 · 22 comments
Closed

Unable to compile on iOS #1

PerThomasHaga opened this issue Mar 11, 2019 · 22 comments
Labels
question Further information is requested

Comments

@PerThomasHaga
Copy link

Hello!

I am unable to build the project on iOS. I am trying to get it built on a clean project with the following steps:

react-native init LaunchDarklyTest
cd LaunchDarklyTest
yarn add launchdarkly-react-native-client
react-native link launchdarkly-react-native-client
cd ios 
pod init

I change the Podfile to the following:

# Uncomment the next line to define a global platform for your project
use_frameworks!
platform :ios, '9.0'

target 'LaunchDarklyTest' do
  rn_path = '../node_modules/react-native'
  rn_darkly_path = '../node_modules/launchdarkly-react-native-client/ios'

  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  #launchdarkly-react-native-client dependencies

  pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client.git', :branch => 'v3-beta'
  
  pod 'LaunchdarklyReactNativeClient', path: rn_darkly_path

end

as instructed in the docs, and run pod install.

I open LaunchDarklyTest.xcworkspace with Xcode and compile the project.

I then receive the following error:
image

My environment info:

React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 31.83 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 22.0.1, 23.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.2/10P107d - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.58.6 => 0.58.6
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7
@torchhound
Copy link
Contributor

Hi @PerThomasHaga our beta Swift SDK was updated and some breaking changes occurred. Try adding the tag for the previous iOS Swift beta release to your Podfile pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client.git', :branch => 'v3-beta', :tag => '3.0.0-beta.2'. I've amended the documentation to reflect this.

@PerThomasHaga
Copy link
Author

Thank you for the answer, @torchhound. Sadly it didn't remove the error. Can you reproduce it by making a clean project and adding launchdarkly-react-native-client?

@torchhound
Copy link
Contributor

torchhound commented Mar 12, 2019

@PerThomasHaga I used very similar steps with the exception of npm i --save instead of yarn add and creating a Podfile and pod install instead of running pod init. I used the same name, LaunchDarklyTest, and had a successful build. I double-checked and our example application is currently working. Currently, React Native has several bugs on iOS and you have to manually link binaries to the React pod, your project workspace, and your test project workspace. Here are some links to the possible bugs: Link JS.core and Link glog and Double Conversion. The hello-react-native ios workspace has all of the correct libraries linked. Sometimes this can lead to an import LaunchDarkly not found error. I've attached a screenshot of my React Native Environment.
Screen Shot 2019-03-12 at 9 49 29 AM

@torchhound torchhound added the question Further information is requested label Mar 18, 2019
@BG687
Copy link

BG687 commented Mar 22, 2019

I am having the same issue. For me, I need to set use_modular_headers! in order to even run pod install. Otherwise I get a couple of errors, including:

The Swift pod LaunchDarkly depends upon DarklyEventSource, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.

@BG687
Copy link

BG687 commented Mar 22, 2019

Sidenote: When I try to build LaunchDarklyReactNativeClient, I get the error Use of undeclared type 'LDFlagChangeOwner' in a number of files - including:

@objc(LaunchdarklyReactNativeClient) class LaunchdarklyReactNativeClient: RCTEventEmitter { private var listenerKeys: [String:LDFlagChangeOwner] = [:]

@markygab
Copy link

I'm also seeing this. Did anyone find the issue or a workaround?

@PerThomasHaga
Copy link
Author

As @torchhound implied it was something wrong with the linking. I managed to get it compiling by adding $(SRCROOT)/../node_modules/launchdarkly-react-native-client/ios to "Header Search Paths" in you target -> Build Settings -> Header Search Paths.

@BG687
Copy link

BG687 commented Mar 25, 2019

@PerThomasHaga @torchhound

Thanks for that. Adding that header search path DID remove one of the errors I was having.

But I still have the following error while building LaunchdarklyReactNativeClient:

Use of undeclared type 'LDFlagChangeOwner' in LaunchdarklyReactNativeClient.swift

Screen Shot 2019-03-25 at 10 07 59 AM

@torchhound
Copy link
Contributor

torchhound commented Mar 25, 2019

@BG687 that might be a caching error, I'll try and investigate and reproduce. I've run into that error while testing the React Native client against iOS client 3.0.0-beta.3. beta.3 deprecated LDFlagChangeOwner. Please try rm -rf Pods/ && pod install with 3.0.0-beta.2 in your Podfile.

@torchhound
Copy link
Contributor

@PerThomasHaga is this issue resolved for you? It sounds like other commenters have different build problems.

@testower
Copy link

I'm a colleague of @PerThomasHaga, and we managed to power through this issue or so it seems. After we stumbled into the issue in #2 , we are now facing an issue where after Xcode upgrades to 10.2, LDClient refuses to compile due to incompatible Swift versions. Are these all separate issues?

@torchhound
Copy link
Contributor

@testower I'm currently running Xcode 10.1, we haven't tested with 10.2. I'll look into this but for right now my only suggestion is downgrading to 10.1.

@BG687
Copy link

BG687 commented Mar 27, 2019

@torchhound Even though I set the tag to 3.0.0-beta.2 in my podfile, it was being over-written by the branch :branch => 'v3-beta', which must use 3.0.0-beta.3 as it's default. Removing the branch specification from the pod solved that issue. Maybe the documentation should be updated to reflect this -- there is no need to specify the branch, it seems?

However, requiring React to use modular headers created issues in a different dependency in our project...

@torchhound
Copy link
Contributor

torchhound commented Mar 27, 2019

@BG687 I'm glad that was resolved, I'll update the documentation accordingly. Would you please elaborate on the modular headers issue?

@testower
Copy link

testower commented Mar 28, 2019

Cheers @torchhound , I have successfully managed to compile on Xcode 10.1 after downgrading, and with workaround for #2 in place the bundler is also successful. However, when trying to use LDClient now we get the following runtime warning from RN:

image

I've tried re-linking, cleaning and reinstalling pods, to no avail. Any idea what might be going on here?

@torchhound
Copy link
Contributor

@testower I'd check the compile log in Xcode for warnings or errors. If that's clean I'd run react-native run-ios which in my experience sometimes surfaces additional log messages. Alternatively, automatic linking may have failed in which case you'll need to do it manually.

@OpsBaseCTO
Copy link

OpsBaseCTO commented Mar 30, 2019

I have managed to solve the issues above by downgrading to 3.0.0-beta.2 and changing the package.json in a fork of the project to adjust the react/react-native dependancies

However, I still don't seem to be able to build the project

I have set up the PodFile as suggested, and run react-native link launchdarkly-react-native-client

However, whenever I try and build the project in XCode (10.1) I get a bunch of errors such as:-

  • Could not build module "Darwin"
  • Unknown type name "namespace"

I have fiddled and googled but I just can't seem to work it out

Any thoughts?

@torchhound
Copy link
Contributor

@OpsBaseCTO those errors are associated with unlinked libraries in React Native. This is an issue with React Native not the LaunchDarkly package. Here are some links to the bugs: Link JS.core and Link glog and Double Conversion. The hello-react-native ios workspace has all of the correct libraries linked.

@PerThomasHaga
Copy link
Author

@OpsBaseCTO If I remember correctly I also had those issues that I fixed by downgrading Cocoapods from 1.6.1 to 1.5.3. So you can try that if you still haven't fixed it.

@torchhound you can close this issue If you want.

@torchhound
Copy link
Contributor

@PerThomasHaga thanks for the heads up! If you or any other commenters has any more problems don't hesitate to recomment, open a new issue, or contact support.

@mcatmos
Copy link

mcatmos commented May 13, 2019

Hi! im still having issues even following this thread couldn't get a solution:

Screenshot 2019-05-13 at 09 59 03

@torchhound
Copy link
Contributor

Hi @mcatmos, I believe that your issue should be resolved if you update your Podfile to: pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client.git', :tag => '3.0.0-beta.3'. The name of that class was a breaking change between iOS 3.0.0-beta.2 and 3.0.0-beta.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants