Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error Ios #74

Open
dnb00 opened this issue Nov 22, 2024 · 5 comments
Open

Build Error Ios #74

dnb00 opened this issue Nov 22, 2024 · 5 comments

Comments

@dnb00
Copy link

dnb00 commented Nov 22, 2024

Im trying to integrate de pushiomanager im facing this issue, I followed the readme and this error keep showing up.

Is the doccsup to date?

im using: expo sdk 51
react native: 0.74
pushiomanager: 7.0

the framework folder

image

image

@alexistec
Copy link

same error . any solution?

@dnb00
Copy link
Author

dnb00 commented Dec 24, 2024

same error . any solution?

yeah i fixed this error, the docs are wrong and missing some parts i followed this https://github.com/oracle/pushiomanager-react-native/blob/master/iOS.Example.md when they say to import <PushIOManager/PushIOManager.h> should be <CX_Mobile_SDK/PushIOManager>

@dnb00
Copy link
Author

dnb00 commented Dec 24, 2024

using expo you will need to create your own plugin to move files into the correct directory

@dnb00
Copy link
Author

dnb00 commented Dec 24, 2024

I did a fork of this library to work with expo eas, because when the expo runs the "install dep" step will break the eas cause dont have cx_mobile_sdk inside framework folder, so i removed this postInstall

@dnb00
Copy link
Author

dnb00 commented Dec 24, 2024

This is my expo plugin to create ios, structure...
`const {
withDangerousMod,
withXcodeProject,
IOSConfig,
} = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

module.exports = function withPushIOManager(config) {
config = withDangerousMod(config, [
'ios',
(config) => {
const iosProjectRoot = config.modRequest.platformProjectRoot;

  const appDelegateHPath = path.join(
    iosProjectRoot,
    config.name.split(' ').join(''),
    'AppDelegate.h'
  );
  const appDelegateMPath = path.join(
    iosProjectRoot,
    config.name.split(' ').join(''),
    'AppDelegate.mm'
  );
  updateAppDelegateH(appDelegateHPath);

  updateAppDelegateM(appDelegateMPath);

  movePushio(config);

  return config;
},

]);
return withXcodeProject(config, (config) => {
const xcodeProject = config.modResults;
const fileName = path.join(
config.modRequest.projectName,
'pushio_config.json'
);

if (
  !xcodeProject ||
  !xcodeProject.pbxGroupByName ||
  !xcodeProject.getFirstTarget
) {
  console.error('❌ Xcode project não está corretamente configurado.');
  return config;
}

if (!xcodeProject.hasFile(fileName)) {
  IOSConfig.XcodeUtils.addResourceFileToGroup({
    filepath: fileName,
    groupName: config.modRequest.projectName,
    project: config.modResults,
    isBuildFile: true,
  });
  console.log(`✅ Added ${fileName} to Xcode project`);
} else {
  console.log(`ℹ️ File ${fileName} already exists in Xcode project`);
}

return config;

});
};

function updateAppDelegateH(filePath) {
let content = fs.readFileSync(filePath, 'utf-8');

if (
!content.includes(
'#import <react_native_pushiomanager/react-native-pushiomanager-umbrella.h>'
)
) {
content = content.replace(
/#import <UIKit/UIKit.h>/,
#import <UIKit/UIKit.h>\n#import <CX_Mobile_SDK/PushIOManager.h>\n#import <UserNotifications/UserNotifications.h>
);
}

if (!content.includes('UNUserNotificationCenterDelegate')) {
content = content.replace(
/@interface AppDelegate : EXAppDelegateWrapper/,
@interface AppDelegate : EXAppDelegateWrapper <UIApplicationDelegate, UNUserNotificationCenterDelegate>
);
}

fs.writeFileSync(filePath, content, 'utf-8');
console.log('Updated AppDelegate.h for PushIOManager.');
}

function updateAppDelegateM(filePath) {
const customAppDelegatePath = path.join('plugins/custom', 'AppDelegate.mm');

// Replace the AppDelegate.m file
fs.copyFileSync(customAppDelegatePath, filePath);
}

function movePushio(config) {
const projectRoot = config.modRequest.projectRoot;
const fileName =
process.env.APP_VARIANT === 'production'
? 'pushio_config_ios_prod.json'
: 'pushio_config_ios_debug.json';
const sourceFilePath = path.join(projectRoot, 'sdk', fileName);

// Path to the destination folder: ios//pushio_config
const iosFolderPath = path.join(
config.modRequest.platformProjectRoot,
config.modRequest.projectName
);
const destinationFilePath = path.join(iosFolderPath, 'pushio_config.json');

// Check if the source file exists
if (fs.existsSync(sourceFilePath)) {
// Move and rename the file
fs.cpSync(sourceFilePath, destinationFilePath, { recursive: true });
console.log(
Moved and renamed ${sourceFilePath} to ${destinationFilePath}
);
} else {
console.warn(File "${sourceFilePath}" not found at ${sourceFilePath});
process.exit(1);
}
}`

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

No branches or pull requests

2 participants