Skip to content

Commit

Permalink
Updated iOS Project
Browse files Browse the repository at this point in the history
  • Loading branch information
ravindraguptacapgemini committed Jul 27, 2023
1 parent 097051b commit a9cfdd9
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 23 deletions.
40 changes: 27 additions & 13 deletions ReproducerApp/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,34 @@
* @format
*/

import React, { useRef } from 'react';
import type { PropsWithChildren } from 'react';
import React, { useReducer } from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
Button,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Colors,
} from 'react-native/Libraries/NewAppScreen';
import { Colors } from 'react-native/Libraries/NewAppScreen';

import MapView, { Marker, enableLatestRenderer, PROVIDER_GOOGLE } from 'react-native-maps';
import MapView, {
Marker,
enableLatestRenderer,
PROVIDER_GOOGLE,
} from 'react-native-maps';

enableLatestRenderer();

function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const forceUpdate = useReducer(x => x + 1, 0)[1];

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
// <SafeAreaView style={backgroundStyle}>
<View style={styles.container}>
const renderMap = () => {
return (
<MapView
style={styles.map}
provider={PROVIDER_GOOGLE}
Expand Down Expand Up @@ -72,6 +70,22 @@ function App(): JSX.Element {
description={'description'}
/>
</MapView>
);
};

let map = renderMap();

return (
// <SafeAreaView style={backgroundStyle}>
<View style={styles.container}>
{map}
<Button
color={'red'}
title={'Re-render Map'}
onPress={() => {
forceUpdate();
}}
/>
</View>
// </SafeAreaView>
);
Expand Down
41 changes: 33 additions & 8 deletions ReproducerApp/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require Pod::Executable.execute_command('node', ['-p',
{paths: [process.argv[1]]},
)', __dir__]).strip

platform :ios, min_ios_version_supported
platform :ios, 13
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
Expand All @@ -17,20 +17,32 @@ prepare_react_native_project!
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
# flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
# linkage = ENV['USE_FRAMEWORKS']
# if linkage != nil
# Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
# use_frameworks! :linkage => linkage.to_sym
# end

target 'ReproducerApp' do
config = use_native_modules!

# Flags change depending on the env values.
flags = get_default_flags()

$static_framework = [
'react-native-maps',
'react-native-google-maps',
'Google-Maps-iOS-Utils',
'GoogleMaps'
]

pod 'react-native-google-maps', :path => '../node_modules/react-native-maps'
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod 'GoogleUtilities', :modular_headers => true

use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
Expand All @@ -40,7 +52,7 @@ target 'ReproducerApp' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
:flipper_configuration => FlipperConfiguration.disabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
Expand All @@ -50,6 +62,19 @@ target 'ReproducerApp' do
# Pods for testing
end

pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name)
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
Expand Down
36 changes: 34 additions & 2 deletions ReproducerApp/ios/ReproducerApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,19 @@
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
INFOPLIST_FILE = ReproducerApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(SDKROOT)/usr/lib/swift",
"$(inherited)",
"\"${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}\"",
/usr/lib/swift,
"$(PODS_ROOT)/../../node_modules/react-native-maps/lib/ios/AirMaps",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -513,11 +521,19 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
INFOPLIST_FILE = ReproducerApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(SDKROOT)/usr/lib/swift",
"$(inherited)",
"\"${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}\"",
/usr/lib/swift,
"$(PODS_ROOT)/../../node_modules/react-native-maps/lib/ios/AirMaps",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -564,7 +580,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -580,6 +596,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
);
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
Expand Down Expand Up @@ -635,7 +659,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -644,6 +668,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
);
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
Expand Down
7 changes: 7 additions & 0 deletions ReproducerApp/ios/ReproducerApp/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <GoogleMaps/GoogleMaps.h>

@implementation AppDelegate

Expand All @@ -11,6 +12,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};

NSString *mapsKey = @"QUl6YVN5Q1k0OVJpQmVZX2ZxRTh1b0c2WmF1VG9RU0VpNzZLNnB3";
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:mapsKey options:0];
NSString *decodedKey = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];

[GMSServices provideAPIKey:decodedKey];

return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

Expand Down

0 comments on commit a9cfdd9

Please sign in to comment.