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

Unable to execute on IOS #21

Open
ashok-sl opened this issue Jan 13, 2021 · 11 comments
Open

Unable to execute on IOS #21

ashok-sl opened this issue Jan 13, 2021 · 11 comments

Comments

@ashok-sl
Copy link

I am stuck with the following issue. Can't even run a sample setup.
Platform - IOS
xCode Version - 12.3
Device - iPad

Screenshot 2021-01-13 at 5 43 44 PM

@vitorpamplona
Copy link
Owner

vitorpamplona commented Jan 13, 2021

Hum... I have never tested on an iPad. Have you tried running on a simulator just to see if it goes through?

@ashok-sl
Copy link
Author

Yes, First I tried with iPhone 11 simulator but there also the same error.

@milosh86
Copy link

Hi, I had the same issue ... try to find additional info on why it failed. I can't remember where but I found that explanation and as I remember it was because of "Privacy - Bluetooth Peripheral Usage Description" was missing in Info.plist

@vitorpamplona
Copy link
Owner

Version 0.0.17 released. It seems to be working well on my devices. Let me know if you see any issues.

@jole141
Copy link

jole141 commented Feb 9, 2023

@vitorpamplona Still not working on the iOS device. Getting "BLEAdvertiser.<function_name> is not a function." Please help :)

@maulanakurniawan
Copy link

maulanakurniawan commented Mar 30, 2023

For some reason, you need to add below entry into your Podfile manually to make it work. Put it inside your app target, then run pod install

pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios'

@Kasendwa
Copy link

For some reason, you need to add below entry into your Podfile manually to make it work. Put it inside your app target, then run pod install

pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios'

Based off this fix highlighted by @maulanakurniawan , here is how you'd implement this in an expo managed project.

  1. Create a file somewhere in your project. Ex: custom-plugins/react-native-ble-advertiser.js and paste the code below in it.
const { withDangerousMod } = require('@expo/config-plugins');
const { mergeContents } = require('@expo/config-plugins/build/utils/generateCode');
const fs = require('fs');
const path = require('path');

function withPodfile(config) {
	return withDangerousMod(config, [
		'ios',
		async config => {
			const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
			const contents = fs.readFileSync(filePath, 'utf-8');

			const addedPod = mergeContents({
				tag: 'Add the BLEAdvertiser pod',
				src: contents,
				newSrc: `pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios'`,
				anchor: 'use_expo_modules!',
				offset: 0,
				comment: '#'
			});

			if (!addedPod.didMerge) {
				console.log(
					"ERROR: Cannot add BLEAdvertiser pod the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile."
				);
				return config;
			}

			fs.writeFileSync(filePath, addedPod.contents);

		return config;
		}
	]);
}

module.exports = function withBLEAdvertiserPodFix(config) {
	config = withPodfile(config);
	return config;
};

Then in your expo config file, add the following under expo.plugins

{
    "expo": {
         "plugins": [
            ...,
            "./custom-plugins/react-native-ble-advertiser.js"
        ]
    }
}

@leodevbro
Copy link

@Kasendwa, please help me to setup Expo project with this package (react-native-ble-advertiser). Does your solution work also on Android? If not, could you please provide a minimal Expo project with this package working on both iOS and Android? It is really a big dream for me to make it possible with the simple flow of Expo (Without the need of Android Studio and Mac XCode).

Here:
#55
@fhllnd did a great job by providing the bare React Native working minimal project (it is updated example project, because the old example project no longer works), and it seems very useful and informative code even if I somehow manage to setup react-native-ble-advertiser with Expo.

I was going to go with bare React Native flow, but I discovered that nowadays Expo became too powerful to ignore. It no longer needs ejecting and it can just implement unsupported npm packages by config plugins (like your solution) and/or development builds and/or creating native modules. The thing is that I am still very new to RN world and I feel I need a little help to implement this package as a config plugin (or something like that), just to get the minimal project setup.

@Kasendwa
Copy link

Hi @leodevbro, sorry I had missed this. Let me look into it tomorrow and get back to you.

@leodevbro
Copy link

Hi @leodevbro, sorry I had missed this. Let me look into it tomorrow and get back to you.

Oh, it's ok. Thanks. Sure, I can wait many days or many weeks. I'm just trying to at least find out if this is possible without a big headache.

@leodevbro
Copy link

@Kasendwa, Hi again, just wanted to ask, have you had any opportunity to have a look at it? I understand if you have limited time.

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

No branches or pull requests

7 participants